2012-03-30 12 views
2

ich mit Layout wie Code in unter xmlIch kann nicht unten zeigt Linearlayout-Ansicht scrollen

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
android:layout_width="fill_parent" 
android:layout_height="fill_parent" 
android:background="@drawable/background" 
android:orientation="vertical" > 

<RelativeLayout 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:background="@drawable/title" > 
</RelativeLayout> 

<ScrollView 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:scrollbars="none"> 

    <RelativeLayout 
     android:id="@+id/rel2" 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" > 

     <Button 
      android:id="@+id/button1" 
      android:layout_width="250dp" 
      android:layout_height="50dp" 
      android:layout_centerHorizontal="true" 
      android:layout_marginTop="10dp" 
      android:background="@drawable/bkg_gold_btn" 
      android:text="Button 1" /> 

     /*--------------------------------*/ 
     /* there are 12 more Buttons Here */ 
     /*--------------------------------*/ 
     <Button 
      android:id="@+id/button10" 
      android:layout_width="250dp" 
      android:layout_height="50dp" 
      android:layout_below="@+id/button9" 
      android:layout_centerHorizontal="true" 
      android:layout_marginBottom="10dp" 
      android:layout_marginTop="5dp" 
      android:background="@drawable/bkg_gold_btn" 
      android:text="Button 14" /> 
    </RelativeLayout> 
</ScrollView> 

    <LinearLayout 
     android:id="@+id/add_layer" 
     android:layout_width="fill_parent" 
     android:layout_height="50dip" 
     > 
    </LinearLayout> 

</LinearLayout> 

arbeitete Aber wenn ich den Code ausführen kann ich nicht auf Linearlayout unten sehen. bitte hilf mir.

+0

Versuchen Sie, ein Element _inside_ das letzte 'Linear Layout' hinzuzufügen, um zu überprüfen, ob es wirklich angezeigt wird. Sie werden es wahrscheinlich nicht in der UI-Laufzeit sehen können, da es nur ein Layout und kein UI-Element ist. – Ghost

+0

Wie wirst du es sehen, wenn es keine Kinder hat ..? – ngesh

Antwort

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

<RelativeLayout 
android:id="@+id/reltop" 
android:layout_width="fill_parent" 
android:layout_height="wrap_content" 
android:layout_alignParentTop="true" 
android:background="@drawable/title" > 
</RelativeLayout> 

<ScrollView 
android:layout_below="@id/reltop" 
android:layout_above="@id/add_layer" 
android:layout_width="fill_parent" 
android:layout_height="wrap_content" 
android:scrollbars="none"> 

<RelativeLayout 
    android:id="@+id/rel2" 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" > 

    <Button 
     android:id="@+id/button1" 
     android:layout_width="250dp" 
     android:layout_height="50dp" 
     android:layout_centerHorizontal="true" 
     android:layout_marginTop="10dp" 
     android:background="@drawable/bkg_gold_btn" 
     android:text="Button 1" /> 

    /*--------------------------------*/ 
    /* there are 12 more Buttons Here */ 
    /*--------------------------------*/ 
    <Button 
     android:id="@+id/button10" 
     android:layout_width="250dp" 
     android:layout_height="50dp" 
     android:layout_below="@+id/button9" 
     android:layout_centerHorizontal="true" 
     android:layout_marginBottom="10dp" 
     android:layout_marginTop="5dp" 
     android:background="@drawable/bkg_gold_btn" 
     android:text="Button 14" /> 
</RelativeLayout> 
</ScrollView> 

<LinearLayout 
    android:id="@+id/add_layer" 
    android:layout_width="fill_parent" 
    android:layout_alignParentBottom="true" 
    android:layout_height="50dip" 
    > 
</LinearLayout> 

</RelativeLayout> 
1

Fügen Sie android:gravity="bottom" android:layout_gravity="bottom" in LinearLayout hinzu und versuchen Sie, Komponenten in LinearLayout hinzuzufügen.

oder ersetzen, dass lineare Layout durch relative Layout wie folgt aus:

<RelativeLayout 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:gravity="bottom" > 

     <Button 
      ... /> 
    </RelativeLayout> 
0

Sie können die untere Linearlayout auf den Boden des RelativeLayout (id/rel2) bewegen, dann werden Sie es

2

Sie sehen Ich kann dieses LinearLayout nicht sehen, Parent LinearLayout ist nicht scrollbar und Scrollview deckt den gesamten Bildschirm ab. Um diese Situation zu lösen, haben Sie zwei Möglichkeiten: entweder die Höhe von ScrollView auf einen festen Teil des Bildschirms mit Gewichtung oder Pixeln zu fixieren. Oder RelativeLayout als Eltern von LinearLayout und Scrollview haben. Legen Sie LinearLayout am unteren Rand des übergeordneten Elements und die Bildlaufansicht über LinearLayout fest.

1

The Bottom Linearlayout ist für Sie nicht sichtbar, möglicherweise wegen der Scroll den verbleibenden Platz des Bildschirms nimmt, ist darin, dass n Zahlen von Taste zu zeigen, weil du es Höhe wrap_content gab.

Sie können weightSum attribut von LinearLayout verwenden, um zu definieren, wie viel Bildschirmbereich von der Ansicht abgedeckt wird.

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
android:layout_width="fill_parent" 
android:layout_height="fill_parent" 
android:weightSum="10" 
android:background="@drawable/background" 
android:orientation="vertical" > 

<RelativeLayout 
    android:layout_width="fill_parent" 
    android:layout_weight="1" 
    android:layout_height="0dp" 
    android:background="@drawable/title" > 
</RelativeLayout> 

<ScrollView 
    android:layout_width="fill_parent" 
    android:layout_weight="8" 
    android:layout_height="0dp" 
    android:scrollbars="none"> 

    <RelativeLayout 
     android:id="@+id/rel2" 
     android:layout_width="fill_parent" 
     android:layout_height="fill_parent" > 

    </RelativeLayout> 
</ScrollView> 

    <LinearLayout 
     android:id="@+id/add_layer" 
     android:layout_width="fill_parent" 
     android:layout_weight="1" 
     android:layout_height="0dp" 
     > 
    </LinearLayout> 

</LinearLayout> 
Verwandte Themen