我在应用程序中设置这样一个布局:顶端一个按钮,第二个按钮在底端,第三个占整个中间的空间。运用的下面的代码,但是不显示第二个按钮。如何实现布局设计的结果呢?
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout android:id="@+id/LinearLayout01"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical">
<!--view=2-->
<Button
android:id="@+id/button2"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Save"
/>
<Button
android:id="@+id/button4"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:text="Previous"
/>
<Button
android:id="@+id/button5"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Next"
/>
</LinearLayout>
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/LinearLayout01"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:weightSum="1" >
<!-- view=2 -->
<Button
android:id="@+id/button2"
android:layout_width="fill_parent"
android:layout_height="0dp"
android:layout_weight=".1"
android:text="Save" />
<Button
android:id="@+id/button4"
android:layout_width="fill_parent"
android:layout_height="0dp"
android:layout_weight=".8"
android:text="Previous" />
<Button
android:id="@+id/button5"
android:layout_width="fill_parent"
android:layout_height="0dp"
android:layout_weight=".1"
android:text="Next" />
</LinearLayout>
第二个按钮设权重为1,其他两不设,还就第二个的高度不要设为fill_parent
<Button
android:id="@+id/button4"
android:layout_width="fill_parent"
android:layout_height="fill_parent" //问题在这里 改成 wrap_content 你就能看到你的按钮了
android:text="Previous"
/>