I am developing an android app where I have 3 buttons at the top of the screen and i have defined them using the layout_weight
property. The buttons adjust to all screen sizes including tablets but its text does not.
This is what it looks like on a nexus 5:
This is what it looks like on a nexus 10:
See the difference?
On the nexus 5, It is quite legible but on the nexus 10 you can hardly see anything!
Here is my 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>
So how do I get the button text size to adjust automatically on different screen sizes without having to make different layouts for different screen sizes?
Please help me out with the code as I am pretty much a beginner!
Thanks in advance!