Android布局权重问题
朋友们 我已经写了下面的布局代码和按钮,以显示在屏幕上的平等,但它似乎不工作,任何人指导我,我在做什么错误Android布局权重问题,android,layout,Android,Layout,朋友们 我已经写了下面的布局代码和按钮,以显示在屏幕上的平等,但它似乎不工作,任何人指导我,我在做什么错误 ![<?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent
![<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<LinearLayout
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:background="@color/color_panel_background"
>
<ImageButton
android:layout_height="wrap_content"
android:id="@+id/currentLocation"
android:layout_weight="1"
android:layout_width="fill_parent"
android:src="@drawable/current_location_icon"
/>
<ImageButton
android:layout_height="wrap_content"
android:id="@+id/searchCity"
android:layout_weight="1"
android:layout_width="fill_parent"
android:src="@drawable/search_icon"
/>
<ImageButton
android:layout_height="wrap_content"
android:id="@+id/home"
android:layout_weight="1"
android:layout_width="fill_parent"
android:src="@drawable/home_icon"
/>
</LinearLayout>
</RelativeLayout>][2]
![
][2]
如果希望中间按钮具有相同的高度,请将android:layout\u height从“wrap\u content”
更改为某个常量。中间按钮的可绘制高度明显大于其他两个按钮。使用wrap_内容设置按钮的高度,使中间的按钮变大。体重与此无关。它仅定义当您使用fill\u parent时项目占用的空间。
解决此问题的最简单方法是将布局高度更改为固定值(使用dp作为单位)
或者改变你的可画物品的大小,使图片一开始都是相同的大小
感谢你问问题的方式。截图和相关代码。希望每个人都能这样做:)将线性布局高度更改为某个恒定的高度
更改线性布局中的对象布局高度,以在水平方向上填充父视图:如果为子视图设置权重,则设置为=0dp 在垂直方向:如果为子视图设置了权重,则将高度设置为0dp