【发布时间】:2012-03-08 08:19:16
【问题描述】:
我正在尝试将按钮对齐到 TableRow 的右侧。在 TableRow 里面我有两个文本视图和一个按钮。显示按钮时,中间的 textview 是隐藏的。这是通过将 textview 可见性设置为消失在我的适配器内部完成的。
我不确定在按钮显示时将其向右对齐的最佳方法是什么。
这是我的布局文件:
<?xml version="1.0" encoding="UTF-8" ?>
<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/widget28"
android:stretchColumns="1"
android:layout_width="fill_parent"
android:layout_height="?android:attr/listPreferredItemHeight"
android:paddingLeft="10sp"
android:descendantFocusability="blocksDescendants"
>
<TableRow>
<TextView
android:id="@+id/textTopLeft"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium">
</TextView>
<TextView
android:id="@+id/textTopRight"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium">
</TextView>
</TableRow>
<TableRow>
<TextView
android:id="@+id/textBottomLeft"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceSmall">
</TextView>
<TextView
android:id="@+id/textBottomRight"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceSmall">
</TextView>
<Button
android:id="@+id/btnSessionResume"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Resume"
android:visibility="invisible"
android:layout_marginRight="20px"
android:layout_alignParentRight="true">
</Button>
</TableRow>
</TableLayout>
按钮在底部的 TableRow 中。
这是当前布局的截图:
【问题讨论】: