In my application I want use NestedScrollView into DrawerLayout.
And for this I write below code.
I want show FAB in bottom of layout, but show me below of card!
I don't want show in below of card, I want show bottom of layout!
Please see below image to understand what I mean:
My codes:
<android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:ads="http://schemas.android.com/apk/res-auto"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="#+id/toNightDrawerLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
tools:openDrawer="end">
<android.support.v4.widget.NestedScrollView
android:layout_width="match_parent"
android:layout_height="match_parent">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<RelativeLayout
android:id="#+id/reviewSerialFrag_newsCommentsLay"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:visibility="visible">
<android.support.v7.widget.CardView
android:id="#+id/reviewSerialFrag_newsCommentsCard"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="#dimen/padding8"
ads:cardBackgroundColor="#android:color/white"
ads:cardElevation="#dimen/size2"
app:contentPadding="#dimen/padding8">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<RelativeLayout
android:id="#+id/reviewSerialFrag_newsCommentsHeaderLay"
android:layout_width="match_parent"
android:layout_height="#dimen/size50">
<ImageView
android:id="#+id/reviewSerialFrag_newsCommentsHeaderImage"
android:layout_width="#dimen/size35"
android:layout_height="#dimen/size35"
android:layout_centerVertical="true"
android:alpha="0.8"
android:src="#drawable/ic_comments"
android:tint="#color/darkBlueGrey" />
<TextView
android:id="#+id/reviewSerialFrag_newsCommentsUserTypeText"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_margin="#dimen/padding10"
android:layout_toRightOf="#+id/reviewSerialFrag_newsCommentsHeaderImage"
android:fontFamily="sans-serif-light"
android:gravity="center_vertical"
android:textColor="#color/darkBlueGrey"
android:textSize="#dimen/font16" />
<TextView
android:id="#+id/reviewSerialFrag_newsCommentsReviewTypeText"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_margin="#dimen/padding10"
android:layout_toRightOf="#+id/reviewSerialFrag_newsCommentsUserTypeText"
android:fontFamily="sans-serif-light"
android:gravity="center_vertical"
android:textColor="#color/darkBlueGrey"
android:textSize="#dimen/font14" />
</RelativeLayout>
<android.support.v7.widget.RecyclerView
android:id="#+id/reviewSerialFrag_newsCommentsRecyclerView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/reviewSerialFrag_newsCommentsHeaderLay"
android:layout_marginTop="#dimen/padding5" />
</RelativeLayout>
</android.support.v7.widget.CardView>
</RelativeLayout>
<!--EmptyList-->
<RelativeLayout
android:id="#+id/reviewSerialFrag_EmptyLsy"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:visibility="gone">
<include layout="#layout/empty_list" />
</RelativeLayout>
<android.support.design.widget.FloatingActionButton
android:id="#+id/reviewSerialFrag_FilterBtn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"
android:layout_margin="#dimen/padding15"
android:src="#drawable/ic_filter"
app:fabSize="normal" />
</RelativeLayout>
</android.support.v4.widget.NestedScrollView>
</android.support.v4.widget.DrawerLayout>
How can I fix this problem?
Hey man try this code :
<android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:ads="http://schemas.android.com/apk/res-auto"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="#+id/toNightDrawerLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
tools:openDrawer="end">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.v4.widget.NestedScrollView
android:layout_width="match_parent"
android:layout_height="match_parent">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<RelativeLayout
android:id="#+id/reviewSerialFrag_newsCommentsLay"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:visibility="visible">
<android.support.v7.widget.CardView
android:id="#+id/reviewSerialFrag_newsCommentsCard"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="#dimen/padding8"
ads:cardBackgroundColor="#android:color/white"
ads:cardElevation="#dimen/size2"
app:contentPadding="#dimen/padding8">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<RelativeLayout
android:id="#+id/reviewSerialFrag_newsCommentsHeaderLay"
android:layout_width="match_parent"
android:layout_height="#dimen/size50">
<ImageView
android:id="#+id/reviewSerialFrag_newsCommentsHeaderImage"
android:layout_width="#dimen/size35"
android:layout_height="#dimen/size35"
android:layout_centerVertical="true"
android:alpha="0.8"
android:src="#drawable/ic_comments"
android:tint="#color/darkBlueGrey" />
<TextView
android:id="#+id/reviewSerialFrag_newsCommentsUserTypeText"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_margin="#dimen/padding10"
android:layout_toRightOf="#+id/reviewSerialFrag_newsCommentsHeaderImage"
android:fontFamily="sans-serif-light"
android:gravity="center_vertical"
android:textColor="#color/darkBlueGrey"
android:textSize="#dimen/font16" />
<TextView
android:id="#+id/reviewSerialFrag_newsCommentsReviewTypeText"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_margin="#dimen/padding10"
android:layout_toRightOf="#+id/reviewSerialFrag_newsCommentsUserTypeText"
android:fontFamily="sans-serif-light"
android:gravity="center_vertical"
android:textColor="#color/darkBlueGrey"
android:textSize="#dimen/font14" />
</RelativeLayout>
<android.support.v7.widget.RecyclerView
android:id="#+id/reviewSerialFrag_newsCommentsRecyclerView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/reviewSerialFrag_newsCommentsHeaderLay"
android:layout_marginTop="#dimen/padding5" />
</RelativeLayout>
</android.support.v7.widget.CardView>
</RelativeLayout>
<!--EmptyList-->
<RelativeLayout
android:id="#+id/reviewSerialFrag_EmptyLsy"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:visibility="gone">
<include layout="#layout/empty_list" />
</RelativeLayout>
</RelativeLayout>
</android.support.v4.widget.NestedScrollView>
<android.support.design.widget.FloatingActionButton
android:id="#+id/reviewSerialFrag_FilterBtn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"
android:layout_margin="#dimen/padding15"
android:src="#drawable/ic_filter"
app:fabSize="normal" />
</RelativeLayout>
</android.support.v4.widget.DrawerLayout>
So try do that:
<android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:ads="http://schemas.android.com/apk/res-auto"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="#+id/toNightDrawerLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
tools:openDrawer="end">
<android.support.design.widget.CoordinatorLayout
android:id="#+id/main_content"
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.v4.widget.NestedScrollView
android:layout_width="match_parent"
android:layout_height="match_parent">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<RelativeLayout
android:id="#+id/reviewSerialFrag_newsCommentsLay"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:visibility="visible">
<android.support.v7.widget.CardView
android:id="#+id/reviewSerialFrag_newsCommentsCard"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="#dimen/padding8"
ads:cardBackgroundColor="#android:color/white"
ads:cardElevation="#dimen/size2"
app:contentPadding="#dimen/padding8">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<RelativeLayout
android:id="#+id/reviewSerialFrag_newsCommentsHeaderLay"
android:layout_width="match_parent"
android:layout_height="#dimen/size50">
<ImageView
android:id="#+id/reviewSerialFrag_newsCommentsHeaderImage"
android:layout_width="#dimen/size35"
android:layout_height="#dimen/size35"
android:layout_centerVertical="true"
android:alpha="0.8"
android:src="#drawable/ic_comments"
android:tint="#color/darkBlueGrey" />
<TextView
android:id="#+id/reviewSerialFrag_newsCommentsUserTypeText"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_margin="#dimen/padding10"
android:layout_toRightOf="#+id/reviewSerialFrag_newsCommentsHeaderImage"
android:fontFamily="sans-serif-light"
android:gravity="center_vertical"
android:textColor="#color/darkBlueGrey"
android:textSize="#dimen/font16" />
<TextView
android:id="#+id/reviewSerialFrag_newsCommentsReviewTypeText"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_margin="#dimen/padding10"
android:layout_toRightOf="#+id/reviewSerialFrag_newsCommentsUserTypeText"
android:fontFamily="sans-serif-light"
android:gravity="center_vertical"
android:textColor="#color/darkBlueGrey"
android:textSize="#dimen/font14" />
</RelativeLayout>
<android.support.v7.widget.RecyclerView
android:id="#+id/reviewSerialFrag_newsCommentsRecyclerView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/reviewSerialFrag_newsCommentsHeaderLay"
android:layout_marginTop="#dimen/padding5" />
</RelativeLayout>
</android.support.v7.widget.CardView>
</RelativeLayout>
<!--EmptyList-->
<RelativeLayout
android:id="#+id/reviewSerialFrag_EmptyLsy"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:visibility="gone">
<include layout="#layout/empty_list" />
</RelativeLayout>
</RelativeLayout>
</android.support.v4.widget.NestedScrollView>
<android.support.design.widget.FloatingActionButton
android:id="#+id/reviewSerialFrag_FilterBtn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="end|bottom"
android:layout_margin="#dimen/padding15"
android:src="#drawable/ic_filter"
app:fabSize="normal" />
</android.support.design.widget.CoordinatorLayout>
</android.support.v4.widget.DrawerLayout>
Set all contect inside a coordinator layout and fab outside the nestedscrollview .If not work ask me to send other possible way.
<android.support.design.widget.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="#style/Widget.AppTheme.AppBarOverlay">
<include
layout="#layout/include_layout_toolbar_scroll"/>
</android.support.design.widget.AppBarLayout>
<include layout="#layout/include_layout_content_with_nestedscroll"/>
<android.support.design.widget.FloatingActionButton
android:id="#+id/fab_task_accept"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="end|bottom"
android:layout_margin="#dimen/fab_margin"
android:src="#drawable/ic_accepted"
app:layout_behavior="pass.to.FabScrollBehavior.Class"
app:theme="#style/Widget.AppTheme.Fab"/>
< /android.support.design.widget.CoordinatorLayout>
use coordinatorlayout
use this link
Related
I want to make navigation drawer above sliding up panel.
I use this https://github.com/umano/AndroidSlidingUpPanel
<com.sothree.slidinguppanel.SlidingUpPanelLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:sothree="http://schemas.android.com/apk/res-auto"
android:id="#+id/suplSurveys"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="bottom"
sothree:umanoScrollableView="#+id/vpPlace"
sothree:umanoPanelHeight="68dp"
sothree:umanoParallaxOffset="100dp"
sothree:umanoDragView="#+id/dragView"
sothree:umanoOverlay="true">
<FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<android.support.v4.widget.DrawerLayout
android:id="#+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent">
<FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<fragment
android:id="#+id/map"
android:name="com.google.android.gms.maps.SupportMapFragment"
android:layout_width="match_parent"
android:layout_height="match_parent" />
<android.support.v7.widget.Toolbar
android:id="#+id/toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#006df0"
app:titleTextColor="#color/colorBackGrey"
android:elevation="20dp"
app:layout_scrollFlags="scroll|enterAlways"
app:popupTheme="#style/ThemeOverlay.AppCompat.Light"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="top|end"
android:layout_marginTop="65dp"
android:orientation="vertical">
<android.support.design.widget.FloatingActionButton
android:id="#+id/fab_my_location"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="top|end"
android:layout_marginTop="10dp"
android:layout_marginEnd="15dp"
app:backgroundTint="#color/jet"
app:fabSize="normal"
app:srcCompat="#drawable/ic_my_location" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:orientation="vertical">
<FrameLayout
android:layout_width="match_parent"
android:layout_height="60dp"
android:layout_marginBottom="65dp"
android:paddingLeft="80dp"
android:paddingRight="80dp"
android:layout_gravity="center">
<com.dd.morphingbutton.impl.IndeterminateProgressButton
android:id="#+id/add_new_location"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:fontFamily="#font/pt_mono"
android:layout_gravity="center_horizontal"
android:textSize="18sp"
android:textColor="#color/colorBackGrey"
android:text="ADD"/>
</FrameLayout>
</LinearLayout>
</FrameLayout>
<android.support.design.widget.NavigationView
android:id="#+id/nvView"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="start"
app:headerLayout="#layout/navdraw_header"
app:menu="#menu/drawer_view" />
</android.support.v4.widget.DrawerLayout>
</FrameLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="400dp"
android:paddingRight="10dp"
android:paddingLeft="10dp"
android:background="#drawable/border"
android:orientation="vertical"
android:focusable="false"
android:id="#+id/dragView">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="68dp"
android:orientation="vertical">
<TextView
android:layout_width="48dp"
android:layout_height="2dp"
android:layout_marginTop="5dp"
android:gravity="center"
android:layout_gravity="center"
android:background="#dddddd" />
<TextView
android:layout_width="48dp"
android:layout_marginTop="5dp"
android:layout_height="2dp"
android:gravity="center"
android:layout_gravity="center"
android:background="#dddddd" />
<TextView android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_weight="1"
android:textSize="14sp"
android:fontFamily="#font/pt_mono"
android:textStyle="bold"
android:text="DAFTAR LOKASI SURVEY"
android:textColor="#color/colorAccent"
android:gravity="center_vertical"
android:paddingLeft="10dp"/>
</LinearLayout>
<ProgressBar
style="?android:attr/progressBarStyleSmall"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:id="#+id/pbLoad"
android:gravity="center"
android:layout_margin="15dp" />
<android.support.v7.widget.RecyclerView
android:id="#+id/vpPlace"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1" />
</LinearLayout></com.sothree.slidinguppanel.SlidingUpPanelLayout>
That's my layout code
So I dont understand what does it mean to make second child
So I dont understand what does it mean to make second child
So I dont understand what does it mean to make second child
So I dont understand what does it mean to make second child
So I dont understand what does it mean to make second child
<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.DrawerLayout android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="#+id/drawer_layout"
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:sothree="http://schemas.android.com/apk/res-auto">
<com.sothree.slidinguppanel.SlidingUpPanelLayout
android:id="#+id/suplSurveys"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="bottom"
sothree:umanoScrollableView="#+id/vpPlace"
sothree:umanoPanelHeight="68dp"
sothree:umanoParallaxOffset="100dp"
sothree:umanoDragView="#+id/dragView"
sothree:umanoOverlay="true">
<FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<fragment
android:id="#+id/map"
android:name="com.google.android.gms.maps.SupportMapFragment"
android:layout_width="match_parent"
android:layout_height="match_parent" />
<android.support.v7.widget.Toolbar
android:id="#+id/toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#006df0"
app:titleTextColor="#color/colorBackGrey"
android:elevation="20dp"
app:layout_scrollFlags="scroll|enterAlways"
app:popupTheme="#style/ThemeOverlay.AppCompat.Light"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="top|end"
android:layout_marginTop="65dp"
android:orientation="vertical">
<android.support.design.widget.FloatingActionButton
android:id="#+id/fab_my_location"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="top|end"
android:layout_marginTop="10dp"
android:layout_marginEnd="15dp"
app:backgroundTint="#color/jet"
app:fabSize="normal"
app:srcCompat="#drawable/ic_my_location" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:orientation="vertical">
<FrameLayout
android:layout_width="match_parent"
android:layout_height="60dp"
android:layout_marginBottom="65dp"
android:paddingLeft="80dp"
android:paddingRight="80dp"
android:layout_gravity="center">
<com.dd.morphingbutton.impl.IndeterminateProgressButton
android:id="#+id/add_new_location"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:fontFamily="#font/pt_mono"
android:layout_gravity="center_horizontal"
android:textSize="18sp"
android:textColor="#color/colorBackGrey"
android:text="ADD"/>
</FrameLayout>
</LinearLayout>
</FrameLayout>
<!--</android.support.v4.widget.DrawerLayout>-->
</FrameLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="400dp"
android:paddingRight="10dp"
android:paddingLeft="10dp"
android:background="#drawable/border"
android:orientation="vertical"
android:focusable="false"
android:id="#+id/dragView">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="68dp"
android:orientation="vertical">
<TextView
android:layout_width="48dp"
android:layout_height="2dp"
android:layout_marginTop="5dp"
android:gravity="center"
android:layout_gravity="center"
android:background="#dddddd" />
<TextView
android:layout_width="48dp"
android:layout_marginTop="5dp"
android:layout_height="2dp"
android:gravity="center"
android:layout_gravity="center"
android:background="#dddddd" />
<TextView android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_weight="1"
android:textSize="14sp"
android:fontFamily="#font/pt_mono"
android:textStyle="bold"
android:text="DAFTAR LOKASI SURVEY"
android:textColor="#color/colorAccent"
android:gravity="center_vertical"
android:paddingLeft="10dp"/>
</LinearLayout>
<ProgressBar
style="?android:attr/progressBarStyleSmall"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:id="#+id/pbLoad"
android:gravity="center"
android:layout_margin="15dp" />
<android.support.v7.widget.RecyclerView
android:id="#+id/vpPlace"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1" />
</LinearLayout>
</com.sothree.slidinguppanel.SlidingUpPanelLayout>
<android.support.design.widget.NavigationView
android:id="#+id/nvView"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="start"
app:headerLayout="#layout/navdraw_header"
app:menu="#menu/drawer_view" />
</android.support.v4.widget.DrawerLayout>
This should be a simple fix, I can't see your layout xml with your drawer style (feel free to share the code).
Using a standard navigation view as an example to give the same layout you have now would look something like this:
<?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"
xmlns:tools="http://schemas.android.com/tools"
android:id="#+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
tools:openDrawer="start">
<android.support.design.widget.CoordinatorLayout
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">
<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>
<LinearLayout
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"
app:layout_behavior="#string/appbar_scrolling_view_behavior"
tools:context=".MainActivity"
tools:showIn="#layout/app_bar_main">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Hello World!"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent" />
</LinearLayout>
</android.support.design.widget.CoordinatorLayout>
<android.support.design.widget.NavigationView
android:id="#+id/nav_view"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="start"
android:fitsSystemWindows="true"
app:menu="#menu/activity_main_drawer" />
</android.support.v4.widget.DrawerLayout>
Which displays something like this (similar to yours):
You will need to wrap the whole screen in another layout (likely linear layout in vertical). You will want to extract the toolbar and bring it out to the outer/top most position like so:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout android:layout_height="match_parent"
android:layout_width="match_parent"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical">
<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>
<android.support.v4.widget.DrawerLayout 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:id="#+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
tools:openDrawer="start">
<android.support.design.widget.CoordinatorLayout
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">
<LinearLayout
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"
app:layout_behavior="#string/appbar_scrolling_view_behavior"
tools:context=".MainActivity"
tools:showIn="#layout/app_bar_main">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Hello World!"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent" />
</LinearLayout>
</android.support.design.widget.CoordinatorLayout>
<android.support.design.widget.NavigationView
android:id="#+id/nav_view"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="start"
android:fitsSystemWindows="true"
app:menu="#menu/activity_main_drawer" />
</android.support.v4.widget.DrawerLayout>
</LinearLayout>
This gives you what you desire - the toolbar will now stay on top and appear like:
Let me know if that does help - please bare in mind that I have made a few assumptions since I have not seen any code yet.
I have this problem to accommodate my floating button, and I do not understand why it does not work.
I would appreciate your response since I can not find the reason why this is happening, one more detail when scrolling or reloading the fragment some of the floating buttons will be accommodated.
And sorry for my English.
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#color/colorBackground"
android:orientation="vertical">
<android.support.v4.widget.NestedScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="#string/appbar_scrolling_view_behavior">
<android.support.v7.widget.CardView
android:id="#+id/mRequestCard"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="10dp"
android:elevation="100dp"
android:orientation="horizontal"
app:cardBackgroundColor="#color/colorWhite"
app:cardCornerRadius="3dp">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<View
android:id="#+id/vDivisor"
android:layout_width="match_parent"
android:layout_height="2dp"
android:background="#color/colorGreen" />
...
</RelativeLayout>
</android.support.v7.widget.CardView>
</android.support.v4.widget.NestedScrollView>
<android.support.design.widget.FloatingActionButton
android:id="#+id/fab"
android:layout_width="30dp"
android:layout_height="30dp"
android:layout_marginRight="#dimen/fab_margin"
android:backgroundTint="#color/colorPurple"
android:scaleType="centerCrop"
android:src="#drawable/ic_route_direction"
app:layout_anchor="#id/mRequestCard"
app:layout_anchorGravity="right|end|bottom" />
</android.support.design.widget.CoordinatorLayout>
And this is my RecyclerView Which is inflated in a fragment
<FrameLayout 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"
tools:context="com.test.HistorialFragment">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.v7.widget.RecyclerView
android:id="#+id/mRecyclerRequest"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</LinearLayout>
</FrameLayout>
And this is my fragment, where I show the RecyclerView
<FrameLayout 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:id="#+id/content_frame"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="#string/appbar_scrolling_view_behavior"
tools:context="com.test.MainActivity"
tools:showIn="#layout/app_bar_main">
</FrameLayout>
you should try RelativeLayout like this
<RelativeLayout android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:orientation="horizontal"
xmlns:android="http://schemas.android.com/apk/res/android">
<android.support.design.widget.FloatingActionButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:backgroundTint="#color/colorBlack"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"/>
<android.support.v7.widget.CardView
android:layout_width="match_parent"
android:layout_height="match_parent"
app:cardCornerRadius="#dimen/activity_corner"
android:layout_marginBottom="#dimen/activity_margin">
<!--your cardview item here-->
</android.support.v7.widget.CardView>
</RelativeLayout>
for your RecyclerView item
Check if this helps you:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#color/colorPrimary"
android:orientation="vertical">
<android.support.v4.widget.NestedScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="#string/appbar_scrolling_view_behavior">
<android.support.v7.widget.CardView
android:id="#+id/mRequestCard"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="10dp"
android:elevation="100dp"
android:orientation="horizontal"
app:cardBackgroundColor="#color/colorWhite"
app:cardCornerRadius="3dp">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<View
android:id="#+id/vDivisor"
android:layout_width="match_parent"
android:layout_height="2dp"
android:background="#color/colorGreen" />
...
</RelativeLayout>
</android.support.v7.widget.CardView>
</android.support.v4.widget.NestedScrollView>
<android.support.design.widget.FloatingActionButton
android:id="#+id/fab"
android:layout_width="30dp"
android:layout_height="30dp"
android:layout_alignParentRight="true"
android:layout_marginRight="10dp"
android:backgroundTint="#color/colorAccent"
android:scaleType="centerCrop"
android:src="#drawable/ic_launcher"
app:layout_anchor="#id/mRequestCard"
app:layout_anchorGravity="right|end|bottom" />
</RelativeLayout>
try this use RelativeLayout and make your FloatingActionButton property android:layout_alignParentBottom="true" and
android:layout_alignParentRight="true" like below code
<RelativeLayout android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:orientation="horizontal"
xmlns:android="http://schemas.android.com/apk/res/android">
<android.support.design.widget.FloatingActionButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:backgroundTint="#color/colorBlack"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"/>
<android.support.v7.widget.CardView
android:layout_width="match_parent"
android:layout_height="match_parent"
app:cardCornerRadius="#dimen/activity_corner"
android:layout_marginBottom="#dimen/activity_margin">
</android.support.v7.widget.CardView>
</RelativeLayout>
I am trying to read the layout code but couldn't get why.
I have a code for drawerlayout and the problem is the whole drawerLayout is scroll able i just want to the items list view scroll able not the header and i couldn't figure it out because it looks like all components are custom made.
Can any one have a look at it..
Thanks in advance
<?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"
xmlns:tools="http://schemas.android.com/tools"
android:id="#+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
tools:context="com.activities.MainActivity">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<android.support.v7.widget.Toolbar
android:id="#+id/toolbar"
style="#style/ToolBarStyle"
android:layout_width="match_parent"
android:layout_height="#dimen/abc_action_bar_default_height_material"
android:background="?attr/colorPrimary">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginRight="#dimen/abc_action_bar_default_height_material">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:adjustViewBounds="true"
android:scaleType="centerInside"
android:src="#drawable/menu_logo" />
</RelativeLayout>
</android.support.v7.widget.Toolbar>
<ViewFlipper
android:id="#+id/loading_switcher"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ProgressBar
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center" />
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.design.widget.CoordinatorLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_above="#+id/checkout_container">
<android.support.design.widget.AppBarLayout
android:id="#+id/app_bar_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="#style/ThemeOverlay.AppCompat.Dark.ActionBar"
app:elevation="2dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#android:color/white"
android:orientation="vertical"
android:padding="10dp"
app:layout_scrollFlags="scroll|enterAlways">
<com.views.font.CustomFontTextView
android:id="#+id/location_text_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:drawableLeft="#drawable/ic_location_on_black_18dp"
android:ellipsize="end"
android:gravity="center_vertical"
android:maxLines="1"
android:singleLine="true"
android:text="Pick Location"
android:textColor="#color/colorPrimary"
android:textSize="15sp" />
<com.views.font.CustomFontTextView
android:id="#+id/locality_info_text_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ellipsize="end"
android:gravity="center_vertical"
android:maxLines="1"
android:singleLine="true"
android:textColor="#android:color/black"
android:textSize="12sp" />
</LinearLayout>
</android.support.design.widget.AppBarLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent" app:layout_behavior="#string/appbar_scrolling_view_behavior">
<android.support.v4.widget.SwipeRefreshLayout
android:id="#+id/product_list_swipe_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginLeft="2dp"
android:layout_marginRight="2dp">
<android.support.v7.widget.RecyclerView
android:id="#+id/products_list_recycler_view"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</android.support.v4.widget.SwipeRefreshLayout>
</RelativeLayout>
</android.support.design.widget.CoordinatorLayout>
<com.views.CheckoutShelfView
android:id="#+id/checkout_container"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:layout_alignParentBottom="true" />
</RelativeLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:gravity="center"
android:orientation="vertical">
<com.views.font.CustomFontTextView
android:id="#+id/error_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="16dp"
android:gravity="center"
android:textColor="#color/grey_bg"
android:textSize="20sp" />
<com.views.font.CustomFontTextView
android:id="#+id/error_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:background="#drawable/shape_green_fill_round_5dp"
android:drawablePadding="2dp"
android:gravity="center_vertical"
android:paddingBottom="5dp"
android:paddingLeft="4dp"
android:paddingRight="8dp"
android:paddingTop="5dp"
android:textAllCaps="false"
android:textColor="#android:color/white" />
</LinearLayout>
</ViewFlipper>
</LinearLayout>
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.design.widget.NavigationView
android:id="#+id/navigation_view"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="start"
app:headerLayout="#layout/header_navigation"
app:itemIconTint="#color/colorPrimary"
app:itemTextColor="#color/colorPrimary"
app:menu="#menu/navigation_menu">
<com.views.font.CustomFontTextView
android:id="#+id/version_text"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal|bottom"
android:background="#android:color/white"
android:gravity="center"
android:padding="3dp"
android:textSize="10sp">
</com.views.font.CustomFontTextView>
</android.support.design.widget.NavigationView>
</ScrollView>
</android.support.v4.widget.DrawerLayout>
try this:
Remove Scrollview from the layout:
try this:
<android.support.design.widget.NavigationView
android:id="#+id/navigation_view"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="start"
android:fitsSystemWindows="true"
app:headerLayout="#layout/header_navigation"
app:itemIconTint="#color/colorPrimary"
app:itemTextColor="#color/colorPrimary"
app:menu="#menu/navigation_menu" />
In activity;
//mNavigationView is your navigation view
mNavViewHeaderLayout = LayoutInflater.from(MainActivity.this).inflate(R.layout.header_navigation, mNavigationView);
//to access content in header view
mTextview = (TextView)mNavViewHeaderLayout.findViewById(R.id.textview);
Good afternoon,
I am trying to put a FAB at the bottom|end of a fragment, but I do not know where I can place it.
Here is the Fragment's xml code :
<android.support.v4.widget.SwipeRefreshLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="#+id/swipe_container"
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.design.widget.CoordinatorLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/cars_list_content"
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:id="#+id/scrollable_layout">
<include layout="#layout/write_comment"/>
<android.support.v7.widget.RecyclerView
android:id="#+id/recyclerview"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</LinearLayout>
</android.support.design.widget.CoordinatorLayout>
</android.support.v4.widget.SwipeRefreshLayout>
And the FAB :
<android.support.design.widget.FloatingActionButton
android:id="#+id/fab"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="end|bottom"
android:layout_margin="#dimen/fab_margin"
android:src="#drawable/ic_plus" />
Thanks for your help !
An answer helped me to have a first "solution" with this code :
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true">
<android.support.v4.widget.SwipeRefreshLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="#+id/swipe_container"
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.design.widget.CoordinatorLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/cars_list_content"
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:id="#+id/scrollable_layout">
<include layout="#layout/write_comment"/>
<android.support.v7.widget.RecyclerView
android:id="#+id/recyclerview"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</LinearLayout>
</android.support.design.widget.CoordinatorLayout>
</android.support.v4.widget.SwipeRefreshLayout>
<android.support.design.widget.FloatingActionButton
android:id="#+id/fab"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="end|bottom"
android:layout_margin="#dimen/fab_margin"
android:src="#drawable/ic_plus"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true"/>
</RelativeLayout>
But it does not work correctly :
Try this:
<?xml version="1.0" encoding="utf-8"?>
<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"
android:fitsSystemWindows="true">
<android.support.v4.widget.SwipeRefreshLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="#+id/swipe_container"
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/cars_list_content"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:id="#+id/scrollable_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<android.support.v7.widget.RecyclerView
android:id="#+id/recyclerview"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</LinearLayout>
</android.support.design.widget.CoordinatorLayout>
</android.support.v4.widget.SwipeRefreshLayout>
<android.support.design.widget.FloatingActionButton
android:id="#+id/fab_add"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:layout_margin="#dimen/fab_margin"
android:src="#drawable/ic_photo_camera_white"
app:backgroundTint="#color/colorFabButton" />
</RelativeLayout>
<?xml version="1.0" encoding="utf-8"?>
<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="match_parent">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
android:id="#+id/image12"
android:layout_width="match_parent"
android:layout_height="250dp"
android:alpha="0.5"
android:src="#drawable/lawbook"
android:scaleType="fitXY"/>
<de.hdodenhof.circleimageview.CircleImageView
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="#+id/profile_image"
android:layout_width="120dp"
android:layout_height="120dp"
android:src="#drawable/aliyar"
android:layout_above="#+id/text121"
android:layout_centerHorizontal="true"
android:layout_marginBottom="71dp" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/image12"
android:textSize="14sp"
android:layout_marginTop="40dp"
android:id="#+id/text121"
android:text="#string/aliyar1"
android:gravity="center_horizontal"
/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/text121"
android:layout_marginTop="5dp"
android:textSize="14sp"
android:text="#string/aliyar2"
android:id="#+id/text122"
android:gravity="center_horizontal"
/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/text122"
android:layout_marginTop="5dp"
android:text="#string/aliyar3"
android:textSize="14sp"
android:id="#+id/text123"
android:gravity="center_horizontal"
/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/text123"
android:layout_marginTop="5dp"
android:text="#string/aliyar4"
android:id="#+id/text124"
android:textSize="14sp"
android:gravity="center_horizontal"
/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/text124"
android:layout_marginTop="5dp"
android:text="#string/aliyar5"
android:id="#+id/text125"
android:textSize="14sp"
android:gravity="center_horizontal"
/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/text125"
android:layout_marginTop="5dp"
android:text="#string/aliyar6"
android:textSize="14sp"
android:id="#+id/text126"
android:gravity="center_horizontal"
/>
</RelativeLayout>
</ScrollView>
</RelativeLayout>
Check below Layout :
<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="#+id/contactnew">
<include
layout="#layout/contentcontact"/>
<android.support.design.widget.FloatingActionButton
android:id="#+id/facebookfab"
android:layout_gravity="bottom|right"
android:layout_width="299dp"
android:layout_height="wrap_content"
android:layout_margin="16dp"
android:clickable="true"
app:backgroundTint="#fff"
android:src="#mipmap/facebook" />
<android.support.design.widget.FloatingActionButton
android:id="#+id/callfab"
android:layout_gravity="bottom|left"
android:layout_width="299dp"
android:layout_height="wrap_content"
android:layout_margin="16dp"
android:clickable="true"
app:backgroundTint="#color/Color_Blue"
android:src="#drawable/ic_local_phone_black_24dp" />
</android.support.design.widget.CoordinatorLayout>
I'm trying to have a card widget starting above an appBarLayout, and continuing above the white background that follows. Above this card I need to have and ImageView (at the top-center), and two floating buttons (at the bottom-right). Half of those elements are on the card, the other half is out.
My issues are : i have no shadows below my card, and the buttons are cut in half.
Here's what i got so far :
layout_card_detailed.xml
<FrameLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
xmlns:app="http://schemas.android.com/tools"
android:layout_margin="5dp">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
>
<android.support.v7.widget.CardView
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:card_view="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/card_view"
android:layout_gravity="center"
card_view:cardCornerRadius="1dp"
android:foreground="?android:attr/selectableItemBackground"
android:layout_marginTop="#dimen/card_detail_avatar_margin"
>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:padding="#dimen/card_detail_padding"
android:orientation="vertical">
<android.support.v7.widget.Toolbar
android:id="#+id/toolbar"
android:layout_height="?attr/actionBarSize"
android:layout_width="match_parent"
app:popupTheme="#style/AppTheme.PopupOverlay" />
<TextView
android:id="#+id/text_description"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="#dimen/abc_text_size_medium_material"
android:layout_marginBottom="#dimen/space_big" />
<TextView
android:id="#+id/text_owner"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="#dimen/abc_text_size_small_material"
android:layout_marginBottom="#dimen/space_small" />
<TextView
android:id="#+id/text_date"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="#dimen/abc_text_size_small_material"
/>
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="#dimen/space_big" />
</LinearLayout>
</android.support.v7.widget.CardView>
</RelativeLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
>
<ImageView
android:id="#+id/image_avatar"
android:layout_width="#dimen/avatar_size_detail"
android:layout_height="#dimen/avatar_size_detail"
android:src="#drawable/contact"
android:layout_centerHorizontal="true" />
</RelativeLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginBottom="-28dp"
android:gravity="bottom|right">
<LinearLayout
android:orientation="horizontal"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="#dimen/fab_margin">
<android.support.design.widget.FloatingActionButton
android:id="#+id/fab_match"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#android:drawable/ic_dialog_email"
android:layout_marginRight="#dimen/fab_margin"
/>
<android.support.design.widget.FloatingActionButton
android:id="#+id/fab_reply"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#android:drawable/ic_dialog_email" />
</LinearLayout>
</RelativeLayout>
</FrameLayout>
activity_card_detail.xml
<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" android:fitsSystemWindows="true"
tools:context="com.myapp.CardDetailActivity" tools:ignore="MergeRootFrame">
<android.support.design.widget.AppBarLayout android:id="#+id/app_bar"
android:layout_width="match_parent" android:layout_height="#dimen/app_bar_height"
android:fitsSystemWindows="true"
android:theme="#style/ThemeOverlay.AppCompat.Dark.ActionBar">
<android.support.design.widget.CollapsingToolbarLayout
android:id="#+id/toolbar_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
app:contentScrim="?attr/colorPrimary"
app:layout_scrollFlags="scroll|exitUntilCollapsed"
app:toolbarId="#+id/toolbar">
<android.support.v7.widget.Toolbar android:id="#+id/detail_toolbar"
android:layout_width="match_parent" android:layout_height="?attr/actionBarSize"
app:layout_collapseMode="pin"
app:popupTheme="#style/ThemeOverlay.AppCompat.Light" />
</android.support.design.widget.CollapsingToolbarLayout>
</android.support.design.widget.AppBarLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="#dimen/layout_margin">
<include layout="#layout/layout_card_detailed"/>
</RelativeLayout>
</android.support.design.widget.CoordinatorLayout>
Finally figured it out, i had to use CoordinatorLayout instead of FrameLayout.
Everything works good now, appart from the fact that my FAB shadows are cut in an abrupt way, following the square shape of the original android view.
If anyone as an idea i'm interested :-).
layout_card_detailed.xml
<?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"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="#dimen/layout_margin">
<android.support.v7.widget.CardView
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:card_view="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/card_view"
card_view:cardCornerRadius="1dp"
android:foreground="?android:attr/selectableItemBackground"
android:layout_marginTop="#dimen/card_detail_avatar_margin">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="center"
>
<ProgressBar
android:id="#+id/progress"
android:visibility="visible"
style="?android:attr/progressBarStyleSmall"
android:layout_width="#dimen/card_progress_size"
android:layout_height="#dimen/card_progress_size"
android:layout_centerInParent="true"
/>
</RelativeLayout>
<LinearLayout
android:id="#+id/content_loading"
android:visibility="invisible"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:padding="#dimen/card_detail_padding"
android:orientation="vertical">
<android.support.v7.widget.Toolbar
android:id="#+id/toolbar"
android:layout_height="?attr/actionBarSize"
android:layout_width="match_parent"
app:popupTheme="#style/AppTheme.PopupOverlay" />
<TextView
android:id="#+id/text_description"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="#dimen/abc_text_size_medium_material"
android:layout_marginBottom="#dimen/space_big" />
<TextView
android:id="#+id/text_owner"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="#dimen/abc_text_size_small_material"
android:layout_marginBottom="#dimen/space_small" />
<TextView
android:id="#+id/text_networks"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="#dimen/abc_text_size_small_material"
/>
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="#dimen/space_big" />
</LinearLayout>
</android.support.v7.widget.CardView>
</RelativeLayout>
<LinearLayout
android:orientation="horizontal"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_anchor="#id/card_view"
app:layout_anchorGravity="right|end|bottom"
android:layout_marginRight="#dimen/fab_margin">
<android.support.design.widget.FloatingActionButton
android:id="#+id/fab_match"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#android:drawable/ic_menu_share"
android:layout_marginRight="#dimen/fab_margin"
/>
<android.support.design.widget.FloatingActionButton
android:id="#+id/fab_reply"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#android:drawable/ic_dialog_email"
/>
</LinearLayout>
<LinearLayout
android:orientation="horizontal"
android:layout_width="wrap_content"
android:layout_height="100dp"
app:layout_anchor="#id/card_view"
app:layout_anchorGravity="right|end|bottom"
android:layout_marginRight="#dimen/fab_margin">
</LinearLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="#dimen/layout_margin"
>
<ImageView
android:id="#+id/image_avatar"
android:layout_width="#dimen/avatar_size_detail"
android:layout_height="#dimen/avatar_size_detail"
android:src="#drawable/contact"
android:layout_centerHorizontal="true" />
</RelativeLayout>
</android.support.design.widget.CoordinatorLayout>