[英]Where's my ImageViews?
我有一個水平LinearLayout
(在另一個LinearLayout
內),其中包含一些ImageView
。 出於某種原因,我只是在運行應用程序時沒有看到它們。
這是我的布局:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent" android:layout_height="fill_parent"
android:background="@drawable/background">
<TextView android:layout_height="wrap_content"
android:layout_width="wrap_content" android:textSize="20dp"
android:text="A bunch of text"
android:textColor="#000000" android:layout_gravity="center_horizontal"
android:padding="10dp" android:background="#0000FF"/>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_height="wrap_content" android:layout_width="fill_parent"
android:orientation="horizontal">
<ImageView android:layout_width="wrap_content"
android:layout_height="75dp"
android:src="@drawable/image1"
android:scaleType="centerCrop" android:background="#0000FF"/>
<ImageView android:layout_width="wrap_content" android:layout_height="75dp"
android:layout_weight="1" android:src="@drawable/image2"
android:scaleType="centerCrop" />
<ImageView android:layout_width="wrap_content" android:layout_height="75dp"
android:layout_weight="1" android:src="@drawable/image3"
android:scaleType="centerCrop" />
</LinearLayout>
</LinearLayout>
我認為您可以看到TextView
那么? LinearLayout
默認是水平的。 這可能是因為 Android 試圖將TextView
繪制到ImageView
的右側,而我猜你想要它們在它下面。 嘗試將android:orientation="vertical"
添加到外部LinearLayout
並從內部LinearLayout
中刪除android:orientation="horizontal"
(嗯,您不需要刪除它)。
嘗試將android:orientation
of your LinearLayout
更改為vertical
,它會解決問題,因為方向水平,它會惹惱屏幕上的圖像視圖
不知道你想如何布局你的視圖,你的代碼對我來說看起來不錯,至少那些圖像視圖應該顯示出來。 您確定您的圖像源( image1, image2.. )不只是一些與背景顏色相同的普通 colors 嗎?
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.