巴顿在LinearLayout中不显示巴顿、中不、LinearLayout

由网友(之前没有想到会这样)分享简介:我想以后的TextView 但它没有显示出来。I am trying to add a Button in a LinearLayout after a TextView but it is not showing up.下面是我的布局code Here is my layout code<?xml versi...

我想以后的TextView 但它没有显示出来。

I am trying to add a Button in a LinearLayout after a TextView but it is not showing up.

下面是我的布局code

Here is my layout code

<?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="45dip">

    <TextView android:layout_width="fill_parent"
        android:layout_height="45dip"
        android:paddingLeft="5dip"
        android:paddingRight="5dip"
        android:textStyle="bold"
        android:textSize="17dip"
        android:gravity="center_vertical"
        android:id="@+id/tvChild"
        android:text="Children"
        android:textColor="#ffCCCC22" />

    <Button android:id="@+id/submit"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:text="Submit" />
</LinearLayout>

的TextView 与正确的文本显示正常,但不是一个按钮我得到了一个很大的空白三到四线长度

The TextView is displayed correctly with proper text but instead of a Button I am getting a big blank space of three to four lines length.

我在想什么?

推荐答案

试试这个。

<?xml version="1.0" encoding="utf-8"?>
    <LinearLayout android:id="@+id/LinearLayout01"
        android:layout_width="fill_parent" android:layout_height="45dip"
        xmlns:android="http://schemas.android.com/apk/res/android">
        <TextView android:layout_width="wrap_content"
            android:layout_height="45dip" android:paddingLeft="5dip"
            android:paddingRight="5dip" android:textStyle="bold" android:textSize="17dip"
            android:gravity="center_vertical" android:id="@+id/tvChild"
            android:text="Children" android:textColor="#ffCCCC22"
            />
            <Button android:id="@+id/submit"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_alignParentBottom="true"
                android:text="Submit" />
    </LinearLayout>

使用机器人:layout_width =WRAP_CONTENT而不是 机器人:layout_width =FILL_PARENT的TextView 按钮