這是我目前的佈局。如何讓文本視圖比我的佈局中的按鈕佔用更多空間?
而且我目前的佈局代碼
<?xml version="1.0" encoding="utf-8"?>
<TableRow xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@android:color/transparent" >
<TextView
android:id="@+id/stockView"
android:text="TextView"
android:layout_weight="1" />
<Button
android:id="@+id/stockQuote"
style="?android:attr/buttonStyleSmall"
android:text="@string/get_stock_quote"
android:layout_weight="1" />
<Button
android:id="@+id/webStock"
style="?android:attr/buttonStyleSmall"
android:text="@string/go_to_website"
android:layout_weight="1" />
</TableRow>
一切工作了罰款,我的理由是,因爲我給每個元素的「1」 layout_width,它們佔用的空間相同數量在表格行中。不過,我希望文本視圖佔用比按鈕更多的空間,所以我將文本視圖的layout_weight更改爲2,以便在每個按鈕佔用1/4按鈕時佔用額外空間的一半。我做了這個改變之後,這就是我的佈局。
有沒有人明白爲什麼會發生這種情況?文本視圖現在甚至不可見。我該如何解決這個問題,讓文本視圖佔用更多的空間?
當你說「layout_ * width *」時,你的意思是「layout_ * weight *」嗎? – aij 2014-09-25 20:13:12
你可以將'TableRow'的'weightSum'設置爲'4',然後使用你想要的值'(2,1,1)'。您還可以使用'layout_weight'的浮點值來獲取更精確的大小關係。 – nem035 2014-09-25 20:14:30
之前的重量總和是多少?這是僅與TableRows? – committedandroider 2014-09-25 21:38:42