Android – add text to layout?
I have a horizontal small screen layout. I have some text in the textview in the layout... But it is not displayed. I do not define any text size font or set any size. However, the text of textview does not appear:
<LinearLayout android:layout_width="wrap_content"
android:id="@+id/text_container"
android:layout_height="wrap_content"
android:layout_above="@+id/relativeLayout"
android:layout_centerHorizontal="true"
android:layout_marginBottom="25dp">
<TextView
android:layout_width="match_parent"
android:text="20:00"
android:layout_height="match_parent"
/>
</LinearLayout>
However, textview is empty... This is an image showing the design layout screen:
Here you can see the text setting clearly:
Why didn't the text appear? This is very strange. I have tried many things, but the problem still exists. I have tried:
>Restart Android studio > refresh Design View > build – > clean project > build – > rebuild project
However, the problem still exists. Thank you for helping me complete this problem
Strangely, this only applies to layout landscapes. It works well in regular layout and small layout. This is the same code
resolvent:
I guess you missed textcolor. Just add it
android:textColor="#00FF00"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
reason
android:layout_marginBottom="25dp"
layout_ Marginbottom is the main culprit here. Your gadget doesn't have a size of 25dp. That's why there's a problem