2017-09-13 2 views
-9

Ich bin Debütant in Android und ich möchte eine Schnittstelle wie diese bekommen, aber ich konnte nicht meine Linearlayout SchnittstelleWie kann ich diese Schnittstelle bekommen?

enter image description here

Ich habe versucht, eine horizontale und eine vertikale Linearlayout platzieren zu verwenden, aber es funktioniert nicht Arbeit

<LinearLayout 
       android:orientation="horizontal" 
       android:layout_width="match_parent" 
       android:layout_height="match_parent" 
       android:gravity="center_horizontal" 
       android:layout_alignParentTop="true" 
       android:layout_alignParentLeft="true" 
       android:layout_alignParentStart="true"><TextView 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:textSize="22sp" 
        android:layout_marginRight="10dp" 
        android:layout_marginEnd="10dp" 
        android:id="@+id/txt1" 
        android:text="AAAAAAAA"/><Button 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:text="BE" 
        android:id="@+id/button1"/></LinearLayout> 
     <LinearLayout 
        android:orientation="vertical" 
        android:layout_width="match_parent" 
        android:layout_height="match_parent" 
        android:layout_alignParentTop="true" 
        android:layout_alignParentLeft="true" 
        android:layout_alignParentStart="true" 
        android:gravity="bottom"> 
    <TextView 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:textSize="22sp" 
        android:layout_marginRight="10dp" 
        android:layout_marginEnd="10dp" 
        android:id="@+id/txt2" 
        android:text="RRRRRRR"/><LinearLayout 
        android:orientation="horizontal" 
        android:layout_width="match_parent" 
        android:layout_height="match_parent" 
        android:layout_alignParentTop="true" 
        android:layout_alignParentLeft="true" 
        android:layout_alignParentStart="true"> 
     <TextView android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:textSize="22sp" 
        android:layout_marginRight="10dp" 
        android:layout_marginEnd="10dp" 
        android:id="@+id/txt3" 
        android:text="JJJJJJJJJJ"/> 
     <Button android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:text="GO" 
        android:id="@+id/button2"/> 
     </LinearLayout> 
     <Button android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:text="Start" 
        android:id="@+id/button3"/> 
     </LinearLayout> 

Können Sie mir helfen, diesen Code zu korrigieren?

+1

Ich glaube, Sie auf Ihre Schnittstelle als UI beziehen sollten, weil das erste, was ein Mitarbeiter mit Schnittstelle das Konstrukt Programmiersprache ist. – xvlcw

+0

Sie müssen verschiedene Layouts üben und entwerfen und ihre Eigenschaften verwenden und die Änderungen sehen. Für Anfänger braucht es Zeit, aber wir alle waren Anfänger vor ein paar Jahren. – Kunu

Antwort

0

Versuchen Sie diesen code.Hope das hilft Ihnen.

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:gravity="center_horizontal" 
    android:orientation="vertical"> 

<LinearLayout 
    android:layout_width="match_parent" 
    android:layout_height="0dp" 
    android:layout_weight="0.7" 
    android:gravity="center_horizontal"> 

    <TextView 
     android:id="@+id/txt1" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_marginEnd="10dp" 
     android:layout_marginRight="10dp" 
     android:text="AAAAAAAA" 
     android:textSize="22sp" /> 

    <Button 
     android:id="@+id/button1" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:text="BE" /> 
</LinearLayout> 


<LinearLayout 
    android:layout_width="match_parent" 
    android:layout_height="0dp" 
    android:layout_weight="0.2" 
    android:gravity="center_horizontal" 
    android:orientation="vertical"> 

    <TextView 
     android:id="@+id/txt2" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_marginEnd="10dp" 
     android:layout_marginRight="10dp" 
     android:layout_gravity="center_horizontal" 
     android:text="RRRRRRR" 
     android:textSize="22sp" /> 

    <LinearLayout 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:gravity="center_horizontal" 
     android:orientation="horizontal"> 

     <TextView 
      android:id="@+id/txt3" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_marginEnd="10dp" 
      android:layout_marginRight="10dp" 
      android:text="JJJJJJJJJJ" 
      android:textSize="22sp" /> 

     <Button 
      android:id="@+id/button2" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:text="GO" /> 

    </LinearLayout> 

    <Button 
     android:id="@+id/button3" 
     android:layout_width="wrap_content" 
     android:layout_height="0dp" 
     android:layout_weight="0.2" 
     android:layout_gravity="center_horizontal" 
     android:text="Start" /> 
</LinearLayout> 

0

können Sie diese Verwendung versuchen RelativeLayout

<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:orientation="vertical"> 


    <TextView 
     android:id="@+id/txt1" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:layout_alignParentTop="true" 
     android:layout_marginEnd="10dp" 
     android:layout_marginRight="10dp" 
     android:gravity="center" 
     android:text="AAAAAAAA" 
     android:textSize="22sp" /> 

    <TextView 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:layout_above="@+id/myl1" 
     android:gravity="center" 
     android:text="123465" /> 

    <LinearLayout 
     android:id="@id/myl1" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:layout_above="@+id/button3" 
     android:orientation="horizontal"> 

     <TextView 
      android:layout_width="0dp" 
      android:layout_height="wrap_content" 
      android:layout_weight="1" 
      android:gravity="center" 
      android:text="123465" /> 

     <Button 
      android:layout_width="0dp" 
      android:layout_height="wrap_content" 
      android:layout_alignParentBottom="true" 
      android:layout_weight="1" 
      android:text="Start" /> 

    </LinearLayout> 

    <Button 
     android:id="@+id/button3" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:layout_alignParentBottom="true" 
     android:text="Start" /> 
</RelativeLayout> 
Verwandte Themen