Android layout 线性布局中的第二个按钮不显示
我有一个Android活动的布局,其中第二个按钮没有显示:Android layout 线性布局中的第二个按钮不显示,android-layout,Android Layout,我有一个Android活动的布局,其中第二个按钮没有显示: <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_pare
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#659EC7"
android:weightSum="4"
>
<LinearLayout android:layout_height="0dp" android:layout_weight="1" android:layout_width="fill_parent" android:id="@+id/linearLayout3">
<TextView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:text="Top Text"
android:textSize="30dip"
android:gravity="center"></TextView>
</LinearLayout>
<LinearLayout android:layout_height="0dp" android:layout_weight="3" android:layout_width="fill_parent" android:id="@+id/linearLayout7" android:weightSum="4">
<Button
android:id="@+id/Button1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Button1"
android:onClick="onButton1Click" />
<Button
android:id="@+id/Button2"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Button2"
android:onClick="onButton2Click"
/>
</LinearLayout>
在包含两个按钮的线性布局中放置android:orientation=“vertical”在包含两个按钮的线性布局中放置android:orientation=“vertical”,非常好,谢谢!自从我是一名web应用程序/db开发人员以来,我一直在研究html/css之类的布局,并发现它们之间的差异。这对我也有帮助-你能告诉我为什么有必要吗?默认情况下,方向是“水平”的。第二个按钮未显示,因为第一个按钮的宽度设置为“fill_parent”,它占用了所有可用空间,因此迫使第二个按钮超出范围。如果我们将方向设置为“垂直”,则不会显示此问题。这非常有效,谢谢!自从我是一名web应用程序/db开发人员以来,我一直在研究html/css之类的布局,并发现它们之间的差异。这对我也有帮助-你能告诉我为什么有必要吗?默认情况下,方向是“水平”的。第二个按钮未显示,因为第一个按钮的宽度设置为“fill_parent”,它占用了所有可用空间,因此迫使第二个按钮超出范围。如果我们将方向设置为“垂直”,则不会显示此问题。