Frage

Hallo Freunde, ich habe mein Layout durch TabLayout innerhalb Linearlayout festgelegt, aber immer noch meine Taste am Ende nicht richtig eingestellt werden könnte, wie TabLayout alle Felder in der Anzahl der Spalten unterteilt, so kann jemand helfen, wie 2-Layouts setzen in einer XML-Datei Mittel alle Felder in TabLayout und beide Anmelden und Registrieren Tasten in Linear-Layout verbleibende Erz einige andere, so dass sie richtig eingestellt werden.

Vielen Dank im Voraus.

Layout

Benutzername! EditTextBox

Passwort! EditTextBox

Anmelden! Registrieren

Button! Taste

Ich möchte mein Layout in oben Format so i TabLaout verwendet haben, aber in diesem Fall ist es meine Taste verursacht Ansicht sowie es eine Taste als andere als EditText streckt größer als Textview

 <?xml version="1.0" encoding="utf-8"?>
    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:orientation="vertical"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        >
    <TextView
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:gravity="center_horizontal"
    android:textSize="26sp"
    android:text="@string/login_text"/>
    <TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:orientation="vertical"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
    >
    <TableRow>
    <TextView  
        android:layout_width="120px"  
        android:text="User name"
        />
    <EditText
        android:id="@+id/txtUserName"
        android:singleLine="true"
        android:maxLength="20"
        android:width="195px"
    />
    </TableRow>
    <TableRow>
    <TextView  
        android:layout_width="120px"  
        android:text="Password"
        />
    <EditText
        android:id="@+id/txtPassword"
        android:width="195px"
        android:maxLength="20"
        android:singleLine="true"
        android:password="true"
    />
    </TableRow>
    <TableRow>
            <TextView />
            <CheckBox android:id="@+id/chkRememberPassword"
                android:layout_width="fill_parent" 
                android:layout_height="wrap_content"
                android:text="Remember Password"
                />   
        </TableRow>
        <TableRow>
        <Button 
                android:id="@+id/buttonRegister" 
                android:text="Register" 
                android:layout_width="124px"
                android:layout_height="wrap_content"
                android:layout_below="@+id/chkRememberPassword"
                android:layout_alignRight="@+id/chkRememberPassword"
                />
        <Button 
            android:id="@+id/buttonSignIn" 
            android:text="Log In" 
            android:layout_width="124px"
            android:layout_height="wrap_content"
            android:layout_below="@+id/chkRememberPassword"
            android:layout_alignLeft="@+id/chkRememberPassword"
            />        
    </TableRow>

    <TextView  
    android:id="@+id/statusError"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
     />
    </TableLayout>
    </LinearLayout>
War es hilfreich?

Lösung

Ich schlage vor, Sie wrap_content in Tablelayout zu verwenden, und dann können Sie Ihre Tasten in Linearlayout haben

<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
>

Andere Tipps

Es ist nicht möglich, mehr als ein Layout in einer einzigen XML-Datei zu setzen ... Und aus dem gleichen Grunde Android hat das Layout, Layout-Landschaft usw. Ordnertyp System ..

Was Sie tun können, ist, wie durch 100rabh erklärt ... Machen Sie das Universal-Layout durch relative Layout und fill Elterneinstellungen anwenden ...

Ansonsten wie ich erklärt benötigen Sie 2 xml Layout-Dateien zu machen, und legen Sie das Layout für Landschaft in der Layout-Landschaft Ordner damit das jeweilige Layout wird automatisch entsprechend der Ausrichtung des Telefons eingestellt werden ...

Hope this helps u ...

Sie müssen zwei XML-Dateien erstellen:

  1. Ein im normalen layout Ordner
  2. Eine zweite in einem res/layout-land das Layout für das Querformat zu definieren. Sie müssen den res/layout-land Ordner erstellen, wenn es nicht bereits vorhanden ist.
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top