2017-05-01 3 views
0

Helo,Warum werden die Schaltflächen im geteilten Layout nicht angezeigt?

mein Code:

<LinearLayout 
xmlns:android="http://schemas.android.com/apk/res/android" 
xmlns:app="http://schemas.android.com/apk/res-auto" 
android:layout_width="match_parent" 
android:layout_height="match_parent" 
android:orientation="vertical" 
android:layout_weight="1.0" 
> 

<LinearLayout 
    android:id="@+id/LinearLayout1" 
    android:layout_width="match_parent" 
    android:layout_height="0dp" 
    android:layout_weight="0.4" 
    android:padding="20sp" 
    android:orientation="vertical"> 

    <LinearLayout 
     android:layout_width="fill_parent" 
     android:layout_height="fill_parent" 
     android:background="@color/colorAccent" 
     android:orientation="vertical"> 

     <TableLayout 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:padding="3sp" 
      android:background="@color/colorAccent" 
      > 
      <TableRow 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content" 
       android:weightSum="1" 
       > 

       <TextView 
        android:id="@+id/textView32" 
        android:layout_width="0dp" 
        android:layout_height="wrap_content" 
        android:layout_weight="1" 
        android:gravity="center" 
        android:text="@string/accounts" 
        android:textAllCaps="false" 
        android:textSize="18sp" 
        android:textStyle="bold" /> 

      </TableRow> 
     </TableLayout> 

     <TableLayout 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:padding="10sp" 
      android:background="@color/colorAccent"> 
      <TableRow 
       android:layout_width="match_parent" 
       android:layout_height="match_parent"> 
       <TextView 
        android:id="@+id/textView_Account_Name" 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:text="@string/account" 
        android:textStyle="bold" 
        android:paddingRight="10sp" 
        /> 
       <TextView 
        android:id="@+id/textView_Account_Description" 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:text="@string/account_description" 
        android:textStyle="bold" 
        android:paddingRight="10sp" 
        /> 
       <TextView 
        android:id="@+id/textView_Account_Sum" 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:text="@string/account_sum" 
        android:textStyle="bold" 
        /> 

      </TableRow> 
     </TableLayout> 

     <!-- Scrollable Area 1 Begin --> 
     <ScrollView 
      android:layout_width="match_parent" 
      android:layout_height="match_parent" 
      android:scrollbars="none" 
      android:layout_weight="1" 
      android:fillViewport="true"> 
      <LinearLayout 
       android:layout_width="match_parent" 
       android:layout_height="match_parent" 
       android:orientation="vertical" 
       android:background="@color/colorAccent"> 
       <TableLayout 
        android:layout_width="match_parent" 
        android:layout_height="match_parent" 
        android:padding="10sp"> 
        <TableRow 
         android:layout_width="match_parent" 
         android:layout_height="match_parent"> 
        </TableRow> 
       </TableLayout> 
      </LinearLayout> 
     </ScrollView> 
     <!-- Scrollable Area 1 End --> 

     <LinearLayout 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:background="@color/colorAccent" 
      android:orientation="horizontal"> 

      <Button 
       android:id="@+id/button4" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:layout_weight="1" 
       android:text="Konto hinzufügen" /> 

      <Button 
       android:id="@+id/button3" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:layout_weight="1" 
       android:text="Konto löschen" /> 
     </LinearLayout> 
    </LinearLayout> 
</LinearLayout> 

<LinearLayout 
    android:id="@+id/scrollView2" 
    android:layout_width="match_parent" 
    android:layout_height="0dp" 
    android:layout_weight="0.6" 
    android:gravity="center|bottom" 
    android:paddingBottom="10sp" 
    android:paddingLeft="20sp" 
    android:paddingRight="20sp" 
    android:orientation="vertical"> 

    <LinearLayout 
     android:layout_width="fill_parent" 
     android:layout_height="fill_parent" 
     android:background="@color/colorAccent2" 
     android:orientation="vertical" 
     android:gravity="center|bottom"> 

     <TableLayout 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:background="@color/colorAccent2" 
      android:padding="3sp"> 

      <TableRow 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content" 
       android:weightSum="1"> 

       <TextView 
        android:id="@+id/textView6" 
        android:layout_width="0dp" 
        android:layout_height="wrap_content" 
        android:layout_weight="1" 
        android:gravity="center" 
        android:text="@string/account_input_output" 
        android:textAllCaps="false" 
        android:textSize="18sp" 
        android:textStyle="bold" /> 

      </TableRow> 
     </TableLayout> 

     <TableLayout 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:background="@color/colorAccent2" 
      android:padding="10sp"> 

      <TableRow 
       android:layout_width="match_parent" 
       android:layout_height="match_parent"> 

       <TextView 
        android:id="@+id/textView_IO_Date" 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:paddingRight="10sp" 
        android:text="@string/account_io_date" 
        android:textStyle="bold" /> 

       <TextView 
        android:id="@+id/textView_IO_Nr" 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:paddingRight="10sp" 
        android:text="@string/account_io_description" 
        android:textStyle="bold" /> 

       <TextView 
        android:id="@+id/textView_IO_Ausgabe" 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:paddingRight="10sp" 
        android:text="@string/account_io_ausgabe" 
        android:textStyle="bold" /> 

       <TextView 
        android:id="@+id/textView_IO_Eingabe" 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:paddingRight="10sp" 
        android:text="@string/account_io_eingabe" 
        android:textStyle="bold" /> 

       <TextView 
        android:id="@+id/textView_IO_Sum" 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:text="@string/account_sum" 
        android:textStyle="bold" /> 
      </TableRow> 
     </TableLayout> 


     <ScrollView 
      android:layout_width="match_parent" 
      android:layout_height="match_parent" 
      android:layout_weight="1" 
      android:fillViewport="true" 
      android:scrollbars="none"> 

      <LinearLayout 
       android:layout_width="match_parent" 
       android:layout_height="match_parent" 
       android:background="@color/colorAccent2" 
       android:orientation="vertical"> 

       <TableLayout 
        android:layout_width="match_parent" 
        android:layout_height="match_parent" 
        android:padding="10sp"> 

        <TableRow 
         android:layout_width="match_parent" 
         android:layout_height="match_parent"> 

        </TableRow> 
       </TableLayout> 
      </LinearLayout> 
     </ScrollView> 


     <LinearLayout 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:background="@color/colorAccent2" 
      android:orientation="horizontal"> 

      <Button 
       android:id="@+id/button6" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:layout_weight="1" 
       android:text="Transaktion hinzufügen" 

       /> 

      <Button 
       android:id="@+id/button7" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:layout_weight="1" 
       android:text="Transaktion löschen" /> 
     </LinearLayout> 
    </LinearLayout> 
</LinearLayout> 

Mein Problem ist:

Die beiden Tasten Button6 und button7 unten nicht auf dem Bildschirm angezeigt werden. Auf Android Studio sind sie, aber nicht auf meinem Handy.

Was mache ich falsch?

This is displayed in android studio gui builder

This is display on android emulator or real device

+0

im Layout-Editor, stellen Sie sicher, dass Sie ein ähnliches Gerät auf die einzustellen Sie verwenden auf, um eine Vorschau. Es wird um die Inkonsistenz kümmern. – C0D3LIC1OU5

+0

@ C0D3LIC1OU5: Hmm. Ich habe versucht, das auf Nexus 5x virtuelles Gerät aber dasselbe Problem zu ändern – ubik

Antwort

0

Hmm ... Ich weiß nicht, ob es die beste Lösung ist.

Aber ich den Boden Polsterung des zweiten linearen Layout:

20sp + 20 sp + black stripe on the bottom sp + 20 sp 

Context context = rootView.getContext(); 
Resources resources = context.getResources(); 
int resourceId = resources.getIdentifier("navigation_bar_height", "dimen", "android"); 
int width = resources.getDimensionPixelSize(resourceId); 

LinearLayout l = (LinearLayout)rootView.findViewById(R.id.scrollView2); 

float density = context.getResources().getDisplayMetrics().density; 
int paddingDp = (int)(20 * density); 

l.setPadding(paddingDp, 0, paddingDp, paddingDp + paddingDp + width); 
Verwandte Themen