Reputation: 23
I'm trying to insert a text field or button into a small layout bar but for some reason its not showing.
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#d1cbcb">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="50dp"
android:background="#767eca">
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:text = "Ankosh"
android:textColor="#ffffff"
android:textSize="20sp"></TextView>
</RelativeLayout>
</LinearLayout>
Upvotes: 0
Views: 39
Reputation: 3288
Change layout_height to wrap_content and if you want textview height 50dp then use that inside TextView
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#767eca">
<TextView
android:layout_width="match_parent"
android:layout_height="50dp"
android:text = "Ankosh"
android:textColor="#ffffff"
android:textSize="20sp"></TextView>
Upvotes: 0
Reputation: 1861
You have to change the height of the inner relative layout or mark it as wrap_content
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#d1cbcb">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#767eca">
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:text = "Ankosh"
android:textColor="#ffffff"
android:textSize="20sp"></TextView>
</RelativeLayout>
</LinearLayout>
Upvotes: 1