我想創建一個佈局(使用eclipse),我需要垂直對齊像TextView和Button這樣的各種控件。我試圖讓所有的小部件完全左對齊。即使我爲控件指定了相同的左邊距/填充,仍然可以在不同類型的控件之間看到1-2像素的差異。Android的UI部件垂直對齊問題
問題是窗口小部件的邊框(eclipse中的藍色矩形)與窗口小部件的內容/圖形之間的距離因部件(如TextView和Button)而異。
我可以通過爲TextView指定左填充或通過減少按鈕容器的左邊距來應用解決方法。但我正在尋找更清潔的解決方案。我無法找到任何控制小部件邊框和內容之間區別的屬性。 任何關於如何控制這種差距的指針?
快照顯示問題如下。下面是我用於此問題的佈局XML: -
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Hello World" />
<Button
android:id="@+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Dummy Button" />
</LinearLayout>
下面的圖像顯示了虛擬應用程序的快照。請注意「Hello World」TextView和「虛擬按鈕」的左側邊距之間的差異。
第二張圖片顯示了在Eclipse中選中時的按鈕小部件。藍色矩形指示小部件邊界/邊界。按鈕的邊框(藍色矩形)和內容(灰色矩形)之間的區別是否可以通過某些屬性控制?
粘貼到快照的鏈接,我將編輯問題以顯示它。 – Blundell
你現在有超過10分:) –
添加了圖像,謝謝你的分數:) –