Wear OS पर व्यू पर आधारित यूज़र इंटरफ़ेस (यूआई) बनाना

Android Jetpack में Wear OS यूज़र इंटरफ़ेस (यूआई) लाइब्रेरी शामिल है. Wear OS की यूज़र इंटरफ़ेस (यूआई) लाइब्रेरी में ये क्लास शामिल हैं:

  • CurvedTextView: बाद में दिखने वाले टेक्स्ट को आसानी से लिखने के लिए एक कॉम्पोनेंट सबसे बड़े वृत्त का वक्र, जिसे दृश्य में लिखा जा सकता है.
  • DismissibleFrameLayout: एक ऐसा लेआउट जो उपयोगकर्ता को 'वापस जाएं' बटन दबाकर या स्क्रीन पर बाईं से दाईं ओर स्वाइप करके, किसी भी व्यू को खारिज किया जा सकता है. Wear OS इस्तेमाल करने वाले लोग, स्क्रीन पर पीछे की गतिविधि के लिए बाईं से दाईं ओर स्वाइप करने की उम्मीद करते हैं.
  • WearableRecyclerView: ऐसा व्यू जो अपडेट करने के लिए बुनियादी ऑफ़सेट करता है चाइल्ड लेआउट का इस्तेमाल करके WearableLinearLayoutManager.
  • AmbientModeSupport: क्लास AmbientModeSupport.AmbientCallbackProvider इंटरफ़ेस ताकि ऐंबियंट मोड की सुविधा इस्तेमाल की जा सके.

पूरी सूची के लिए, प्रॉडक्ट की जानकारी पढ़ें.

Wear OS की यूज़र इंटरफ़ेस (यूआई) लाइब्रेरी पर डिपेंडेंसी जोड़ें

ऐप्लिकेशन बनाने के लिए, Wear OS के लिए एक खास प्रोजेक्ट बनाएं. इसके बाद, ये डिपेंडेंसी जोड़ें ऐप्लिकेशन की build.gradle फ़ाइल में:

dependencies {
    ...
  // Standard Wear OS libraries
  implementation "androidx.wear:wear:1.2.0"
  // includes support for wearable specific inputs
  implementation "androidx.wear:wear-input:1.1.0"
}

Wear OS यूज़र इंटरफ़ेस (यूआई) लाइब्रेरी पैकेज से क्लास इंपोर्ट करें

Wear OS की यूज़र इंटरफ़ेस (यूआई) लाइब्रेरी से किसी क्लास का इस्तेमाल करने के लिए, उसे androidx.wear.widget पैकेज.

लेआउट फ़ाइलों में सही एलिमेंट के नाम इस्तेमाल करें

लेआउट फ़ाइलों में, पूरी तरह क्वालिफ़ाइड नाम इस्तेमाल करें, जो Wear OS यूज़र इंटरफ़ेस (यूआई) से मेल खाते हों लाइब्रेरी.

उदाहरण के लिए, Wear OS यूज़र इंटरफ़ेस (यूआई) लाइब्रेरी से DismissibleFrameLayout क्लास, जिसे आप तय कर सकते हैं लेआउट फ़ाइल में निम्नलिखित को पूरा करना होगा:

<androidx.wear.widget.DismissibleFrameLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:id="@+id/swipe_dismiss_root" >

    <TextView
        android:id="@+id/test_content"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:gravity="center"
        android:text="Swipe the screen to dismiss me." />
</androidx.wear.widget.DismissibleFrameLayout>