我會有數百個這樣的佈局(請參閱下圖),所以我需要以最有效的方式構建它。有三個區域,兩個第一個由底線對齊,左邊一個包含ImageView
,第二個包含兩個TextView
。第二個是TextView
。作爲容器使用TableLayout
,第二個使用LinearLayout
?它會有效嗎?謝謝。最有效的方法來構建佈局
1
A
回答
0
試試這個
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity" >
<ImageView
android:id="@+id/imageView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:layout_marginLeft="41dp"
android:layout_marginTop="39dp"
android:src="@drawable/ic_launcher" />
<LinearLayout
android:id="@+id/linearLayout1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_alignTop="@+id/imageView1"
android:layout_marginLeft="10dp"
android:layout_toRightOf="@+id/imageView1"
android:orientation="vertical" >
<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="TextView 1" />
<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="TextView 2" />
</LinearLayout>
<TextView
android:id="@+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/linearLayout1"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"
android:layout_below="@+id/imageView1"
android:text="TextView" />
+0
我不需要底部的TextView在ImageView下傳播 – Eugene
0
第一sugestion是讓ImageView的「高」,所以它涵蓋了高度都TextViews,或者使底部的TextView廣泛覆蓋的ImageView和TextView的上..
它看起來更好,我看來,這空的空間正在刺傷我的眼睛痛..
然後我會建議TableLayout,當然這種佈局在不同的文件中,這樣你們可以重複使用它與包括..;)
歡呼聲,希望這有助於
0
的RelativeLayout
在裏面你應該添加Image View
與AlignParentLeft="true"
和alignParenttop = "true"
然後添加第一TextView
爲ImageView的的RightOff
和第二個文本視圖將它添加到LayoutBottom
第一TextView
使用Relative Layouts
,他們被認爲是從Linear Layouts
更輕。
0
試試這個,它會exaclty給你,你已經在你的問題中描述的佈局:
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
>
<ImageView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:src="@drawable/img" />
<RelativeLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1">
<TextView
android:id="@+id/txt1"
android:layout_alignParentTop="true"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="textView1" />
<TextView
android:id="@+id/txt2"
android:layout_below="@+id/txt1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="textView1" />
</RelativeLayout>
</LinearLayout>
0
試試這個:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/bg_l_l"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:orientation="horizontal" >
<ImageView
android:id="@+id/imageView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/ic_launcher" />
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/bg_l_l"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical" >
<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="chintan"
android:textAppearance="?android:attr/textAppearanceMedium" />
<TextView
android:id="@+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="khetiya"
android:textAppearance="?android:attr/textAppearanceMedium" />
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/bg_l_l"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical" >
<TextView
android:id="@+id/textView3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="this is extra text and this will not spred under the imageview as you can see."
android:textAppearance="?android:attr/textAppearanceMedium" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
相關問題
- 1. 最有效的方法來做水平滑動佈局
- 2. Android佈局 - 最有效的方式來實現我之後
- 3. 什麼是最有效的方式來實現這種佈局
- 4. 創建有效的佈局
- 5. PHP - 爲此數組結構構建表的最有效方法
- 6. Javascript是創建流體佈局的有效方法嗎?
- 7. 最有效的方法來連接表
- 8. 最有效的方法來從PHP
- 9. 最有效的方法來修改xml
- 10. 最有效的方法來繪製silverlight
- 11. Mongodb - 構建我的數據庫的最有效方法?
- 12. 構建字符串的有效方法
- 13. 構建通用iOS應用程序的最有效方法
- 14. 從存儲數據構建鏈表的最有效方法?
- 15. 構建隨機排列列表的最有效方法
- 16. 構建我想要的簡單HTML佈局的最佳方式
- 17. 最有效的方法來創建報告編制日期
- 18. 有沒有更好的方式去使用ui.router來構建佈局?
- 19. 最有效的grep方法
- 20. 處理20多種不同靜態佈局的最有效方法是什麼?
- 21. 構建複雜的佈局
- 22. Android的佈局構建
- 23. 最有效的方法來獲得最後的初始?
- 24. 最有效的方法來找到最左邊的div?
- 25. 最有效的方法來找到最接近的整數?
- 26. 最有效的方法來使用懸停在圖像效果
- 27. 這是簡單的方法來創建佈局的Android
- 28. Android - 有沒有更好的方法來做這種佈局?
- 29. 創建大量新佈局的最佳方法
- 30. 最有效的方法來創建一個天真的文本總結算法
你想讓文字在圖像視圖下方傳播嗎? –
不,底部的TextView不應該散佈在圖像視圖下方。 – Eugene
@siik:查看我的回答下面 – Houcine