我想在同一個佈局中顯示一個左對齊的ImageButton和一個TextView對齊的中心。但兩者都出現在中心或左側。我曾嘗試過LinearLayout和RelativeLayout。請給我解決方案。 非常感謝提前。在Android中對齊
0
A
回答
1
<?xml version="1.0" encoding="UTF-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_height="fill_parent"
android:layout_gravity="fill_horizontal" android:layout_width="fill_parent"
android:orientation="horizontal">
<TextView android:id="@+id/header_text1" android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="20sp" android:textStyle="bold" android:textColor="@color/white"
android:layout_marginLeft="70dp"
android:layout_centerHorizontal="true" android:layout_centerVertical="true"
android:singleLine="true" />
<ImageView android:src="@drawable/image_button1" android:id="@+id/back"
android:layout_width="wrap_content" android:layout_height="wrap_content"
android:layout_centerVertical="true" android:layout_toRightOf="@+id/header_text1" />
1
使用RelativeLayout併爲您的小部件(視圖元素)使用android:layout_align =「」參數。有相對於父視圖的對齊指令,但也有其他視圖元素。
+0
非常感謝你。 – Mudassir 2010-11-08 10:44:13
相關問題
- 1. 在Android中對齊
- 2. RadioGroup在Android中對齊
- 3. Android中的中心對齊
- 4. 在Android中對齊文字左右對齊
- 5. Android LinearLayout對齊
- 6. Android TableLayout對齊
- 7. Android:在TabHost中對齊中心圖像
- 8. 對齊左/中/右LinearLayout - Android
- 9. Android中的對齊問題
- 10. Android,textviews中的textviews對齊
- 11. Android對齊佈局中心
- 12. 在android中對齊佔位符問題
- 13. 在android中的對齊線性佈局
- 14. 在AlertView中對齊文本android
- 15. android:如何在alertDialog中對齊消息?
- 16. 如何在Android中對齊按鈕
- 17. 如何在android中對齊文本
- 18. 在Android TextView中對齊文本
- 19. 在Android textview中對齊文本
- 20. Android:在列表視圖中對齊textviews
- 21. 對齊問題在Android中的EditText
- 22. 在TextView中對齊文本Android
- 23. Android - ImageView在TableLayout中未正確對齊
- 24. 在android studio中的文字對齊
- 25. 如何在Android Webview中對齊文本?
- 26. 在Android Webview中對齊文本
- 27. Android相對佈局在對齊父對齊時添加邊距
- 28. Android右對齊TabWidget
- 29. 對齊道路Android
- 30. android sdk tablelayout對齊
感謝哥們。你的回答引導我朝着正確的方向前進。 :-) – Mudassir 2010-11-08 10:43:51
@Mudassir:你總是歡迎 – 2010-11-08 11:09:48