我仍然没有解决方法如何在XML中做到这一点。我想将textview集中在一个桌面上的图像按钮上。
这应该是:
我的代码:
<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/tableLayout1"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:stretchColumns="1"
android:layout_below="@+id/button"
android:layout_marginTop="85dp">
<TableRow
android:id="@+id/tableRow1"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:paddingBottom="30dip" >
<ImageButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@null"
android:id="@+id/imageButton5"
android:src="@drawable/options_460"
android:layout_span="3"
android:layout_gravity="left"/>
</TableRow>
<TableRow
android:id="@+id/tableRow2"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:gravity="center_horizontal"
android:padding="0dip" >
<ImageButton
android:layout_height="wrap_content"
android:background="@null"
android:id="@+id/a"
android:src="@drawable/buttonsh"
android:layout_weight="1"
android:onClick="rasp"
android:tag="a"
android:layout_gravity="right"
/>
<ImageButton
android:layout_height="wrap_content"
android:background="@null"
android:id="@+id/b"
android:src="@drawable/buttonsh"
android:layout_weight="1"
android:onClick="rasp"
android:tag="b"
android:layout_gravity="left"/>
</TableRow>
............................................
</TableLayout>
有没有办法做到这一点?任何建议都会受到欢迎。 谢谢你的阅读。
答案 0 :(得分:0)
首先,没有必要采取表格视图,我们有简单的替代方案,你应该尝试下面...在这里你只需要设置一个背景9.pach在你的按钮并采取适当的相关组件的ID,您将完成任务。祝你好运
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="@android:color/darker_gray"
android:gravity="center"
android:paddingBottom="20dp"
android:paddingTop="20dp"
android:text="Middle center text" />
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:weightSum="2" >
<Button
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center"
android:text="left upper" />
<Button
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center"
android:text="right upper" />
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:weightSum="2" >
<Button
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center"
android:text="left bottom" />
<Button
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center"
android:text="right bottom" />
</LinearLayout>
</LinearLayout>