我有5個按鈕,每個按鈕的寬度都不相同,因爲某些按鈕的文字比其他文字多。Android中的定位按鈕
我希望他們一致,但問題是,他們不適合在寬屏幕顯示爲小(在平板電腦看起來很完美,但在移動設備上不都不好看)
我如何能實現類似於下面的圖片?如果屏幕尺寸太小,那些不適合自動換行的按鈕,但是屏幕尺寸足夠大,可以使它們全部排成一行。
layout.xml
<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"
android:hardwareAccelerated="true"
tools:context=".MainActivity" >
<WebView
android:id="@+id/webView1"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_below="@+id/button3"
android:hardwareAccelerated="true" />
<ImageView
android:id="@+id/imageView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:src="@drawable/id_moduls" />
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="40dp"
android:orientation="horizontal" >
<Button
android:id="@+id/btnbmwx6"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:text="BMW X6" />
<Button
android:id="@+id/btnbmwz4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_toRightOf="@+id/btnbmwx6"
android:text="BMW Z4" />
<Button
android:id="@+id/btnbmw1s3d"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="BMW 1s 3-Doors" />
<Button
android:id="@+id/btnbmw6sgrancoupe"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="BMW 6s Gran Coupe" />
<Button
android:id="@+id/btnbmw5stouring"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="BMW 5s Touring" />
</LinearLayout>
</RelativeLayout>
我增加了佈局。 – 2013-04-29 19:54:31