2016-04-05 4 views
-4

Ich möchte eine XML-Datei wie folgt erstellen:kann nicht mit Android XML-Datei ändern

enter image description here

Aber ich kann es nicht. Kann mir jemand sagen, warum das passiert? Wie mache ich ein Zentrum der Bearbeitungsbox?

Speziell Bearbeitungsfeld

enter image description here

Hier ist mein Code:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
      android:layout_width="fill_parent" 
      android:layout_height="fill_parent" > 

      <RelativeLayout 
       android:layout_width="fill_parent" 
       android:layout_height="fill_parent"> 

       <Button 
        android:id="@+id/button1" 
        android:layout_width="match_parent" 
        android:layout_height="wrap_content" 
        android:layout_weight="1" 
        android:text="Button1" 
        android:layout_marginTop="67dp" 
        android:layout_below="@+id/linearLayout" 
        android:layout_centerHorizontal="true" 
        android:background="#013567" /> 

       <LinearLayout 
        xmlns:android="http://schemas.android.com/apk/res/android" 
        android:orientation="vertical" 
        android:layout_width="match_parent" 
        android:layout_height="wrap_content" 
        android:padding="10dip" 
        android:gravity="center" 
        android:layout_marginTop="51dp" 
        android:id="@+id/linearLayout" 
        android:weightSum="1" 
        android:layout_below="@+id/textView4" 
        android:layout_alignParentLeft="true" 
        android:layout_alignParentStart="true"> 
        <!-- Email Label --> 
        <TextView 
         android:layout_width="wrap_content" 
         android:layout_height="wrap_content" 
         android:textAppearance="?android:attr/textAppearanceLarge" 
         android:text="Large Text" 
         android:id="@+id/textView" 
         android:layout_below="@+id/topBar" 
         android:layout_centerHorizontal="true" 
         android:textColor="#fe9900" 
         android:layout_weight="0.07" 
         android:layout_gravity="center_horizontal" /> 

        <EditText android:layout_width="268dp" 
         android:layout_height="match_parent" 
         android:layout_marginTop="5dip" 
         android:layout_marginBottom="20dip" 
         android:singleLine="true" 
         android:background="#ffffff" 
         android:hint="Enter Email Address" /> 
        <!-- Password Label --> 
        <EditText android:layout_width="274dp" 
         android:layout_height="fill_parent" 
         android:layout_marginTop="5dip" 
         android:singleLine="true" 
         android:password="true" 
         android:background="#ffffff" 
         android:hint="Password" /> 
        <!-- Login button --> 
        <Button android:id="@+id/btnLogin" 
         android:layout_width="wrap_content" 
         android:layout_height="wrap_content" 
         android:layout_marginTop="10dip" 
         android:text="Login" 
         android:background="#fe9900" 
         android:layout_gravity="center_horizontal" /> 

        <!-- Link to Registration Screen --> 

       </LinearLayout> 

       <LinearLayout 
        android:orientation="vertical" 
        android:layout_width="fill_parent" 
        android:layout_height="wrap_content" 
        android:layout_alignParentTop="true" 
        android:layout_alignParentLeft="true" 
        android:layout_alignParentStart="true" 
        android:layout_marginTop="45dp" 
        android:id="@+id/linearLayout2"> 


       </LinearLayout> 

       <TextView 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:textAppearance="?android:attr/textAppearanceMedium" 
        android:text="Medium Text" 
        android:id="@+id/textView2" 
        android:layout_alignParentBottom="true" 
        android:layout_alignParentLeft="true" 
        android:layout_alignParentStart="true" 
        android:layout_marginLeft="41dp" 
        android:layout_marginStart="41dp" 
        android:layout_marginBottom="38dp" /> 

       <TextView 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:textAppearance="?android:attr/textAppearanceMedium" 
        android:text="Medium Text" 
        android:id="@+id/textView3" 
        android:layout_alignBottom="@+id/textView2" 
        android:layout_toRightOf="@+id/textView2" 
        android:layout_toEndOf="@+id/textView2" 
        android:layout_marginLeft="31dp" 
        android:layout_marginStart="31dp" /> 

       <TextView 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:textAppearance="?android:attr/textAppearanceMedium" 
        android:text="Medium Text" 
        android:id="@+id/textView4" 
        android:layout_alignTop="@+id/linearLayout2" 
        android:layout_toLeftOf="@+id/textView3" 
        android:layout_toStartOf="@+id/textView3" /> 

       <TextView 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:textAppearance="?android:attr/textAppearanceMedium" 
        android:text="Medium Text" 
        android:id="@+id/textView5" 
        android:layout_alignTop="@+id/linearLayout2" 
        android:layout_alignLeft="@+id/textView3" 
        android:layout_alignStart="@+id/textView3" 
        android:layout_marginLeft="34dp" 
        android:layout_marginStart="34dp" /> 

      </RelativeLayout> 

     <Button 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:text="New Button" 
      android:id="@+id/button" 
      android:background="#013469" /> 



    </RelativeLayout> 

</RelativeLayout> 
+0

Ich sehe hier einige Probleme. ** 1 ** - 'fill_parent' wurde vor 6 Jahren eingestellt. Verwenden Sie stattdessen 'match_parent'. ** 2 ** - Sie verwenden viele verschachtelte Layouts, die Sie wirklich nicht benötigen und ** einen Einfluss auf die Leistung haben **. Ein einzelnes RelativeLayout ist, wenn es korrekt verwendet wird, alles was Sie brauchen. Und wird viel besser funktionieren. –

Antwort

0

hinzufügen android:gravity="center_horizontal" in EditText xml Sie zentrieren möchten, und entfernen Sie android:layout_centerHorizontal="true" aus der E-Mail-Textview. Sie sollten auch android:password="true" als veraltet entfernen. Nur ein kleiner Tipp, wenn eine Zeile von XML-Code gelb ist. Es gibt etwas, das vielleicht oder vielleicht ein Problem damit ist. Bewegen Sie den Mauszeiger darüber und sehen Sie eine Nachricht und klicken Sie auf die Glühbirne auf der linken Seite für weitere Optionen. So etwas wie das sollte funktionieren.

<!-- Email Label --> 
      <TextView 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:textAppearance="?android:attr/textAppearanceLarge" 
       android:text="Large Text" 
       android:id="@+id/textView" 
       android:layout_below="@+id/topBar" 
       android:textColor="#fe9900" 
       android:layout_weight="0.07" 
       android:layout_gravity="center_horizontal" /> 

      <EditText android:layout_width="268dp" 
       android:layout_height="match_parent" 
       android:layout_marginTop="5dip" 
       android:layout_marginBottom="20dip" 
       android:singleLine="true" 
       android:background="#ffffff" 
       android:gravity="center_horizontal" 
       android:hint="Enter Email Address" /> 
      <!-- Password Label --> 
      <EditText android:layout_width="274dp" 
       android:layout_height="fill_parent" 
       android:layout_marginTop="5dip" 
       android:singleLine="true" 
       android:password="true" 
       android:gravity="center_horizontal" 
       android:background="#ffffff" 
       android:hint="Password" /> 
Verwandte Themen