![](/img/trans.png)
[英]android studio Make a textView below an imageview visible if imageview has no image
[英]How to combine textview and imageview into image compound when imageview has width and height values in android?
嗨,这在我的XML文件中:
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<ImageView
android:id="@+id/picture_text"
android:layout_width="32dp"
android:layout_height="32dp"
android:layout_marginRight="10dp"
android:src="@drawable/text"/>
<TextView
android:id="@+id/textview_message"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/tap_message"
android:onClick="GoToMessage"
android:clickable="true"
style="@style/text_link"/>
</LinearLayout>
Android皮棉抱怨警告,提示应将其合并到textview复合中。 我可以做到,但是我不明白如何为imageview设置宽度,高度和边距...
谁能告诉我该怎么做?
谢谢
建议在textview中添加一个drawable,如下所示:
<TextView
android:id="@+id/title"
android:drawableLeft="@yourDrawable"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="yourText">
</TextView>
希望这可以帮助。
问候!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.