【发布时间】:2016-03-01 08:21:51
【问题描述】:
我在 Android Studio 的列表视图中创建了一个表格视图(参见以下代码),出于各种原因,我使用了文本视图和复选框作为单独的元素,而不仅仅是使用复选框并附加文本。问题是文本位于屏幕/表格的左侧,但复选框基本上居中,因为我希望它位于最右侧。
<ScrollView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/title"
android:layout_above="@+id/Button1"
android:id="@+id/scrollView"
android:background="@drawable/list">
<TableLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TableRow
android:layout_width="fill_parent"
android:layout_height="match_parent">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text="@string/Maths"
android:id="@+id/Maths"
android:layout_column="1"
android:textColor="#ffffff" />
<CheckBox
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/MathsCheck"
android:layout_column="2"
android:buttonTint="#00ffff"
android:onClick="MathsClicked"/>
</TableRow>
<TableRow
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text="@string/History"
android:id="@+id/History"
android:layout_column="1"
android:textColor="#ffffff"/>
<CheckBox
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/HistoryCheck"
android:layout_column="2"
android:onClick="HistoryClicked"
android:buttonTint="#00ffff" />
</TableRow>
</TableLayout>
</ScrollView>
实际上有更多这样的文本视图和复选框,但你明白了。我尝试过使用填充和边距,但这并没有真正起作用,因为它在某些设备显示器上可以正常工作,但我必须对其进行硬编码,这并不理想。我还尝试了重力功能,由于某种原因似乎没有任何作用。
任何帮助表示赞赏
【问题讨论】: