我正在開發一款android應用程序,其中屏幕頂部有3個按鈕,我使用layout_weight
屬性定義了它們。這些按鈕適用於包括平板電腦在內的所有屏幕尺寸,但其文字不適用Android - 所有屏幕尺寸的按鈕文本大小
這是它看起來像一個關係5:
這是它看起來像一個關係10:
見區別?
在nexus 5上,它很清晰,但在nexus 10上幾乎看不到任何東西!
這裏是我的XML:
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_gravity="center_vertical"
android:layout_weight="1"
android:background="#000000"
android:orientation="horizontal"
android:weightSum="3" >
<Button
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:text="Button 1"
android:layout_weight="1"
android:id="@+id/button" />
<Button
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:text="Button 2"
android:layout_weight="1"
android:id="@+id/button2" />
<Button
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:text="Button 3"
android:layout_weight="1"
android:id="@+id/button3" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_gravity="center_vertical"
android:background="#000000"
android:layout_weight="1"
android:orientation="horizontal"
android:weightSum="3" >
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_gravity="center_vertical"
android:layout_weight="1"
android:background="#000000"
android:orientation="horizontal"
android:weightSum="3" >
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_gravity="center_vertical"
android:layout_weight="1"
android:background="#000000"
android:orientation="horizontal"
android:weightSum="3" >
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_gravity="center_vertical"
android:layout_weight="1"
android:background="#000000"
android:orientation="horizontal"
android:weightSum="3" >
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_gravity="center_vertical"
android:layout_weight="1"
android:background="#000000"
android:orientation="horizontal"
android:weightSum="3" >
</LinearLayout>
那麼,如何讓按鈕上的文字大小在不同的屏幕大小自動調節,而無需進行不同的佈局爲不同的屏幕尺寸?
請幫助我與代碼,因爲我幾乎是一個初學者!
在此先感謝!
[文本大小和不同的android屏幕大小](http:// stackoverflow。com/questions/9877946/text-size-and-different-android-screen-sizes) – StarsSky
@StarsSky我想避免製作不同的文件夾,並尋找解決方案來製作支持所有屏幕尺寸的單一佈局。如果您有解決方案,請幫助我。謝謝! –
不同的佈局文件夾已被引入,以滿足您的要求 – StarsSky