【发布时间】:2011-08-25 09:48:28
【问题描述】:
我正在设计布局,但遇到了问题。不知何故,它在我的表格布局右侧有一个空白空间,我无法填充它。如果有人有想法,请您帮帮我吗?
下面是我的布局 xml 和屏幕截图,以显示究竟发生了什么;顺便说一句,我使用 tablelayout 的原因是为了通过与用户的交互将一些项目放在那里。
提前谢谢你
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<LinearLayout android:id="@+id/header" android:layout_height="wrap_content" android:layout_width="match_parent">
<TextView android:id="@+id/header_life_title" android:textSize="20sp" android:text="Life: " android:layout_height="wrap_content" android:layout_width="wrap_content"></TextView>
<TextView android:id="@+id/header_life_value" android:textSize="20sp" android:text="20" android:layout_height="wrap_content" android:layout_width="wrap_content"></TextView>
<Button android:text="Inc." android:id="@+id/header_btn_inc" android:layout_width="wrap_content" android:layout_height="35dp" android:layout_gravity="center_vertical">
<Button android:text="Dec." android:id="@+id/header_btn_dec" android:layout_width="wrap_content" android:layout_height="35dp"></Button>
<Button android:text="Put L." android:id="@+id/header_btn_putLand" android:layout_width="wrap_content" android:layout_height="35dp"></Button>
<Button android:text="Remove L." android:id="@+id/header_btn_removeLand" android:layout_width="wrap_content" android:layout_height="35sp">
<LinearLayout android:layout_width="wrap_content" android:layout_height="match_parent" android:id="@+id/land_space">
</LinearLayout>
</LinearLayout>
<ScrollView android:id="@+id/scrollView1" android:layout_height="wrap_content" android:layout_width="match_parent">
<TableLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:id="@+id/cardboard">
<LinearLayout android:layout_height="40dp" android:layout_width="match_parent" android:id="@+id/layout_menu">
<Spinner android:id="@+id/spinner_creature" android:layout_height="wrap_content" android:layout_width="150dp"></Spinner>
<Button android:id="@+id/btn_creature" android:layout_height="wrap_content" android:layout_width="wrap_content" android:text="Cast"></Button>
<Spinner android:id="@+id/spinner_noncreature" android:layout_height="wrap_content" android:layout_width="wrap_content"></Spinner>
<Button android:id="@+id/btn_noncreature" android:layout_height="wrap_content" android:layout_width="wrap_content" android:text="Cast"></Button>
<Button android:id="@+id/btn_delete" android:layout_height="wrap_content" android:layout_width="wrap_content" android:text="Del."></Button>
</LinearLayout>
<TableRow android:layout_height="wrap_content" android:layout_width="wrap_content" android:id="@+id/tableRow_cardImage"><![enter image description here][1]/TableRow>
<TableRow android:layout_height="wrap_content" android:layout_width="wrap_content" android:id="@+id/tableRow_cardData"></TableRow>
<TableRow android:layout_height="wrap_content" android:layout_width="wrap_content" android:id="@+id/tableRow_cardImage2"></TableRow>
<TableRow android:layout_height="wrap_content" android:layout_width="wrap_content" android:id="@+id/tableRow_cardData2"></TableRow>
</TableLayout>
</ScrollView>
</LinearLayout>
@987654321@
【问题讨论】:
-
那个空间不是由LinearLayout而不是TableLayout造成的吗?
-
感谢您的评论,卡斯帕。如果可能,您能告诉我如何解决这个问题吗?
-
你试试 layout_width="fill_parent" 最后一个元素:Del.? (只是猜测)
-
第二行的按钮/微调器是否应该填充视图?
-
我认为只是其中一个,我会选择最小的一个,以防止在小屏幕或纵向模式下剪切文本。