Skip to content Skip to sidebar Skip to footer

Android Button Layout With Big Text Size

I'm trying to make two identical buttons with the same height, but when the text is too long (the second button) then breaks markup. How can I fix it? xml layout:

Solution 1:

Add android:singleLine="true"

<LinearLayout
    android:layout_height="wrap_content"
    android:layout_width="match_parent">

    <Button
        android:singleLine="true"

        android:text="test"
        android:layout_height="100dp"
        android:layout_width="0dp"
        android:layout_weight="1"/>

    <Button
        android:singleLine="true"
        android:padding="0dp"
        android:text="Arterial tension disturbance"
        android:layout_height="100dp"
        android:layout_width="0dp"
        android:layout_weight="1"/>

    </LinearLayout>


Solution 2:

use wrap_content instead of 0dp

    <Button
        android:padding="0dp"
        android:text="Arterial tension disturbance"
        android:layout_height="100dp"
        android:layout_width="wrap_content"
        android:layout_weight="1"/>

Solution 3:

You can try this: (Edited)

<LinearLayout
       android:layout_width="fill_parent"
       android:layout_height="fill_parent"
       android:orientation="vertical"
       android:weightSum="100" >


       <Button
          android:layout_width="fill_parent"
          android:text="yourText"
          android:layout_height="wrap_content"
          android:layout_weight="50" />

      <Button
          android:layout_width="fill_parent"
          android:text="yourText"
          android:layout_height="wrap_content"
          android:layout_weight="50" />


Post a Comment for "Android Button Layout With Big Text Size"