Я пытаюсь организовать свое представление со следующими виджетами вида -
Я пытаюсь написать настольную игру, и, следовательно, пользовательский вид нарисован.
Моя проблема в том, что лучше всего подходит для этого?
Можно ли использовать TableLayout и иметь эти два представления как по одному столбцу? Я думал, что это будет трюк, но какой-либо макет, который я использую для пользовательского вида, просто не заполняет экран, даже несмотря на то, что заголовок, который я рисую, заполняет экран.
Надеюсь, я смог правильно объяснить себя. Любые указатели приветствуются.
<?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>
Попробуйте использовать
<?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">
<TextView
android:id="@+id/question"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textSize="30sp"
android:text="ASDFASDF"
android:textColor="#ffFFFFFF"
android:layout_gravity="center_vertical"
android:paddingBottom="9dip"
android:layout_marginLeft="3dip"
android:layout_marginRight="2dip"/>
<com.ac.gui.CustomView
android:layout_below="@+id/question"
android:layout_width="fill_parent"
android:layout_height="fill_parent" />
</RelativeLayout>
Я тестировал другой макет вместо вашего, и он отлично работает. Он также должен работать с вашим.
RelativeLayout позволяет вам позиционировать позиции, ну, относительно друг друга. Вы увидите атрибут "layout_below" в своем пользовательском представлении, где я укажу идентификатор представления, чтобы поместить его.