我試圖插入一個文本字段或按鈕到一個小的佈局欄,但由於某種原因它沒有顯示。試圖將文本字段添加到小布局?
<?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>
什麼不顯示? –
爲什麼在背景後關閉relativeLayout?如果textview應該放在裏面,那麼不需要... – Opiatefuchs
提供方向 - 垂直或水平到線性佈局。 如果你想爲textview指定一些高度,最好將它提供給textview本身,而不是父級佈局。 – Ankita