'Android: text doesn't appear in Button widget
I am trying to create a Linear Layout with 3 Buttons arranged horizontally. Each button has a text and an image. It looks like this in Android studio:
But in my emulator, it looks like this on small devices:
As you can see, the text is not visible. Here is my code:
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:orientation="horizontal">
<Button
android:id="@+id/lightingButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="17dp"
android:layout_weight="1"
android:backgroundTint="#82B2C6"
android:drawableTop="@drawable/lighting"
android:padding="10dp"
android:text="Lighting"
android:textAllCaps="false"
android:textColor="@color/black" />
<Button
android:id="@+id/plantButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="17dp"
android:layout_weight="1"
android:backgroundTint="#82B2C6"
android:drawableTop="@drawable/plant"
android:padding="10dp"
android:text="Decoration"
android:textAllCaps="false"
android:textColor="@color/black"
android:textSize="13.2sp" />
<Button
android:id="@+id/bedButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="20dp"
android:layout_weight="1"
android:backgroundTint="#82B2C6"
android:drawableTop="@drawable/bed"
android:drawablePadding="-15sp"
android:padding="10dp"
android:text="Bedroom"
android:textAllCaps="false"
android:textColor="@color/black" />
</LinearLayout>
Solution 1:[1]
I checked your layout. Just add this attribute
android:gravity="bottom"
in your Button.
If not solved. let me know.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 |


