2017-10-10 5 views
0

Ich habe eine Scrollview mit drei Ansicht Pager in einem Fragment Container.Ich möchte eine feste schwimmende Aktion Schaltfläche wie Gmail Posteingang unten rechts auf der Seite und nicht in der rechten unteren Ecke der scrollview.It sollte festgelegt werden, ob ich blättern oder nicht.Ich bin meiner Schublade Layout xml Posting michfeste Position Floating Action Button wie Gmail Android

<?xml version="1.0" encoding="utf-8"?> 
<android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android" 
xmlns:app="http://schemas.android.com/apk/res-auto" 
android:id="@+id/drawer_layout" 
xmlns:tools="http://schemas.android.com/tools" 
android:layout_width="match_parent" 
android:layout_height="match_parent" 
tools:context="com.example.efflorescence.settingneeds.HomeActivity"> 

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

    <View 
     android:layout_width="match_parent" 
     android:layout_height="1sp" 
     android:background="@android:color/white"/> 
    <include 
     android:id="@+id/toolbar" 
     layout="@layout/toolbar"/> 

    <!--fragment container--> 
    <FrameLayout 
     android:id="@+id/container" 
     android:visibility="gone" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent"> 

     </FrameLayout> 
    <!--Home Page Content put here--> 

    <ScrollView 
     android:id="@+id/svcontent" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:scrollbars="none" 
     android:background="@android:color/white" 
     android:layout_marginTop="0dp"> 

     <RelativeLayout 
      android:id="@+id/home_main_layout" 
      android:layout_width="match_parent" 
      android:layout_height="match_parent"> 


      <TextView 
       android:id="@+id/pro_req_heading" 
       android:layout_width="match_parent" 
       android:layout_height="50dp" 
       android:background="#2094c5" 
       android:textColor="@android:color/white" 
       android:gravity="center" 
       android:text="[ IMMEDIATE REQUIREMENT ]"/> 

       <RelativeLayout 
        android:id="@+id/product_req_container" 
        android:layout_width="match_parent" 
        android:layout_height="300dp" 
        android:layout_below="@+id/pro_req_heading" 
        android:layout_marginBottom="1dp"> 

        <android.support.v4.view.ViewPager 
          android:id="@+id/pager1" 
          android:layout_width="fill_parent" 
          android:layout_height="fill_parent" 
          android:layout_alignParentTop="true"/> 
       </RelativeLayout> 

      <TextView 
       android:id="@+id/pro_review_heading" 
       android:layout_marginTop="0dp" 
       android:layout_width="match_parent" 
       android:layout_below="@+id/product_req_container" 
       android:layout_height="50dp" 
       android:background="#2094c5" 
       android:textColor="@android:color/white" 
       android:gravity="center" 
       android:text="[ MOST REVIEW PRODUCTS ]"/> 

      <RelativeLayout 
       android:id="@+id/product_review_container" 
       android:layout_width="match_parent" 
       android:layout_height="300dp" 
       android:layout_below="@+id/pro_review_heading"> 

       <android.support.v4.view.ViewPager 
        android:id="@+id/pager2" 
        android:layout_width="fill_parent" 
        android:layout_height="fill_parent"/> 
      </RelativeLayout> 

      <TextView 
       android:id="@+id/pro_sale_heading" 
       android:layout_marginTop="0dp" 
       android:layout_width="match_parent" 
       android:layout_below="@+id/product_review_container" 
       android:layout_height="50dp" 
       android:background="#2094c5" 
       android:textColor="@android:color/white" 
       android:gravity="center" 
       android:text="[ MOST SALE PRODUCTS ]"/> 

      <RelativeLayout 
       android:id="@+id/product_sale_container" 
       android:layout_width="match_parent" 
       android:layout_height="300dp" 
       android:layout_alignParentBottom="true" 
       android:layout_below="@+id/pro_sale_heading"> 

       <android.support.v4.view.ViewPager 
        android:id="@+id/pager3" 
        android:layout_width="fill_parent" 
        android:layout_height="fill_parent" 
        android:layout_alignParentBottom="true"/> 

      </RelativeLayout> 


     </RelativeLayout> 
    </ScrollView> 

</LinearLayout> 

<fragment 
    android:id="@+id/nav_drwr_fragment" 
    android:layout_width="@dimen/nav_drawer_width" 
    android:layout_height="match_parent" 
    android:name="com.example.efflorescence.settingneeds.navigation.NavigationFragment" 
    android:layout_gravity="start" 
    tools:layout="@layout/fragment_navigation"/> 

Antwort

6

Sie benötigen CoordinatorLayout

main.xml verwenden file.please helfen

<?xml version="1.0" encoding="utf-8"?> 
<android.support.design.widget.CoordinatorLayout 
    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.c217.reddyteacherapp.baseActivity"> 

    <android.support.design.widget.AppBarLayout 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:theme="@style/AppTheme.AppBarOverlay"> 

     <android.support.v7.widget.Toolbar 
      android:id="@+id/toolbar" 
      android:layout_width="match_parent" 
      android:layout_height="?attr/actionBarSize" 
      android:background="?attr/colorPrimary" 
      app:popupTheme="@style/AppTheme.PopupOverlay" /> 

    </android.support.design.widget.AppBarLayout> 

    <include layout="@layout/content_base" /> 

    <android.support.design.widget.FloatingActionButton 
     android:id="@+id/fab" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_gravity="bottom|end" 
     android:layout_margin="@dimen/fab_margin" 
     app:srcCompat="@android:drawable/ic_dialog_email" /> 

</android.support.design.widget.CoordinatorLayout> 

und setzen alle anderen Komponente in content_base XML-Datei

Verwandte Themen