【问题标题】:list item ignoring set height, using wrap_content instead忽略设置高度的列表项,改用 wrap_content
【发布时间】:2011-09-18 03:09:12
【问题描述】:

我的列表项布局存在我无法理解的问题。我将列表项的高度设置为 70dp,但如果我只有总高度为 40dp 的内容,它将自动忽略我使用 android:layout_height 设置的值,而是使用似乎是 wrap_content 作为高度。

如果我在列表之外使用 exakt 相同的布局,它会按预期工作。

下面是我的一个列表中的一个列表项的布局。

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_height="70dip"
android:layout_width="fill_parent">

<TextView android:id="@+id/name"
    android:layout_height="wrap_content"
    android:layout_width="wrap_content"
    style="@style/NormalText"/>

<TextView android:id="@+id/description"
    android:layout_height="wrap_content"
    android:layout_width="wrap_content"
    style="@style/VerySmallLightText"/></LinearLayout>

编辑我的 xml 以更好地反映我的代码。我有一些样式属性,这就是为什么我在这里手动绑定时不小心打错了。

【问题讨论】:

    标签: android listview layout


    【解决方案1】:

    您是否尝试过线性布局的 layout_height 而不仅仅是高度?

    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_height="70dp"*
    android:layout_width="fill_parent">
    

    【讨论】:

    • 我错了,我当然有 layout_height 代码:9 更改我的帖子以反映这一点
    【解决方案2】:

    您的线性布局属性如下 android:height = '70dip' 是否可以通过 IDE 检查?

    【讨论】:

    • 更新了我发布的代码,只是我在这里写代码时打错了
    猜你喜欢
    • 1970-01-01
    • 2016-10-07
    • 2019-11-12
    • 1970-01-01
    • 1970-01-01
    • 2020-05-05
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多