use*_*404 2 android android-layout
在一个相当复杂的布局中,我需要连续4个SeekBars和一个Button.空间比例应为7:1.
布局树看起来像这样:
<LinearLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<TableLayout
android:layout_weight="7"
android:layout_width="0dp"
android:layout_height="match_parent" >
<TableRow
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<SeekBar
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</TableRow>
<!--- 3 more SeekBar, one table row each -->
</TableLayout>
<TableLayout
android:layout_weight="1"
android:layout_width="0dp"
android:layout_height="match_parent" >
<TableRow
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<Button
android:layout_weight="1"
android:layout_width="0dp"
android:layout_height="match_parent"
android:text="O_" />
</TableRow>
</TableLayout>
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)
很抱歉,如果该代码看起来很乱,但我希望你得到基本的想法,因为我认为这个问题只是一个简单的编辑值.
正如您在图片中看到的那样,布局边界被正确地绘制到按钮上,但SeekBars只是保持很小.

非常感谢您的帮助,我希望我能够充分描述这个问题.
添加以下内容seekbar,它应该工作正常
android:layout_weight="1"
这是我测试和工作正常的完整代码
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TableLayout
android:layout_weight="7"
android:layout_width="0dp"
android:layout_height="match_parent">
<TableRow
android:layout_width="match_parent"
android:layout_height="wrap_content">
<SeekBar
android:layout_width="match_parent"
android:layout_weight="1"
android:layout_height="wrap_content" />
</TableRow>
<!--- 3 more SeekBar, one table row each -->
</TableLayout>
<TableLayout
android:layout_weight="1"
android:layout_width="0dp"
android:layout_height="match_parent">
<TableRow
android:layout_width="match_parent"
android:layout_height="wrap_content">
<Button
android:layout_weight="1"
android:layout_width="0dp"
android:layout_height="match_parent"
android:text="O_" />
</TableRow>
</TableLayout>
</LinearLayout>
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
903 次 |
| 最近记录: |