大家好,我希望有一個佈局如下圖所示那裏是在TextView的右側ImageView的身影。如果圖像不存在,我希望文本顯示在整個屏幕上,如圖所示,我怎樣才能得到它。 對不起,我想說的是,我有一個自定義列表視圖,我只有一個textView和ImageView在適配器中。如果圖像不存在的同一字段我希望textview從左到右,以取代圖像視圖也。
-6
A
回答
1
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_gravity="right"
android:gravity="right">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Some Random Text for example ..........................................."
android:gravity="left"
android:layout_weight="5"/>
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="left"
android:src="@drawable/jayz"
android:layout_weight="1"/>
</LinearLayout>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Some Random text for example............................................."/>
</LinearLayout>
根據您的編輯。
將第一個textView的layout_width
更改爲match_parent
,就像我一樣。
從您的代碼調用imageView.setVisibility(View.GONE);
後,每當您的imageview應該是空的。
您的佈局會是這樣`
+0
事實上,我已經在發佈這個問題之前做了這個。你沒有得到我的問題。我編輯了我的問題,請再看一遍。我現在清楚還是仍然困惑。 – Shree
+0
看到我的編輯@Shree。 –
相關問題
- 1. 移動時Bootstrap背景圖像沒有填滿空間
- 2. JPQL左連接 - 在返回所有左行時過濾右列
- 3. 如何有一個控制填滿所有可用的空間
- 4. 動畫文字填充從左到右
- 5. 圖像沒有填滿整個頁面
- 6. NGINX將所有圖像請求路由到外部服務器
- 7. LINQ到EF返回所有列,而不是通過WHERE子句到服務器
- 8. CSS如何使的div填滿所有的垂直空間
- 9. 從左到右滾動文字效果
- 10. 圖像文件沒有保存到服務器「圖」文件夾
- 11. SQL - 如何從左表中返回沒有在右表中找到的行?
- 12. SQL加入到由左,右表中返回空行
- 13. Linux服務器,我沒有空間嗎?
- 14. SQL服務器:加入所有左表和重複右
- 15. 服務器沒有返回響應
- 16. Iphone反饋服務返回devicetoken沒有任何空間
- 17. 選取器沒有返回任何圖像,如果allowsEditing = NO
- 18. Glass Mapper沒有返回所有結果
- 19. 如果字段爲空或空白,則返回所有行
- 20. 如果沒有圖像,顯示文字?
- 21. WCF服務沒有返回值到jQuery
- 22. 通過NAT /路由器的服務器到服務器通信
- 23. 文字:從右到左(CSS)
- 24. LinearLayout從右到左填充
- 25. 通過web服務返回linq結果
- 26. 應用程序interace佈局方向從左到右從右到左的語言返回從左到右
- 27. 從服務器到所有沒有UDP的客戶端的Silverlight通知
- 28. Javascript上傳文件到頁面,沒有通過Web服務器
- 29. 的Webservice如果我有一個返回值圖像的web服務,返回的圖像加上一些
- 30. 從服務器通過凌空抽取圖像在android中
嘗試使用相對佈局 – SaravInfern
@Shree爲更好的UI我已提出建議,圖書館。 – Varma460