Android layout 如何正确显示搜索栏?(布局和重量)
我正在尝试创建以下布局:Android layout 如何正确显示搜索栏?(布局和重量),android-layout,Android Layout,我正在尝试创建以下布局: 我想将80%的父布局分配给textView1和textView2,尽可能多地包装SeekBar,剩余的可用空间分配给textView3 我试图: 使用布局权重属性(分别为-4、4、1、1),但使用最后一个 视图与搜索栏重叠 仅对textView1和textView2使用布局权重,将SeekBar的高度设置为“wrap_content”,并为最后一个视图设置“match_parent” 现在我没有更多的想法了。你曾经遇到过这样的问题吗?要创建此布局,我会尝试:
我想将80%的父布局分配给textView1和textView2,尽可能多地包装SeekBar,剩余的可用空间分配给textView3
我试图:
- 使用布局权重属性(分别为-4、4、1、1),但使用最后一个 视图与搜索栏重叠
- 仅对textView1和textView2使用布局权重,将SeekBar的高度设置为“wrap_content”,并为最后一个视图设置“match_parent”
现在我没有更多的想法了。你曾经遇到过这样的问题吗?要创建此布局,我会尝试:
更改重量以调整尺寸。
让搜索栏包装内容,在其他视图上赋予权重
告诉我这是否有用。太好了!非常感谢。它工作得很好。但是你能告诉我为什么它有效吗?SeekBar的空间是否首先确定(因为它没有分配任何权重)?然后剩下的就按重量分了?
<?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:id="@+id/textView1"
android:layout_width="match_parent"
android:layout_height="match_parent" >
</TextView>
<TextView
android:id="@+id/textView2"
android:layout_width="match_parent"
android:layout_height="match_parent" >
</TextView>
<SeekBar
android:id="@+id/seekbar"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<TextView
android:id="@+id/textView3"
android:layout_width="match_parent"
android:layout_height="wrap_content" >
</TextView>
</LinearLayout>
<TextView
android:id="@+id/textView1"
android:layout_width="match_parent"
android:layout_height="0dip"
android:layout_weight="4" >
</TextView>
<TextView
android:id="@+id/textView2"
android:layout_width="match_parent"
android:layout_height="0dip"
android:layout_weight="4" >
</TextView>
<SeekBar
android:id="@+id/seekbar"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<TextView
android:id="@+id/textView3"
android:layout_width="match_parent"
android:layout_height="0dip"
android:layout_weight="1">
</TextView>