看起來像關於居中,相同的大小等有很多問題,但到目前爲止我沒有找到確切的我的情況,所以我敢問:)LinearLayout文本包裝問題,當有兩個相同大小的按鈕加上一個在中心延伸
我需要的是三個按鈕像這樣的佈局:
[ previous ][*select*] [ next ]
其中[上一頁]和[下一步]按鈕是相同大小(即在此的情況下,尺寸爲[上一個]按鈕,因爲它更大),並且[* select *]按鈕應拉伸以佔據所有可用寬度。
繼LinearLayout中同樣大小製作兩個按鈕的提示,我想出了下面的XML文件:
<LinearLayout
android:id="@+id/button_bar"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:orientation="horizontal" >
<Button
android:layout_width="0dip"
android:layout_height="fill_parent"
android:layout_weight="1"
android:text="Previous" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="2"
android:text="Select" />
<Button
android:layout_width="0dip"
android:layout_height="fill_parent"
android:layout_weight="1"
android:text="Next" />
</LinearLayout>
這幾乎作品:) 除了一兩件事:反而讓下一頁按鈕大小匹配上一頁按鈕,android製作上一頁按鈕的大小爲下一頁 :) 因爲這個文本「上一頁」被包裹在兩行,像
Previ
ous
說不上來,如果這是一個錯誤或沒有,但你可以指點我解決方法或一些其他的方式才達到所需的佈局?
謝謝!
啊,我也試圖爲按鈕指定textview的「android:singleLine = true」屬性 - 它沒有幫助 – dimsuz 2010-08-20 10:53:41
有類似問題的帖子 http://stackoverflow.com/questions/1177020/android-how -to-化妝所有元素 - 內 - linearla yout-same-size – DeRagan 2010-08-20 11:15:44
是的,我用這個帖子來製作我的xml。但事情是,雖然它有些作品,我有一個問題與包裝文本(請參閱我的問題的結束部分) – dimsuz 2010-08-20 11:33:45