Android 线性布局元件尺寸。体重如何影响尺寸

Android 线性布局元件尺寸。体重如何影响尺寸,android,android-linearlayout,Android,Android Linearlayout,我需要为屏幕上的按钮设置相同的大小。这些按钮具有不同的内容(不同的长度)。我想让它看起来像照片上的第三行 我试过: <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/LinearLayout1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:la

我需要为屏幕上的按钮设置相同的大小。这些按钮具有不同的内容(不同的长度)。我想让它看起来像照片上的第三行

我试过:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/LinearLayout1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:orientation="horizontal" >

<Button
    android:id="@+id/button2"
    android:layout_width="0dp"
    android:layout_height="fill_parent"
    android:layout_weight="1"
    android:text="Button" />


<Button
    android:id="@+id/button1"
    android:layout_width="0dp"
    android:layout_height="fill_parent"
    android:layout_weight="1"
    android:text="B" />

但是我在屏幕中央有两个大小不同的小按钮。怎么了?
请举例说明。

尝试将LinearLayout部分中的宽度参数更改为

android:layout_width="fill_parent"

添加
android:weightsum=10
LinearLayout
并将您的部分划分为2,4,4。您还可以通过使用
快速查看
(eclipse左下角的小正方形)->
其他
->
属性
在Graphics.xml中构建它们时,按百分比(20%、40%、40%)对它们进行调整,并在开发时输入值。

谢谢,它可以工作,但前提是我加入像rahul wroteNice这样的LinearLayout android:layout\u width=“fill\u parent”。作为用户,如果您发现答案完全有用,您应该通过勾选或向上投票(如果部分有用)来接受。