且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

显示在列表视图耐磨超过3项以上不滚动

更新时间:2023-10-29 23:04:58

磨损列表视图设计为只有3个项目给予适当的超大触控的目标,所以我不会建议试图在屏幕上添加更多的项目到任何东西这应该与互动。

如果你纯粹想有一个列表中显示的,可通过滚动然后用滚动视图里面一个TextView。如果你打算重新使用它了很多,你可以封装程序了与接入方式,以各行的自定义窗口小部件。

I want to create a wearable listview that can show more than 3 item simultaneously, but the wearable listview only shows 3 item, and i have to scroll down to see the other items. Is this a WearableListView specific thing?

So my WearableListView looks like this:

But i want to show more than 3 item without scrolling, because it has enough space.

The listview container xml:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/kaempewatch_screen_bg"
android:orientation="vertical">

<android.support.wearable.view.WearableListView
    android:id="@+id/exercise_listview"
    android:layout_width="match_parent"
    android:layout_height="match_parent" />

</LinearLayout>

The item xml:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:orientation="vertical"
    android:paddingLeft="40dp"
    android:paddingRight="40dp">

<TextView
    android:id="@+id/li_tv_training_name"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:text="New Text"
    android:lines="1"
    android:ellipsize="marquee"
    android:marqueeRepeatLimit="marquee_forever"
    android:textColor="@color/white"
    android:textSize="16sp"/>

<TextView
    android:id="@+id/li_tv_training_duration"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:background="@drawable/nr_bg"
    android:textColor="@color/white"
    android:textSize="13sp"/>

</LinearLayout>

The Wear listview is designed to only have 3 items to give a suitably large touch target so I wouldn't recommend trying to add more items on the screen to anything that should be interacted with.

If you purely want to have a list displayed that can be scrolled through then use a textview inside a scrollview. You could wrapper this up into a custom widget with access methods to individual lines if you're going to re-use it a lot.