gpt4 book ai didi

android - ImageView 未显示在 TableRow 上

转载 作者:行者123 更新时间:2023-11-29 21:44:49 25 4
gpt4 key购买 nike

我有以下代码在我的代码中创建表头。但是,由于某种原因,带有 ImageView 的列不显示任何内容。由于我固定了列的权重,而不是显示图像,因此这段代码只为列保留一个空白空间,但不显示任何内容。我怀疑我的 drawable 是它的起源,但如果我创建一个 TextView 并将其定义为 drawableTop、drawableBottom 或其他类型,它就会显示出来。

<TableLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="2dp"
android:layout_marginRight="2dp" >

<TableRow>

<TextView
android:layout_margin="1dp"
android:layout_weight="2"
android:background="#ffcccccc"
android:gravity="center"
android:text="@string/date_hour"
android:textSize="16sp"
android:textStyle="bold" />

<ImageView
android:layout_margin="1dp"
android:layout_weight=".75"
android:background="#ffcccccc"
android:gravity="center"
android:drawable="@drawable/road" />

<TextView
android:layout_margin="1dp"
android:layout_weight=".75"
android:background="#ffcccccc"
android:gravity="center"
android:text="@string/op"
android:textSize="16sp"
android:textStyle="bold" />

<TextView
android:layout_margin="1dp"
android:layout_weight="1"
android:background="#ffcccccc"
android:gravity="center"
android:text="@string/tag"
android:textSize="16sp"
android:textStyle="bold" />

<TextView
android:layout_margin="1dp"
android:layout_weight="2"
android:background="#ffcccccc"
android:gravity="center"
android:text="@string/status"
android:textSize="16sp"
android:textStyle="bold" />
</TableRow>
</TableLayout>

有人遇到同样的问题吗?

最佳答案

我猜你的imageview应该如下所示

<ImageView
android:layout_margin="1dp"
android:layout_weight=".75"
android:background="#ffcccccc"
android:gravity="center"
android:src="@drawable/road" />

尝试在您的代码中替换它。希望有用

关于android - ImageView 未显示在 TableRow 上,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16147139/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com