2016-04-15 6 views
0

Ich versuche, ein Textfeld oder eine Schaltfläche in eine kleine Layoutleiste einzufügen, aber aus irgendeinem Grund wird es nicht angezeigt.Versuchen Sie, einem kleinen Layout ein Textfeld hinzuzufügen?

<?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> 
+0

was genau zeigt nicht? –

+0

Warum relativesLayout nach Hintergrund? Wenn die Textansicht im Inneren enthalten ist, müssen Sie nicht ... – Opiatefuchs

+0

Orientierung bereitstellen - vertikal oder horizontal zum linearen Layout. Wenn Sie textview eine Höhe zuweisen möchten, ist es besser, sie textview als das übergeordnete Layout zur Verfügung zu stellen. – Ankita

Antwort

1

Sie haben die Höhe des inneren relativen Layout zu verändern oder als 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> 
+1

Überprüfen Sie diese Antwort. –

0

ändern layout_height markieren wrap_content und wenn Sie Textview Höhe wollen 50dp dann verwenden, dass im Inneren 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> 

Verwandte Themen