0

Ich baue ein Layout mit Bildlaufansicht und in der Bildlaufansicht gibt es ein relatives Layout. Ich möchte die FloatingActionButton auf der unteren Mitte des Layouts platzieren, aber ich weiß nicht, was passiert.Scrollansicht mit Relative Layout

Das ist mein Layout:

enter image description here

hier unter meinem Code:

<?xml version="1.0" encoding="utf-8"?> 
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:app="http://schemas.android.com/apk/res-auto" 
    xmlns:tools="http://schemas.android.com/tools" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    tools:context="com.example.mani.fakecall.MainActivity"> 

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

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

      <ImageButton 
       android:id="@+id/display_image" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:layout_gravity="center_horizontal" 
       android:background="@drawable/circular_image_button" 
       android:src="@drawable/ic_add_white_24dp" /> 

      <EditText 
       android:id="@+id/display_number" 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content" 
       android:layout_marginTop="16dp" 
       android:hint="@string/enter_number" 
       android:inputType="number" /> 

      <EditText 
       android:id="@+id/display_name" 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content" 
       android:layout_marginTop="16dp" 
       android:hint="@string/enter_name" 
       android:inputType="textCapWords" /> 

      <Button 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:layout_gravity="center_horizontal" 
       android:layout_marginTop="16dp" 
       android:elevation="8dp" 
       android:text="@string/set_time" /> 

     </LinearLayout> 

     <android.support.design.widget.FloatingActionButton 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_alignParentBottom="true" 
      android:layout_centerHorizontal="true" 
      android:layout_margin="16dp" 
      android:clickable="true" 
      android:elevation="12dp" 
      android:src="@drawable/ic_call_white_24dp" 
      app:backgroundTint="@color/colorFab" 
      app:elevation="0dp" /> 

    </RelativeLayout> 

</ScrollView> 

Antwort

0

wird Ihre Hierarchie wie diese

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
xmlns:app="http://schemas.android.com/apk/res-auto" 
xmlns:tools="http://schemas.android.com/tools" 
android:layout_width="match_parent" 
android:layout_height="match_parent" 
tools:context="com.example.mani.fakecall.MainActivity"> 

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

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

     <ImageButton 
      android:id="@+id/display_image" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_gravity="center_horizontal" 
      android:background="@drawable/circular_image_button" 
      android:src="@drawable/ic_add_white_24dp" /> 

     <EditText 
      android:id="@+id/display_number" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:layout_marginTop="16dp" 
      android:hint="@string/enter_number" 
      android:inputType="number" /> 

     <EditText 
      android:id="@+id/display_name" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:layout_marginTop="16dp" 
      android:hint="@string/enter_name" 
      android:inputType="textCapWords" /> 

     <Button 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_gravity="center_horizontal" 
      android:layout_marginTop="16dp" 
      android:elevation="8dp" 
      android:text="@string/set_time" /> 

    </LinearLayout> 


</ScrollView> 


<android.support.design.widget.FloatingActionButton 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_alignParentBottom="true" 
    android:layout_centerHorizontal="true" 
    android:layout_margin="16dp" 
    android:clickable="true" 
    android:elevation="12dp" 
    android:src="@drawable/ic_add" 
    app:backgroundTint="@color/colorAccent" 
    app:elevation="0dp" /> 

</RelativeLayout> 

+0

Ich habe versucht, bearbeitet Ihre wa y aber jetzt bewegt sich der 'FloatingActionButton' unnötigerweise. – mani

+0

senden Sie Ihren Code hier –

+0

Stellen Sie sicher, Ihre Eltern ist RelativeLayout, nicht Scrollview –

Verwandte Themen