2016-12-08 16 views
0

Ich verwende diesen Code in meinem Fragmente Layout:Wie positioniert man LinearLayout mit ScrollView?

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:tools="http://schemas.android.com/tools" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    xmlns:app="http://schemas.android.com/apk/res-auto" 
    android:orientation="vertical" 
    tools:context="com.app.MainFragment"> 

    <android.support.v4.widget.NestedScrollView 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:fitsSystemWindows="true" 
     android:scrollbars="vertical" 
     android:scrollbarAlwaysDrawVerticalTrack="true" 
     app:layout_behavior="@string/appbar_scrolling_view_behavior"> 
    <LinearLayout 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:orientation="vertical" 
     android:background="@color/colorDivider"> 
     <android.support.v7.widget.RecyclerView 
      android:id="@+id/list" 
      android:layout_width="match_parent" 
      android:layout_height="500dp" 
      android:scrollbars="vertical" 
      app:layout_behavior="@string/appbar_scrolling_view_behavior" 
      /> 
    </LinearLayout> 
    </android.support.v4.widget.NestedScrollView> 


    <LinearLayout 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:layout_margin="10dp" 
     android:layout_alignParentBottom="true" 
     android:weightSum="2" 
     > 

     <EditText 
      android:id="@+id/edit_text" 
      android:layout_width="0dp" 
      android:layout_height="wrap_content" 
      android:layout_weight="1.91" 
      android:layout_marginLeft="10dp" 
      android:textColor="@color/colorPrimaryDark" 
      android:textColorHint="@color/colorPrimaryDark" 
      android:theme="@style/btmedtext" 
      android:textColorHighlight="@color/colorPrimary" 
      android:hint="Send message" 
      android:inputType="textMultiLine" 
      android:maxLines="6" 
      android:scrollbars="vertical"> 
     </EditText> 

     <android.support.design.widget.FloatingActionButton 
      android:id="@+id/button_send" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_alignParentRight="true" 
      android:layout_marginRight="3dp" 
      android:layout_marginLeft="10dp" 
      android:layout_marginBottom="16dp" 
      android:layout_gravity="bottom|end" 
      android:src="@drawable/ic_mic_white_24dp"/> 

    </LinearLayout> 

</RelativeLayout> 

Das Ergebnis ist:

enter image description here

Meine Frage ist: wie dieses schwimmende Linearlayout (EditText + FloatingActionButton) über die Recyclerview zu vermeiden ? Ich möchte diese LinearLayout am unteren Rand und wenn der EditText verwendet wird, sollte die ScrollView davon springen.

enter image description here

+0

Versuchen Hinzufügen der align_parentBottom = "true" oder layout_below = @ id/list –

+0

Leider funktioniert das nicht. Die Ansichten können nicht einmal miteinander angezeigt werden – GB11

Antwort

0

Leider, wenn eine schwebende Aktion Taste, so scheint es die einzige Wahl ist, um entweder die Taste ganz bewegen, blenden Sie die Taste oder Sie können einen leeren Behälter am Ende dynamisch hinzufügen, so dass der blockierten Inhalt zu bewegen oben.

Auschecken THIS Bibliothek. Sie könnten dies nutzen, wenn der bewegliche oder leere Behälter nicht in Frage kommt. Es erlaubt Ihnen, Ihren Knopf zu behalten und ihn bei Bedarf zu präsentieren.

Floating Action Button Hide Library

+0

Vielen Dank, ich werde diese Bibliothek anzeigen. Achte übrigens auf mein Update, um das Bild aus dem WhatsApp Chat zu sehen, genau das brauche ich. – GB11

0

Ich hoffe, das Ihr Problem

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
xmlns:tools="http://schemas.android.com/tools" 
android:layout_width="match_parent" 
android:layout_height="match_parent" 
xmlns:app="http://schemas.android.com/apk/res-auto" 
android:orientation="vertical" 
tools:context="com.app.MainFragment"> 


    <RelativeLayout 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:orientation="vertical" 
     android:background="@color/colorDivider"> 
     <android.support.v7.widget.RecyclerView 
      android:id="@+id/list" 
      android:layout_width="match_parent" 
      android:layout_height="match_parent" 
      android:scrollbars="vertical" 
      android:layout_above="@+id/editbox_laypou" 
      app:layout_behavior="@string/appbar_scrolling_view_behavior" /> 

     <LinearLayout 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:layout_margin="10dp" 
      android:layout_alignParentBottom="true" 
      android:weightSum="2" 
      android:id="@+id/editbox_laypou"> 

      <EditText 
       android:id="@+id/edit_text" 
       android:layout_width="0dp" 
       android:layout_height="wrap_content" 
       android:layout_weight="1.91" 
       android:layout_marginLeft="10dp" 
       android:textColor="@color/colorPrimaryDark" 
       android:textColorHint="@color/colorPrimaryDark" 
       android:textColorHighlight="@color/colorPrimary" 
       android:hint="Send message" 
       android:inputType="textMultiLine" 
       android:maxLines="6" 
       android:scrollbars="vertical"> 
      </EditText> 

      <android.support.design.widget.FloatingActionButton 
       android:id="@+id/button_send" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:layout_alignParentRight="true" 
       android:layout_marginRight="3dp" 
       android:layout_marginLeft="10dp" 
       android:layout_marginBottom="16dp" 
       android:layout_gravity="bottom|end" 
       android:src="@drawable/ic_mic_white_24dp"/> 

     </LinearLayout> 
    </RelativeLayout> 

0

fügen Sie diese lösen in Ihrem Manifest

android:windowSoftInputMode="adjustPan" 
Verwandte Themen