2016-11-21 4 views
0

Ich habe ein Layout, das wie folgt aussieht,-Taste, um unteren Teil des Bildschirms

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

    <ScrollView 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content"> 

     <LinearLayout 
      android:layout_width="match_parent" 
      android:layout_height="match_parent" 
      android:orientation="vertical"> 

      <include 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content" 
       layout="@layout/layout1" /> 

      <TextView 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content" 
       android:layout_weight="1"/> 

      <Button 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:text="button"/> 
     </LinearLayout> 
    </ScrollView> 
</LinearLayout> 

Ich möchte die Schaltfläche am unteren Rand des Bildschirms angezeigt werden, die, wenn sie mit einem activity.When verwenden funktioniert gut ich versuche, benutze es jedoch mit einem Fragment (in einem FrameLayout) wird der Button überhaupt nicht angezeigt. Irgendwelche Vorschläge?

EDIT

Vielen Dank für Ihre Antworten, aber ich habe bereits versucht alle that.Let mich klarstellen something.I ein Haupt Layout haben, die eine Toolbar und ein Framelayout .Dieses FrameLayout enthält für meine verwendet wird 4- 5 App's Fragments. Einer von ihnen hat das vorherige Layout ich gepostet.

+1

versuchen relativelayout verwenden. Legen Sie dann die Eigenschaft auf align_ParentBottom = true fest. Es wird am unteren Rand zeigen, egal was – Umair

+0

gehen durch diese http://stackoverflow.com/questions/3482742/gravity-and-layout-gravity-on-android/40080065#40080065 – sushildlh

+0

Hallo @ tasgr86 ist es zwingend FrameLayout zu verwenden. .? –

Antwort

0

versuchen zu nutzen:

android:layout_gravity="bottom" 

oder:

android:layout_alignParentBottom="true" 

im Botton-Tag.

0

Sie müssen gesetzt Eigenschaft für Scroll

android:fillViewport="true" 

und hinzufügen zu Button Linie

android:layout_alignParentBottom="true" 
android:layout_gravity="center_horizontal" 

Ich habe Ihren Code nur Edited versuchen, diese

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

<ScrollView 
    android:layout_width="match_parent" 
    android:fillViewport="true" 
    android:layout_height="match_parent"> 

    <LinearLayout 
     android:layout_width="match_parent" 
     android:orientation="vertical" 
     android:layout_height="match_parent"> 

     <include 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      layout="@layout/layout1" /> 

     <TextView 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:layout_weight="1"/> 

     <Button 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_alignParentBottom="true" 
      android:text="button" 
      android:layout_gravity="center_horizontal" /> 

    </LinearLayout> 
</ScrollView> 

0

Sie sollte hier ScrollView als Root-Layout als LinearLayout verwenden.

Und versuchen, diese Eigenschaft innerhalb Scrollview:

android:fillViewport="true" 

Kann sein, es wird Ihnen helfen.

1

Verwenden layout_weight

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

    <ScrollView 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:layout_weight="1"> 

     <LinearLayout 
      android:layout_width="match_parent" 
      android:layout_height="match_parent" 
      android:orientation="vertical"> 

      <include 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content" 
       layout="@layout/layout1" /> 

      <TextView 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content" 
       android:layout_weight="1" /> 

     </LinearLayout> 
    </ScrollView> 

    <Button 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:text="button" /> 

</LinearLayout> 
0

zu diesem Code tasgr86 versuchen hoffen, dass dies eine Vorstellung machen kann oder helfen ..

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

<ScrollView 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:layout_above="@+id/button"> 

    <LinearLayout 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:orientation="vertical"> 

     <include 
      layout="@layout/layout1" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" /> 

     <TextView 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:layout_weight="1" 
      android:text="Test" /> 

    </LinearLayout> 
</ScrollView> 

<Button 
    android:id="@+id/button" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:layout_alignParentBottom="true" 
    android:layout_marginBottom="5dp" 
    android:text="button" /> 

</RelativeLayout> 
Verwandte Themen