পরিধানে কব্জির অঙ্গভঙ্গি ব্যবহার করুন
সেভ করা পৃষ্ঠা গুছিয়ে রাখতে 'সংগ্রহ' ব্যবহার করুন
আপনার পছন্দ অনুযায়ী কন্টেন্ট সেভ করুন ও সঠিক বিভাগে রাখুন।
একটি টাচ স্ক্রীন অসুবিধাজনক হলে কব্জি অঙ্গভঙ্গি আপনার অ্যাপের সাথে দ্রুত, এক হাতে মিথস্ক্রিয়া সক্ষম করতে পারে।
উদাহরণস্বরূপ, একজন ব্যবহারকারী এক হাতে এক কাপ জল অন্য হাতে ধরে রেখে বিজ্ঞপ্তিগুলির মাধ্যমে স্ক্রোল করতে পারেন। কব্জি অঙ্গভঙ্গি জন্য অন্যান্য ব্যবহারের ক্ষেত্রে নিম্নলিখিত অন্তর্ভুক্ত:
- একটি জগিং অ্যাপে, উল্লম্ব স্ক্রিনের মাধ্যমে নেভিগেট করা যা গৃহীত পদক্ষেপ, অতিবাহিত সময় এবং বর্তমান গতি দেখায়
- একটি ভ্রমণ অ্যাপে, ফ্লাইট এবং গেটের তথ্যের মাধ্যমে স্ক্রোল করা
- একটি সংবাদ অ্যাপে, নিবন্ধগুলির মাধ্যমে স্ক্রোল করা হচ্ছে
ঘড়ির যন্ত্রে কব্জির অঙ্গভঙ্গি পর্যালোচনা করতে, সেটিংস > উন্নত বৈশিষ্ট্য > অঙ্গভঙ্গি > হাতের অঙ্গভঙ্গি চালু নির্বাচন করে নিশ্চিত করুন যে অঙ্গভঙ্গি চালু আছে। তারপর লঞ্চ টিউটোরিয়াল নির্বাচন করে ঘড়িতে অঙ্গভঙ্গি টিউটোরিয়ালটি সম্পূর্ণ করুন।
দ্রষ্টব্য: কব্জি কাঁপানো হল সিস্টেম-ব্যাপী পিছনে বা পূর্বাবস্থায় ফেরানো অঙ্গভঙ্গি এবং কাস্টমাইজ করার জন্য অ্যাপগুলির জন্য উপলব্ধ নয়৷
কব্জির অঙ্গভঙ্গি নিম্নলিখিত উপায়ে ব্যবহার করা যেতে পারে, যেমন এই নির্দেশিকায় বর্ণনা করা হয়েছে:
প্রতিটি কব্জি অঙ্গভঙ্গি KeyEvent
ক্লাস থেকে একটি int
ধ্রুবক ম্যাপ করা হয়, যেমনটি নিম্নলিখিত টেবিলে দেখানো হয়েছে:
কব্জির অঙ্গভঙ্গি সমর্থন করার জন্য একটি বাঁকা বিন্যাস ব্যবহার করুন
WearableRecyclerView
ক্লাস তালিকার জন্য একটি বাঁকা লেআউট প্রদান করে এবং স্বয়ংক্রিয়ভাবে কব্জি অঙ্গভঙ্গি সমর্থন করে। ক্লাসে কব্জির অঙ্গভঙ্গির ঘটনার জন্য পূর্বনির্ধারিত ক্রিয়া রয়েছে যখন দৃশ্যের ফোকাস থাকে। WearableRecyclerView
ক্লাস ব্যবহার করার বিষয়ে তথ্যের জন্য, Wear OS-এ তালিকা তৈরি করুন দেখুন। এছাড়াও, এই গাইডের সেরা অনুশীলন বিভাগটি দেখুন।
দ্রষ্টব্য: WearableRecyclerView
ক্লাস পরিধানযোগ্য সমর্থন লাইব্রেরিতে অনুরূপ, অবচয়িত শ্রেণী প্রতিস্থাপন করে।
এমনকি যদি আপনি একটি WearableRecyclerView
ব্যবহার করেন, আপনি KeyEvent
ক্লাস থেকে ধ্রুবক ব্যবহার করতে চাইতে পারেন। WearableRecyclerView
সাবক্লাসিং এবং onKeyDown()
কলব্যাক পুনরায় প্রয়োগ করে পূর্বনির্ধারিত ক্রিয়াগুলি ওভাররাইড করা যেতে পারে। setEnableGestureNavigation(false)
ব্যবহার করে আচরণটি সম্পূর্ণরূপে নিষ্ক্রিয় করা যেতে পারে। আরও তথ্যের জন্য, কীবোর্ড ক্রিয়াগুলি হ্যান্ডেল দেখুন।
মূল ঘটনা সরাসরি ব্যবহার করুন
অঙ্গভঙ্গি ইভেন্টের প্রতিক্রিয়ায় নতুন অ্যাকশন ট্রিগার করতে আপনি WearableRecyclerView
এর বাইরে মূল ইভেন্টগুলি ব্যবহার করতে পারেন। গুরুত্বপূর্ণভাবে, এই অঙ্গভঙ্গি ইভেন্টগুলি যখন একটি ডিভাইস সক্রিয় মোডে থাকে তখন স্বীকৃত হয় এবং সেগুলি সমস্ত মূল ইভেন্টগুলির মতোই বিতরণ করা হয়৷
একটি শ্রেণী যা ব্যবহারকারীর ইন্টারঅ্যাকশনের সাথে সম্পর্কিত, যেমন একটি View
বা একটি Activity
, এবং যা KeyEvent.Callback
প্রয়োগ করে৷ কলব্যাক মূল ইভেন্টগুলি শুনতে পারে যা কব্জির অঙ্গভঙ্গির সাথে সম্পর্কিত ঠিক যেমন এটি অন্য কোনো মূল ইভেন্টের সাথে তালিকাভুক্ত হতে পারে৷ অ্যান্ড্রয়েড ফ্রেমওয়ার্ক View
বা Activity
বলে যা মূল ইভেন্টগুলির সাথে ফোকাস করে। অঙ্গভঙ্গির জন্য, অঙ্গভঙ্গি ঘটলে onKeyDown()
পদ্ধতি কলব্যাক বলা হয়।
উদাহরণ হিসেবে, একটি অ্যাপ একটি View
বা Activity
পূর্বনির্ধারিত ক্রিয়াগুলিকে ওভাররাইড করতে পারে যা KeyEvent.Callback
প্রয়োগ করে নিম্নরূপ:
কোটলিন
class GesturesActivity : Activity() {
/* KeyEvent.Callback */
override fun onKeyDown(keyCode: Int, event: KeyEvent): Boolean {
return when (keyCode) {
KeyEvent.KEYCODE_NAVIGATE_NEXT ->
// Do something that advances a user View to the next item in an ordered list.
moveToNextItem()
KeyEvent.KEYCODE_NAVIGATE_PREVIOUS ->
// Do something that advances a user View to the previous item in an ordered list.
moveToPreviousItem()
else -> {
// If you did not handle it, let it be handled by the next possible element as determined
// by the Activity.
super.onKeyDown(keyCode, event)
}
}
}
/** Shows the next item in the custom list. */
private fun moveToNextItem(): Boolean {
...
// Return true if handled successfully, otherwise return false.
return false
}
/** Shows the previous item in the custom list. */
private fun moveToPreviousItem(): Boolean {
...
// Return true if handled successfully, otherwise return false.
return false
}
}
জাভা
public final class GesturesActivity extends Activity {
@Override /* KeyEvent.Callback */
public boolean onKeyDown(int keyCode, KeyEvent event) {
switch (keyCode) {
case KeyEvent.KEYCODE_NAVIGATE_NEXT:
// Do something that advances a user View to the next item in an ordered list.
return moveToNextItem();
case KeyEvent.KEYCODE_NAVIGATE_PREVIOUS:
// Do something that advances a user View to the previous item in an ordered list.
return moveToPreviousItem();
}
// If you did not handle it, let it be handled by the next possible element as determined by the Activity.
return super.onKeyDown(keyCode, event);
}
/** Shows the next item in the custom list. */
private boolean moveToNextItem() {
boolean handled = false;
...
// Return true if handled successfully, otherwise return false.
return handled;
}
/** Shows the previous item in the custom list. */
private boolean moveToPreviousItem() {
boolean handled = false;
...
// Return true if handled successfully, otherwise return false.
return handled;
}
}
সর্বোত্তম অনুশীলন
-
KeyEvent
এবং KeyEvent.Callback
পর্যালোচনা করুন। আপনার View
এবং Activity
মূল ইভেন্টগুলি সরবরাহের জন্য কলব্যাক পৃষ্ঠাগুলি। - একটি সামঞ্জস্যপূর্ণ দিকনির্দেশক সামর্থ্য রাখুন: পরের জন্য "ফ্লিক রিস্ট আউট" এবং আগের জন্য "কব্জি ফ্লিক ইন" ব্যবহার করুন।
- একটি অঙ্গভঙ্গি জন্য একটি স্পর্শ সমান্তরাল আছে.
- চাক্ষুষ প্রতিক্রিয়া প্রদান.
- কার্যকারিতা বাস্তবায়নের জন্য একটি কীকোড ব্যবহার করবেন না যা সিস্টেমের বাকি অংশের বিপরীত হবে। উদাহরণস্বরূপ, একটি ক্রিয়া বাতিল করতে বা ফ্লিক সহ বাম-ডান অক্ষে নেভিগেট করতে
KEYCODE_NAVIGATE_NEXT
ব্যবহার করবেন না৷ - ব্যবহারকারী ইন্টারফেসের অংশ নয় এমন উপাদানগুলির মূল ইভেন্টগুলিকে বাধা দেবেন না, যেমন দৃশ্যগুলি অফস্ক্রিন বা আংশিকভাবে আচ্ছাদিত৷ এটি যে কোনও মূল ইভেন্টের মতোই।
- আপনার নিজের অভিনব অঙ্গভঙ্গিতে বারবার ফ্লিক অঙ্গভঙ্গি পুনরায় ব্যাখ্যা করবেন না। এটি সিস্টেমের "কব্জি কাঁপানো" অঙ্গভঙ্গির সাথে বিরোধপূর্ণ হতে পারে।
অঙ্গভঙ্গি কী ইভেন্টগুলি পেতে একটি দৃশ্যের জন্য, এটিতে অবশ্যই ফোকাস থাকতে হবে; View.setFocusable()
দেখুন।
যেহেতু অঙ্গভঙ্গিগুলিকে মূল ইভেন্ট হিসাবে বিবেচনা করা হয়, তারা "টাচ মোড" থেকে একটি ট্রানজিশন ট্রিগার করে যা অপ্রত্যাশিত জিনিসগুলি করতে পারে। যেহেতু ব্যবহারকারীরা স্পর্শ এবং অঙ্গভঙ্গি ব্যবহারের মধ্যে বিকল্প হতে পারে, তাই View::setFocusableInTouchmode()
পদ্ধতিটি প্রয়োজনীয় হতে পারে। কিছু ক্ষেত্রে, setDescendantFocusability(FOCUS_BEFORE_DESCENDANTS)
ব্যবহার করারও প্রয়োজন হতে পারে যাতে স্পর্শ মোডে বা থেকে পরিবর্তনের পরে যখন ফোকাস পরিবর্তিত হয়, তখন আপনার অভিপ্রেত ভিউ ফোকাস পায়।
-
requestFocus()
এবং clearFocus()
সাবধানে ব্যবহার করুন:-
requestFocus()
কল করার সময়, নিশ্চিত করুন যে এটি দৃষ্টিভঙ্গির জন্য উপযুক্ত। যদি দৃশ্যটি অফস্ক্রিন হয় বা অন্য একটি দৃশ্য দ্বারা আচ্ছাদিত হয়, তাহলে আশ্চর্য ঘটতে পারে যখন অঙ্গভঙ্গি কলব্যাকগুলিকে ট্রিগার করে। -
clearFocus()
পদ্ধতি অন্য একটি উপযুক্ত ভিউ খুঁজে পেতে একটি ফোকাস অনুসন্ধান শুরু করে। ভিউ অনুক্রমের উপর নির্ভর করে, এই অনুসন্ধানের জন্য অ-তুচ্ছ গণনার প্রয়োজন হতে পারে। এটি এমন একটি দৃশ্যে ফোকাস বরাদ্দ করতে পারে যা আপনি ফোকাস পাওয়ার আশা করেন না।
মূল ইভেন্টগুলি প্রথমে ভিউ হায়ারার্কিতে ফোকাস সহ ভিউতে পৌঁছে দেওয়া হয়। যদি ফোকাসড ভিউ ইভেন্টটি পরিচালনা না করে - অন্য কথায়, এটি false
ফেরত দেয় - ইভেন্টটি প্যারেন্ট ভিউতে বিতরণ করা হয় না, এমনকি যদি এটি ফোকাস পেতে পারে এবং একটি KeyListener
থাকে। বরং, ইভেন্টটি বর্তমান ক্রিয়াকলাপে বিতরণ করা হয় যাতে দৃষ্টিক্রমিক ফোকাস থাকে।
অতএব, উচ্চ স্তরে সমস্ত ইভেন্ট ধরার প্রয়োজন হতে পারে, তারপর প্রাসঙ্গিক কোডগুলি নীচে পাস করুন৷ বিকল্পভাবে, আপনি ক্রিয়াকলাপটিকে সাবক্লাস করতে পারেন এবং dispatchKeyEvent(KeyEvent event)
পদ্ধতিটি ওভাররাইড করতে পারেন যখন প্রয়োজনে কীগুলিকে আটকাতে পারেন বা নীচের স্তরগুলিতে পরিচালনা করা না হলে সেগুলি পরিচালনা করতে পারেন৷
এই পৃষ্ঠার কন্টেন্ট ও কোডের নমুনাগুলি Content License-এ বর্ণিত লাইসেন্সের অধীনস্থ। Java এবং OpenJDK হল Oracle এবং/অথবা তার অ্যাফিলিয়েট সংস্থার রেজিস্টার্ড ট্রেডমার্ক।
2025-07-29 UTC-তে শেষবার আপডেট করা হয়েছে।
[[["সহজে বোঝা যায়","easyToUnderstand","thumb-up"],["আমার সমস্যার সমাধান হয়েছে","solvedMyProblem","thumb-up"],["অন্যান্য","otherUp","thumb-up"]],[["এতে আমার প্রয়োজনীয় তথ্য নেই","missingTheInformationINeed","thumb-down"],["খুব জটিল / অনেক ধাপ","tooComplicatedTooManySteps","thumb-down"],["পুরনো","outOfDate","thumb-down"],["অনুবাদ সংক্রান্ত সমস্যা","translationIssue","thumb-down"],["নমুনা / কোড সংক্রান্ত সমস্যা","samplesCodeIssue","thumb-down"],["অন্যান্য","otherDown","thumb-down"]],["2025-07-29 UTC-তে শেষবার আপডেট করা হয়েছে।"],[],[],null,["# Use wrist gestures on Wear\n\nWrist gestures can enable quick, one-handed interactions with your app\nwhen a touch screen is inconvenient.\n\n\nFor example, a user can scroll\nthrough notifications with one hand while holding a cup of water with the\nother. Other use cases for wrist gestures include the following:\n\n- In a jogging app, navigating through vertical screens that show the steps taken, time elapsed, and current pace\n- In a travel app, scrolling through flight and gate information\n- In a news app, scrolling through articles\n\n\nTo review the [wrist gestures](https://support.google.com/androidwear/answer/6312406) on a watch\ndevice, confirm that gestures are\nturned on by selecting **Settings \\\u003e Advanced features \\\u003e Gestures \\\u003e Wrist Gestures\nOn** . Then complete the\nGestures tutorial on the watch by selecting **Launch Tutorial**.\n\n\n**Note:** Shaking the wrist is the system-wide back or undo gesture\nand is not available for apps to customize.\n\n\nWrist gestures can be used in the following ways, as described in this guide:\n\n- With a [curved layout](#using_wrv), which has predefined gesture actions\n- By using [key events directly](#using_key_events) to define new user actions\n\n\nEach wrist gesture is mapped to an `int` constant from the\n[KeyEvent](/reference/android/view/KeyEvent)\nclass, as shown in the following table:\n\n| Gesture | KeyEvent | Description |\n|-----------------|-------------------------------------------------------------------------------------------|------------------------------------------|\n| Flick wrist out | [`KEYCODE_NAVIGATE_NEXT`](/reference/android/view/KeyEvent#KEYCODE_NAVIGATE_NEXT) | This key code goes to the next item. |\n| Flick wrist in | [`KEYCODE_NAVIGATE_PREVIOUS`](/reference/android/view/KeyEvent#KEYCODE_NAVIGATE_PREVIOUS) | This key code goes to the previous item. |\n\nUse a curved layout to support wrist gestures\n---------------------------------------------\n\n\nThe [WearableRecyclerView](/reference/androidx/wear/widget/WearableRecyclerView) class provides a curved\nlayout for lists and automatically supports\nwrist gestures. The class has predefined actions for occurrences of\nwrist gestures when the view has focus. For information about using\nthe `WearableRecyclerView` class, see [Create lists on Wear OS](/training/wearables/ui/lists). Also, see the\n[Best practices](#best_practices) section of this guide.\n\n\n**Note:** The `WearableRecyclerView` class replaces a similar,\n[deprecated](/training/wearables/ui/wear-ui-library#deprecations) class in the Wearable Support Library.\n\n\nEven if you use a `WearableRecyclerView`, you might want to use\nconstants from the [KeyEvent](/reference/android/view/KeyEvent)\nclass. The predefined actions can be overridden by subclassing the\n`WearableRecyclerView` and re-implementing the\n`onKeyDown()` callback. The behavior can be disabled entirely\nby using [`setEnableGestureNavigation(false)`](/reference/android/support/wearable/view/WearableListView#setEnableGestureNavigation(boolean)).\nFor more information, see\n[Handle keyboard actions](/training/keyboard-input/commands).\n\nUse key events directly\n-----------------------\n\n\nYou can use key events outside of a [WearableRecyclerView](/reference/androidx/wear/widget/WearableRecyclerView) to trigger new actions in response to gesture\nevents. Importantly, these gesture events are recognized when a device is in\nactive mode, and they are delivered in the same way as all key events.\n\n\nA class that relates to user interaction, such as a `View` or an\n`Activity`, and that implements\n[KeyEvent.Callback](/reference/android/view/KeyEvent.Callback) can listen to key events that relate to\nwrist gestures just as it can listed to any other key event. The Android framework\ncalls the `View` or `Activity` that has\nfocus with the key events. For gestures, the `onKeyDown()`\nmethod callback is called when gestures occur.\n\n\nAs an example, an app can override predefined actions in a `View`\nor `Activity` that implements `KeyEvent.Callback` as follows: \n\n### Kotlin\n\n```kotlin\nclass GesturesActivity : Activity() {\n\n /* KeyEvent.Callback */\n override fun onKeyDown(keyCode: Int, event: KeyEvent): Boolean {\n return when (keyCode) {\n KeyEvent.KEYCODE_NAVIGATE_NEXT -\u003e\n // Do something that advances a user View to the next item in an ordered list.\n moveToNextItem()\n KeyEvent.KEYCODE_NAVIGATE_PREVIOUS -\u003e\n // Do something that advances a user View to the previous item in an ordered list.\n moveToPreviousItem()\n else -\u003e {\n // If you did not handle it, let it be handled by the next possible element as determined\n // by the Activity.\n super.onKeyDown(keyCode, event)\n }\n }\n }\n\n /** Shows the next item in the custom list. */\n private fun moveToNextItem(): Boolean {\n ...\n // Return true if handled successfully, otherwise return false.\n return false\n }\n\n /** Shows the previous item in the custom list. */\n private fun moveToPreviousItem(): Boolean {\n ...\n // Return true if handled successfully, otherwise return false.\n return false\n }\n}\n```\n\n### Java\n\n```java\npublic final class GesturesActivity extends Activity {\n\n @Override /* KeyEvent.Callback */\n public boolean onKeyDown(int keyCode, KeyEvent event) {\n switch (keyCode) {\n case KeyEvent.KEYCODE_NAVIGATE_NEXT:\n // Do something that advances a user View to the next item in an ordered list.\n return moveToNextItem();\n case KeyEvent.KEYCODE_NAVIGATE_PREVIOUS:\n // Do something that advances a user View to the previous item in an ordered list.\n return moveToPreviousItem();\n }\n // If you did not handle it, let it be handled by the next possible element as determined by the Activity.\n return super.onKeyDown(keyCode, event);\n }\n\n /** Shows the next item in the custom list. */\n private boolean moveToNextItem() {\n boolean handled = false;\n ...\n // Return true if handled successfully, otherwise return false.\n return handled;\n }\n\n /** Shows the previous item in the custom list. */\n private boolean moveToPreviousItem() {\n boolean handled = false;\n ...\n // Return true if handled successfully, otherwise return false.\n return handled;\n }\n}\n```\n\nBest practices\n--------------\n\n- Review the [KeyEvent](/reference/android/view/KeyEvent) and [KeyEvent.Callback](/reference/android/view/KeyEvent.Callback) pages for the delivery of key events to your `View` and `Activity`.\n- Keep a consistent directional affordance: use \"flick wrist out\" for next and \"flick wrist in\" for previous.\n- Have a touch parallel for a gesture.\n- Provide visual feedback.\n- Don't use a keycode to implement functionality that would be counterintuitive to the rest of the system. For example, don't use `KEYCODE_NAVIGATE_NEXT` to cancel an action or to navigate the left-right axis with flicks.\n- Don't intercept the key events on elements that are not part of the user interface, such as views that are offscreen or partially covered. This is the same as for any key event.\n- Don't reinterpret repeated flick gestures into your own novel gesture. This might conflict with the system's \"shaking the wrist\" gesture.\n- For a view to receive gesture key events, it must have [focus](/reference/android/view/View#attr_android:focusable); see [`\n View.setFocusable()`](/reference/android/view/View#setFocusable(boolean)).\n\n Because gestures are treated as key events,\n they trigger a transition out of \"touch mode\" that might do unexpected\n things. Since users may alternate between using touch and\n gestures, the [`\n View::setFocusableInTouchmode()`](/reference/android/view/View#setFocusableInTouchMode(boolean)) method could be necessary. In some\n cases, it also could be necessary to use\n `setDescendantFocusability(FOCUS_BEFORE_DESCENDANTS)` so\n that when focus changes after a change to or from touch mode, your\n intended view gets the focus.\n- Use [requestFocus()](/reference/android/view/View#requestFocus()) and [clearFocus()](/reference/android/view/View#clearFocus()) carefully:\n - When calling `requestFocus()`, make sure it's appropriate for the view to have focus. If the view is offscreen or is covered by another view, surprises can occur when gestures trigger callbacks.\n - The `clearFocus()` method initiates a focus search to find another suitable view. Depending on the view hierarchy, this search might require nontrivial computation. It can also end up assigning focus to a view you don't expect to receive focus.\n- Key events are delivered first to the view with focus in the view\n hierarchy. If the focused view does not handle the event---in other words, it returns\n `false`---the event is not delivered to the parent view, even\n if it can receive focus and has a [`\n KeyListener`](/reference/android/text/method/KeyListener). Rather, the event is delivered to the current activity\n holding the view hierarchy with focus.\n\n Therefore, it might be necessary to\n catch all events at the higher level, then pass relevant codes down.\n Alternatively, you might subclass the activity and override the\n [dispatchKeyEvent(KeyEvent event)](/reference/android/app/Activity#dispatchKeyEvent(android.view.KeyEvent)) method to intercept keys\n when necessary or handle them when they are not handled at\n lower layers."]]