xml - Android 布局文件中的所有小部件都需要 layout_width 和 layout_height 吗?

标签 xml android layout

我有一个由 LinearLayouts 组成的 ListView。每个内部都有一个 ImageView、TextView 和另一个水平放置的 ImageView:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="horizontal"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    >
            <ImageButton
                android:id="@+id/thumbnail"
                android:background="@color/white"
                android:paddingTop="10dip"
                android:paddingLeft="8dip"
                android:paddingBottom="10dip"
                />
            <TextView
                android:id="@+id/title"
                android:background="@color/white"
                android:textColor="@color/bntext"
                android:paddingTop="10dip"
                android:paddingLeft="8dip"
                />
            <ImageButton
                android:src="@drawable/green_arrow_small"
                android:background="@color/white"
                />
</LinearLayout>

最佳答案

是的。这应该会崩溃。

关于xml - Android 布局文件中的所有小部件都需要 layout_width 和 layout_height 吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2547900/

相关文章:

java - android 完成当前 Activity 导致应用关闭

CSS 布局固定宽度

PHP:调用未定义函数:simplexml_load_string()

java - 使用 viewPager 滚动所有布局

PHP SimpleXML、CodeIgniter 和 Apache 与 Suhosin

java - Jackson MixIn 将泛型类 JAXBElement<T> 替换为 getValue() 后面的 T

android - 如何在 Android 中制作垂直的 SeekBar?

Android FOCUS_MODE_CONTINUOUS_VIDEO 和捕获预览帧

HTML Nav 标签格式奇怪

Android自定义按钮布局