巴顿在LinearLayout中不显示 [英] Button not displaying in LinearLayout

查看:177
本文介绍了巴顿在LinearLayout中不显示的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想以后的TextView 按钮的LinearLayout code>但它没有显示出来。

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 按钮

这篇关于巴顿在LinearLayout中不显示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆