1

我正在尝试在 Android 的布局中添加一个看起来像电影中的演职员表的人员列表:

Director ................................. John Doe
Producer ............................... John Smith
Camera ................................... Jane Doe
Screenplay ............................. Jane Smith

我希望点根据屏幕的宽度扩展(以便位置名称将对齐左侧和名称右侧)

有没有办法在布局 xml 中做到这一点?

4

3 回答 3

0

我会那样做 - 伪layout.xml:

<frame-layout>
 <text-view text="dots"/>
 <relative-layout>
   <textview align-parent-left="true" padding-right:="5dp" text="role"/>
   <textview align-parent-right="true" padding-left:="5dp" text="name/>
 </relative-layout>
</frame-layout>

这作为列表视图中的一行

于 2012-04-26T18:02:49.700 回答
0

您可以将整个布局设为垂直方向的 LinearLayout;每行都是一个水平方向的 LinearLayout,包含三个组件:

具有角色名称的 TextView,宽度为 WRAP_CONTENT

带有文本“......”的 TextView(很多点,足以满足所有屏幕),宽度 MATCH_PARENT 和 layout_weight 设置为 1.0

带有人名的 TextView,宽度为 WRAP_CONTENT。

于 2012-04-26T18:07:19.403 回答
0
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent" >

    <TextView
        android:id="@+id/textView1"
        android:layout_width="wrap_content"
     >> android:layout_height="20dp"
        android:layout_alignParentLeft="true"
        android:layout_alignParentTop="true"
        android:text="Small Text"
        android:textAppearance="?android:attr/textAppearanceSmall" />

    <TextView
        android:id="@+id/textView2"
        android:layout_width="fill_parent"
    >>  android:layout_height="20dp"
        android:layout_alignParentTop="true"
        android:layout_toRightOf="@+id/textView1"
        android:layout_toLeftOf="@+id/textView3"
        android:text=".........................................................................."
        android:textAppearance="?android:attr/textAppearanceSmall" />

    <TextView
        android:id="@+id/textView3"
        android:layout_width="wrap_content"
    >>  android:layout_height="20dp" // set as u want....
        android:layout_alignParentRight="true"
        android:layout_alignParentTop="true"
        android:text="Small Text"
        android:textAppearance="?android:attr/textAppearanceSmall" />

</RelativeLayout>
于 2012-04-26T18:08:33.277 回答