简体   繁体   中英

How to show Android Right-aligned ListItem data without overlapping the scrollbar?

I've basically the same thing as ListView row styling - left aligned text, and right-aligned icon : a listview with listitems in it that are right-aligned:

<RelativeLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="horizontal"
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content">
    <TextView
        xmlns:android="http://schemas.android.com/apk/res/android"
        android:text="Name"
        android:id="@+id/list_item_name" 
        android:layout_height="wrap_content"
        android:layout_width="wrap_content"
        android:layout_alignParentLeft="true"
        >
    </TextView>
    <TextView
        xmlns:android="http://schemas.android.com/apk/res/android"
        android:text="0x0 0s"
        android:id="@+id/list_item_value" 
        android:layout_height="wrap_content"
        android:layout_width="wrap_content"
        android:layout_alignParentRight="true" 
        >
    </TextView>
</RelativeLayout>

and it works fine.. .except that the list_item_value text is obscured by the scrollbar. There's plenty of blank space between the names and values, scooting all the values to the left a little would be fine, but I don't know how to do that either.

try setting android:layout_marginRight on list_item_value . Try a value like 10dp or so - just to get a feel, then adjust accordingly.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM