我正在尝试使用以下视图小部件组织我的视图 -
- TextView(应该填满屏幕的宽度并具有特定的高度)
- 使用 Draw() 绘制的自定义视图(填充宽度,应该在上面的 textview 之后开始并填充屏幕)
我正在尝试编写棋盘游戏,因此绘制了自定义视图。
我的问题是为此使用的最佳布局是什么?
我可以使用 TableLayout 并将这两个视图分别作为一列吗?我认为这可以解决问题,但我用于自定义视图的任何布局都不会填满屏幕,即使我正在绘制它的 tablerow 填满了屏幕。
我希望我能够正确地解释自己。非常感谢任何指针。
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/root_layout"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/tl_question"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:shrinkColumns="1"
android:stretchColumns="2">
<TableRow>
<TextView
android:id="@+id/question"
android:layout_width="wrap_content"
android:textSize="30sp"
android:textColor="#ffFFFFFF"
android:layout_gravity="center_vertical"
android:paddingBottom="9dip"
android:layout_marginLeft="3dip"
android:layout_marginRight="2dip"/>
</TableRow>
<TableRow>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_gravity="center_vertical" >
<com.ac.gui.CustomView
android:id="@+id/custom_board"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:keepScreenOn="true" />
</LinearLayout>
</TableRow>
</TableLayout>
</RelativeLayout>