Show more than 3 item in a wearable listview without scrolling

China☆狼群 提交于 2019-12-11 12:50:11

问题


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>

回答1:


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.




回答2:


I modified WearableListView and made it support more than three items:

https://github.com/zjbpku/CenterScaledRecyclerView



来源:https://stackoverflow.com/questions/32197217/show-more-than-3-item-in-a-wearable-listview-without-scrolling

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!