官术网_书友最值得收藏!

  • Android Wear Projects
  • Ashok Kumar S
  • 234字
  • 2021-07-15 17:17:52

Exploring UI components for Wear devices

In this subchapter, let's explore the commonly used Wear-specific UI components. In Wear application programming, we can use all the components that we use in mobile app programming, but how we accommodate the visual appearance of components in the Wear device needs to be well thought of before using it.

WatchViewStub: WatchViewStub helps in rendering the views for different form factors of Wearable devices. If your application is being installed on a round watch device, WatchViewStub will load the specific layout configuration for round watches. If it is square, it will load the square layout configuration:

<?xml version="1.0" encoding="utf-8"?>
<android.support.wearable.view.WatchViewStub xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/watch_view_stub"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:rectLayout="@layout/rect_activity_main"
app:roundLayout=
"@layout/round_activity_main"
tools:context="com.ashokslsk.wearapp.MainActivity"
tools:deviceIds="wear"></android.support.wearable.view.WatchViewStub>

WearableRecyclerView: WearableRecyclerView is the implementation of recyclerview specific to wearable devices. It provides a flexible view for datasets in the Wearable device viewport. We will explore WearbaleRecyclerView in detail in the coming chapters:

 <android.support.wearable.view.WearableRecyclerView
android:id="@+id/recycler_launcher_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scrollbars="vertical" />
Note: WearableListView is deprecated; the Android community recommends using WearableRecyclerView.

CircledImageVIew: An Imageview surrounded by a circle. A very handy component for presenting the image in round form factor Wearable devices:

<?xml version="1.0" encoding="utf-8"?>
<android.support.wearable.view.CircledImageView
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/circledimageview"
app:circle_color="#2878ff"
app:circle_radius="50dp"
app:circle_radius_pressed="50dp"
app:circle_border_width="5dip"
app:circle_border_color="#26ce61"
android:layout_marginTop="15dp"
android:src="@drawable/skholinguaicon"
android:layout_gravity="center_horizontal"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />

BoxInsetLayout: This Layout extends directly to Framelayout and it has the ability to recognize the form factor of the Wearable device. Shape-aware FrameLayout can box its children in the center square of the screen:

<android.support.wearable.view.BoxInsetLayout    xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.example.ranjan.androidwearuicomponents.BoxInsetLayoutDemo">

<TextView
android:text="@string/hello_world"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_box="all" />

</android.support.wearable.view.BoxInsetLayout>

After the Wear 2.0 release, a few components were deprecated for an immersive activity experience and Google strictly prohibits using them; we can still use all the components that we know in Android programming.

主站蜘蛛池模板: 隆子县| 杭州市| 平果县| 伽师县| 漯河市| 关岭| 鹿邑县| 汽车| 东乡| 开原市| 富顺县| 股票| 集贤县| 枝江市| 瓮安县| 阿勒泰市| 宿迁市| 钟祥市| 成都市| 泽库县| 灵宝市| 班戈县| 重庆市| 武夷山市| 隆昌县| 梅州市| 社旗县| 彭泽县| 鄂伦春自治旗| 兴宁市| 平和县| 东宁县| 华池县| 安陆市| 甘南县| 和静县| 新化县| 长治市| 新巴尔虎左旗| 武清区| 汝阳县|