Search code examples
listviewscrollpaddingwear-oslistviewitem

Show more than 3 item in a wearable listview without scrolling


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:

WearableListView

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>

Solution

  • 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.