TextView填充点的问题

3

抱歉我的英语不好

我有一个RelativeLayout和两个文本视图,就像这样

<RelativeLayout
            android:layout_width="fill_parent"
            android:layout_weight="1"
            android:layout_height="wrap_content" >

            <TextView
                android:id="@+id/textView9"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_alignParentLeft="true"
                android:layout_alignParentTop="true"
                android:singleLine="true"
                android:textAppearance="?android:attr/textAppearanceMedium" />

            <TextView
                android:id="@+id/textView10"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_alignParentRight="true"
                android:layout_alignParentTop="true"
                android:singleLine="true"
                android:textAppearance="?android:attr/textAppearanceMedium" />

        </RelativeLayout>

我希望通过点号将两个元素分开,就像这样:

TextView9 ...................................... TextView10

其他更长的文本 ................................... 69

1个回答

1

没有Java代码:

drawable/dotted.xml:

<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="line">

    <stroke
       android:color="#C7B299"
       android:dashWidth="10px"
       android:dashGap="10px" />
</shape>

view.xml:

<View
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:background="@drawable/dotted" />

并且设置:

view.setLayerType(View.LAYER_TYPE_SOFTWARE, null);

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接