Android:如何创建特定的水平线性布局
我正在制作一个有自定义搜索栏的应用程序。我希望有一个大的搜索部分,一个小正方形的区域选择微调器,和一个小正方形的搜索按钮 这就是我要说的 我现在掌握的代码是:Android:如何创建特定的水平线性布局,android,android-layout,layout,Android,Android Layout,Layout,我正在制作一个有自定义搜索栏的应用程序。我希望有一个大的搜索部分,一个小正方形的区域选择微调器,和一个小正方形的搜索按钮 这就是我要说的 我现在掌握的代码是: <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:la
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent"
android:layout_height="match_parent" android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
android:paddingBottom="@dimen/activity_vertical_margin" tools:context=".MainActivity">
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
>
<EditText
android:hint="@string/summoner_name"
android:layout_width="wrap_content"
android:layout_weight="75"
android:layout_height="wrap_content"
android:id="@+id/summoner_name"/>
<Spinner
android:layout_weight="1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/regions">
</Spinner>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:id="@+id/search_button"/>
</LinearLayout>
然而,这使得搜索占据了屏幕的一半,2/5的按钮占据了屏幕,旋转器占据了较小的弹药量。有人知道如何做到这一点吗
谢谢:)将权重1赋予
EditText
android:layout\u weight=“1”
,并从其他组件上移除权重标签
此外,如果由于微调器的宽度部分,上述设置不起作用,您需要静态设置微调器宽度
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent"
android:layout_height="match_parent" android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
android:paddingBottom="@dimen/activity_vertical_margin" tools:context=".MainActivity"
android:orientation="vertical">
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<EditText
android:layout_width="wrap_content"
android:layout_weight="75"
android:layout_height="wrap_content"
android:id="@+id/summoner_name"/>
<Spinner
android:layout_weight="1"
android:layout_width="100dp"
android:layout_height="wrap_content"
android:id="@+id/regions"/>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:id="@+id/search_button"/>
</LinearLayout>
</LinearLayout>