开发者

Is there an easy to use extensible layout?

I am trying to create a layout that extends to the whole screen if there is space.

Actually, I want to display information next to its title.

I found something that works, but I feel it is more a hack than a real solution.

<TableLayout android:layout_width="fill_parent"
    android:layout_height="wrap_content" android:id="@+id/resort_infos"
    android:stretchColumns="0">
    <TableRow android:background="#0b66ad" android:padding="3dip">
        <TextView android:i开发者_运维知识库d="@+id/openSlopesKmTitle"
            android:text="@string/slopes_km" android:textColor="#EEE" />
        <TextView android:id="@+id/slopes" android:layout_width="fill_parent"
            android:layout_height="wrap_content" android:gravity="right"
            android:textColor="#EEE" android:paddingRight="15dip" />
    </TableRow>
</TableLayout>

This allows me to extend the first column and let enough space for the second one. Is it the right way to do it?


The way to do it is using RelativeLayout, this way:

<RelativeLayout
    android:layout_width="fill_parent"
    android:layout_height="wrap_content">
    <TextView
        android:id="@+id/slopes"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentRight="true"
        android:textColor="#EEE"
        android:paddingRight="15dip" />
    <TextView
        android:id="@+id/openSlopesKmTitle"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_toLeftOf="@id/slopes"
        android:text="@string/slopes_km"
        android:textColor="#EEE"/>
</RelativeLayout>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜