【问题标题】:Android cannot get TextViews to display with LinearLayoutAndroid 无法让 TextViews 与 LinearLayout 一起显示
【发布时间】:2010-11-05 17:07:52
【问题描述】:

我只是想创建一个布局,其中有多个 TextViews(最终是一个 EditText)在活动中垂直堆叠。但是,唯一显示的是我的顶部标题栏和第一个 TextView(带有“名称”文本)。为什么没有其他东西出现?这是我的代码:

<?xml version="1.0" encoding="utf-8"?>

<LinearLayout android:orientation="vertical"
    android:layout_width="fill_parent" android:layout_height="fill_parent"
    android:layout_weight="1">

    <TextView android:text="Name:" android:layout_width="fill_parent"
        android:layout_height="fill_parent" android:textColor="#4096cc"
        android:paddingTop="15dip" android:paddingLeft="15dip"
        android:textSize="20sp" />

    <TextView
        android:text="This is my little description."
        android:layout_width="wrap_content" android:layout_height="fill_parent"
        android:textColor="#333333" android:paddingTop="10dip"
        android:paddingLeft="15dip" android:textSize="10sp" />

    <EditText android:layout_width="fill_parent"
        android:layout_height="wrap_content" />

</LinearLayout>

谢谢!

【问题讨论】:

    标签: java android text layout view


    【解决方案1】:

    TextView 的 layout_height 必须是 wrap_content,而不是 fill_parent。

    【讨论】:

    • 没问题!布局可能很棘手。但你会习惯的!
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-01-05
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多