Error when use android.support.design.widget.CoordinatorLayout - java

I'm new android dev. I have tried to work with
<android.support.design.widget.CoordinatorLayout>
and here is my XML code.
<?xml version="1.0" encoding="utf-8"?>
<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"
tools:context="com.example.ducbo.flynow_ver20.payment_section">
<LinearLayout
android:id="#+id/payment_header"
android:layout_width="match_parent"
android:layout_height="100dp"
android:background="#drawable/background_header">
<Button
android:id="#+id/payment_btn_back"
android:layout_width="15dp"
android:layout_height="30dp"
android:layout_gravity="center_vertical"
android:layout_marginLeft="15dp"
android:background="#drawable/btnback" />
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginRight="27dp"
android:layout_toRightOf="#id/payment_btn_back"
android:layout_weight="12"
android:gravity="center_horizontal"
android:text="#string/thanh_toan"
android:textColor="#color/white"
android:textSize="28sp" />
</LinearLayout>
<android.support.v4.widget.NestedScrollView
android:id="#+id/payment_content"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/payment_header">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:id="#+id/payment_types"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#color/white"
android:padding="15dp"
android:text=""
android:textSize="16sp" />
<LinearLayout
android:id="#+id/payment_types_container"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="#+id/payment_tab_method"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="#+id/payment_types">
<android.support.design.widget.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="15dp"
android:theme="#style/ThemeOverlay.AppCompat.Dark.ActionBar">
<!--<android.support.v7.widget.Toolbar-->
<!--android:id="#+id/toolbar"-->
<!--android:layout_width="match_parent"-->
<!--android:layout_height="?attr/actionBarSize"-->
<!--app:layout_scrollFlags="scroll|enterAlways"-->
<!--app:popupTheme="#style/ThemeOverlay.AppCompat.Light" />-->
<!--android:background="?attr/colorPrimary"-->
<android.support.design.widget.TabLayout
android:id="#+id/tabs"
android:layout_width="match_parent"
android:layout_height="90dp"
android:background="#color/white"
app:tabGravity="fill"
app:tabMode="fixed" />
</android.support.design.widget.AppBarLayout>
<android.support.v4.view.ViewPager
android:id="#+id/viewpager"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_behavior="#string/appbar_scrolling_view_behavior" />
</android.support.design.widget.CoordinatorLayout>
</LinearLayout>
<include
android:id="#+id/payment_table_passenger"
layout="#layout/table_passenger"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/payment_types_container"></include>
<include
android:id="#+id/payment_startdp"
layout="#layout/fm_booking_startdp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/payment_table_passenger"></include>
<include
android:id="#+id/payment_enddp"
layout="#layout/fragment_booking_enddp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/payment_startdp">
</include>
<Button
android:id="#+id/payment_btn_submit"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/payment_enddp"
android:layout_marginBottom="15dp"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_marginTop="15dp"
android:background="#drawable/border_orange"
android:text="Continue"
android:textColor="#color/white" />
</RelativeLayout>
</android.support.v4.widget.NestedScrollView>
With each tab, I used one fragment to show tab's content. After that, I included some layout below Coordinator but it wasn't appear below Coordinator. When I checked again in Design tab on Android studio, I realized that the height of coordinator seemingly unlimited even though I set wrap_content for it. I think that is problem and I have changed height attribute of Coordinator to specific number and my input layout appeared but I don't want like this. What can I fix the height of Coordinator to wrap content?

Related

Android java - card slider match width to parent

I would like to create a horizontally scrolling photo gallery. I'm using https://github.com/IslamKhSh/CardSlider.
I would like the photo to be displayed across the entire width of the screen and the height of the photo to scale.
Unfortunately, currently the image is not displayed on the entire width of the screen, there are small margins (green area) screenshot.
I tried setting the margin and padding to 0 but it didn't help. What can I do to remove these margins?
Gallery item
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#android:color/transparent"
android:gravity="center_horizontal"
android:orientation="vertical"
android:padding="0dp"
>
<ImageView
android:id="#+id/image_poster"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:adjustViewBounds="true"
android:background="#color/colorContrastYellow"
/>
<TextView
android:id="#+id/image_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="12sp" />
</LinearLayout>
Activity with gallery
<?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="match_parent">
<androidx.coordinatorlayout.widget.CoordinatorLayout
android:id="#+id/coordinator_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_above="#+id/activity_details_social_bar"
android:background="#color/colorLightGrayBackground"
android:fitsSystemWindows="true">
<com.google.android.material.appbar.AppBarLayout
android:id="#+id/app_bar_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:adjustViewBounds="true"
android:background="#color/colorLightGrayBackgroundTransparent"
android:fitsSystemWindows="true"
android:theme="#style/ThemeOverlay.AppCompat.Dark.ActionBar">
<com.google.android.material.appbar.CollapsingToolbarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:fitsSystemWindows="true"
app:contentScrim="?attr/colorPrimary"
app:expandedTitleMarginEnd="64dp"
app:expandedTitleMarginStart="48dp"
app:layout_scrollFlags="scroll|exitUntilCollapsed"
>
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:fitsSystemWindows="true"
android:background="#color/colorRed">
<com.github.islamkhsh.CardSliderViewPager
android:id="#+id/viewPager"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#color/greenCard"
app:cardSlider_indicator="#id/indicator"
app:cardSlider_otherPagesWidth="0dp"
app:cardSlider_pageMargin="0dp"
android:layout_margin="0dp"
android:padding="0dp"
app:cardSlider_smallScaleFactor="1"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<com.github.islamkhsh.CardSliderIndicator
android:id="#+id/indicator"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#id/viewPager" />
</androidx.constraintlayout.widget.ConstraintLayout>
<include
android:id="#+id/toolbar"
layout="#layout/toolbar_transparent" />
</com.google.android.material.appbar.CollapsingToolbarLayout>
</com.google.android.material.appbar.AppBarLayout>
<androidx.core.widget.NestedScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="#string/appbar_scrolling_view_behavior">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:divider="#drawable/v_line"
android:orientation="vertical"
android:showDividers="middle">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:paddingLeft="#dimen/activity_padding"
android:paddingTop="#dimen/dp10"
android:paddingRight="#dimen/activity_padding"
android:paddingBottom="#dimen/dp10">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:id="#+id/activity_details_news_TV_category"
style="#style/AppTheme.DetailsSectionTitleTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_alignParentRight="true"
android:layout_marginBottom="#dimen/dp12" />
<de.hdodenhof.circleimageview.CircleImageView
android:id="#+id/activity_details_news_CIV_author_photo_static"
android:layout_width="#dimen/author_image_size"
android:layout_height="#dimen/author_image_size"
android:layout_alignTop="#+id/activity_details_news_TV_author"
android:layout_alignBottom="#+id/activity_details_news_TV_publ_date"
android:layout_alignParentLeft="true"
android:layout_marginRight="#dimen/dp8" />
<ImageView
android:id="#+id/activity_details_news_IMG_line"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_alignTop="#+id/activity_details_news_TV_author"
android:layout_alignBottom="#+id/activity_details_news_TV_publ_date"
android:layout_marginRight="#dimen/dp8"
android:layout_toRightOf="#+id/activity_details_news_CIV_author_photo_static"
android:src="#drawable/h_line" />
<TextView
android:id="#+id/activity_details_news_TV_author"
style="#style/AppTheme.DetailsAuthorTextView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/activity_details_news_TV_category"
android:layout_toRightOf="#+id/activity_details_news_IMG_line" />
<TextView
android:id="#+id/activity_details_news_TV_publ_date"
style="#style/AppTheme.DetailsAuthorTextView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/activity_details_news_TV_author"
android:layout_alignParentBottom="true"
android:layout_toRightOf="#+id/activity_details_news_IMG_line" />
</RelativeLayout>
<TextView
android:id="#+id/activity_details_news_TV_title"
style="#style/AppTheme.DetailsTitleTextView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="#dimen/dp12" />
<TextView
android:id="#+id/activity_details_news_TV_headline"
style="#style/AppTheme.DetailsAbstrTextView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="#dimen/dp12" />
<TextView
android:id="#+id/activity_details_news_TV_descr"
style="#style/AppTheme.DetailsContentTextView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="#dimen/dp8" />
</LinearLayout>
<LinearLayout
android:id="#+id/activity_details_news_LL_editorial"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:divider="#drawable/linear_vertical_contact_spacing"
android:orientation="vertical"
android:paddingLeft="#dimen/activity_padding"
android:paddingTop="#dimen/dp10"
android:paddingRight="#dimen/activity_padding"
android:paddingBottom="#dimen/dp10"
android:showDividers="middle">
<TextView
android:id="#+id/tvEditorial"
style="#style/AppTheme.DetailsSectionTitleTextView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="#string/editorial" />
<TextView
android:id="#+id/activity_details_news_TV_phone"
style="#style/AppTheme.DetailsContactTextView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:drawableLeft="#drawable/vertical_phone" />
<TextView
android:id="#+id/activity_details_news_TV_email"
style="#style/AppTheme.DetailsContactTextView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:drawableLeft="#drawable/vertical_message" />
</LinearLayout>
</LinearLayout>
</androidx.core.widget.NestedScrollView>
<de.hdodenhof.circleimageview.CircleImageView
android:id="#+id/activity_details_news_CIV_author_photo"
android:layout_width="#dimen/author_image_size"
android:layout_height="#dimen/author_image_size"
android:layout_marginLeft="#dimen/activity_padding"
app:layout_anchor="#id/app_bar_layout"
app:layout_anchorGravity="bottom|left"
app:layout_behavior="com.yarmobile.gminy.utils.behaviors.NewsDetailsAuthorImageBehavior" />
</androidx.coordinatorlayout.widget.CoordinatorLayout>
<include
android:id="#+id/activity_details_social_bar"
layout="#layout/activity_details_social_bar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true" />
<include
android:id="#+id/progress_wheel"
layout="#layout/blocking_progress_wheel"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</RelativeLayout>
I tried setting the margin and padding to 0 but it didn't help.
you can use RecyclerView if you have list of Images to scroll Horizontal Image

In my layout there is recyclerview and bottom navigation bar but navigation bar goes behinf the recycler view

In my layout there is recyclerview and bottom navigation bar but the problem is that the recyclerview occupies all the view and the bottom navigation bar and the header bad goes behind the recycler view. I've sucessfully implemented the material dependency.
this is the layout:
This is the code of the layout.
<?xml version="1.0" encoding="utf-8"?>
<androidx.coordinatorlayout.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:id="#+id/baseLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context=".MainActivity">
<!--status bar-->
<com.google.android.material.bottomappbar.BottomAppBar
android:id="#+id/default_activity_button"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="top"
android:backgroundTint="#color/buttoncolor"
app:menu="#menu/default_menu" />
<!--add button-->
<com.google.android.material.bottomappbar.BottomAppBar
android:id="#+id/bottomAppBar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:backgroundTint="#color/buttoncolor"
app:fabAlignmentMode="end"
app:fabCradleMargin="6.2sp"
app:fabCradleRoundedCornerRadius="15sp"
app:menu="#menu/app_bar_menu" />
<com.google.android.material.floatingactionbutton.FloatingActionButton
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:backgroundTint="#ED4444"
android:onClick="openCamera"
android:src="#drawable/ic_add"
app:layout_anchor="#id/bottomAppBar"
app:maxImageSize="35sp"
app:tint="#color/white" />
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<androidx.recyclerview.widget.RecyclerView
android:id="#+id/rw"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="#+id/empty_list" />
<LinearLayout
android:id="#+id/empty_list"
android:visibility="gone"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_vertical|center_horizontal"
android:orientation="vertical">
<ImageView
android:id="#+id/empty_list_icon"
android:layout_width="200dp"
android:layout_height="200dp"
android:background="#drawable/ic_no_data" />
<TextView
android:id="#+id/empty_list_title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textStyle="bold"
android:text="Scan the files"
android:paddingLeft="20dp"
android:paddingRight="20dp"
android:textSize="24dp"
android:gravity="center_horizontal"/>
<TextView
android:id="#+id/empty_list_message"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Scan to make something great"
android:paddingLeft="40dp"
android:paddingRight="40dp"
android:gravity="center_horizontal" />
</LinearLayout>
</RelativeLayout>
</androidx.coordinatorlayout.widget.CoordinatorLayout>
Try this by giving specific height to the BottomAppBar. Then provide margin top and Bottom to the RelativeLayout :
<?xml version="1.0" encoding="utf-8"?>
<androidx.coordinatorlayout.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:id="#+id/baseLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context=".MainActivity">
<!--status bar-->
<com.google.android.material.bottomappbar.BottomAppBar
android:id="#+id/default_activity_button"
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_gravity="top"
android:backgroundTint="#color/buttoncolor"
app:menu="#menu/default_menu" />
<!--add button-->
<com.google.android.material.bottomappbar.BottomAppBar
android:id="#+id/bottomAppBar"
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_gravity="bottom"
android:backgroundTint="#color/buttoncolor"
app:fabAlignmentMode="end"
app:fabCradleMargin="6.2sp"
app:fabCradleRoundedCornerRadius="15sp"
app:menu="#menu/app_bar_menu" />
<com.google.android.material.floatingactionbutton.FloatingActionButton
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:backgroundTint="#ED4444"
android:onClick="openCamera"
android:src="#drawable/ic_add"
app:layout_anchor="#id/bottomAppBar"
app:maxImageSize="35sp"
app:tint="#color/white" />
<RelativeLayout
android:layout_marginTop="50dp"
android:layout_marginBottom="50dp"
android:layout_width="match_parent"
android:layout_height="match_parent">
<androidx.recyclerview.widget.RecyclerView
android:id="#+id/rw"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="#+id/empty_list" />
<LinearLayout
android:id="#+id/empty_list"
android:visibility="gone"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_vertical|center_horizontal"
android:orientation="vertical">
<ImageView
android:id="#+id/empty_list_icon"
android:layout_width="200dp"
android:layout_height="200dp"
android:background="#drawable/ic_no_data" />
<TextView
android:id="#+id/empty_list_title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textStyle="bold"
android:text="Scan the files"
android:paddingLeft="20dp"
android:paddingRight="20dp"
android:textSize="24dp"
android:gravity="center_horizontal"/>
<TextView
android:id="#+id/empty_list_message"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Scan to make something great"
android:paddingLeft="40dp"
android:paddingRight="40dp"
android:gravity="center_horizontal" />
</LinearLayout>
</RelativeLayout>
</androidx.coordinatorlayout.widget.CoordinatorLayout>

FAB button not showing on a nested scrollview

I am trying show fab more button inside the nested scroll view.I have searched for many solutions but not found any solution which I can able to show fab more button in right bottom
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout 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="match_parent"
android:background="#android:color/white"
android:fitsSystemWindows="true"
android:orientation="vertical">
<android.support.design.widget.AppBarLayout
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal">
<ImageButton
android:id="#+id/bt_close"
android:layout_width="?attr/actionBarSize"
android:layout_height="?attr/actionBarSize"
android:background="?attr/selectableItemBackgroundBorderless"
android:tint="#android:color/white"
app:srcCompat="#drawable/ic_close" />
<TextView
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:gravity="center_vertical"
android:text="Filter All Order"
android:textAppearance="#style/Base.TextAppearance.AppCompat.Title"
android:textColor="#android:color/white" />
</LinearLayout>
</android.support.design.widget.AppBarLayout>
<android.support.v4.widget.NestedScrollView
android:id="#+id/nested_scroll_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scrollbars="none"
android:scrollingCache="true">
<LinearLayout
android:id="#+id/billBlock"
android:layout_width="match_parent"
android:layout_height="match_parent">
//many inner layout
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<View
android:layout_width="match_parent"
android:layout_height="1px"
android:background="#color/grey_10" />
<android.support.v7.widget.RecyclerView
android:id="#+id/print_payment_list"
android:layout_margin="10dp"
android:background="#color/grey_20"
android:layout_width="match_parent"
android:layout_height="wrap_content">
</android.support.v7.widget.RecyclerView>
</LinearLayout>
</LinearLayout>
</android.support.v4.widget.NestedScrollView>
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout
android:id="#+id/fabFrame"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="?attr/actionBarSize"
android:paddingBottom="#dimen/activity_vertical_margin"
android:paddingLeft="#dimen/activity_horizontal_margin"
android:paddingRight="#dimen/activity_horizontal_margin"
android:paddingTop="#dimen/activity_vertical_margin"
android:orientation="vertical">
<android.support.design.widget.FloatingActionButton
android:id="#+id/fab_mic"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="#dimen/spacing_middle"
android:clickable="true"
android:tint="#color/grey_80"
app:backgroundTint="#color/grey_20"
app:fabSize="mini"
app:rippleColor="#android:color/white"
app:srcCompat="#drawable/ic_mic" />
<android.support.design.widget.FloatingActionButton
android:id="#+id/fab_call"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="#dimen/spacing_middle"
android:clickable="true"
android:tint="#color/grey_80"
app:backgroundTint="#color/grey_20"
app:fabSize="mini"
app:rippleColor="#android:color/white"
app:srcCompat="#drawable/ic_photo_camera" />
<android.support.design.widget.FloatingActionButton
android:id="#+id/fab_add"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="#dimen/spacing_smlarge"
android:layout_marginLeft="#dimen/spacing_smlarge"
android:layout_marginRight="#dimen/spacing_smlarge"
android:layout_marginTop="#dimen/spacing_middle"
android:clickable="true"
android:tint="#android:color/white"
app:fabSize="normal"
app:rippleColor="#android:color/white"
app:srcCompat="#drawable/ic_add" />
<!--android:src="#drawable/ic_close_black_24dp"-->
</FrameLayout>
</LinearLayout>
I have multiple views inside one parent of nested scroll view .scroll and all working fine .only issue is fab is not positioned in a bottom right position
can anyone help me how I can achieve this? since am new to android.T hanks
i need fab bar to be placed like this .This is sample image from google
try this one
<?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="match_parent"
android:background="#android:color/white"
android:fitsSystemWindows="true"
android:orientation="vertical">
<android.support.design.widget.AppBarLayout
android:id="#+id/app"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal">
<ImageButton
android:id="#+id/bt_close"
android:layout_width="?attr/actionBarSize"
android:layout_height="?attr/actionBarSize"
android:background="?attr/selectableItemBackgroundBorderless"
android:tint="#android:color/white"
app:srcCompat="#drawable/ic_close" />
<TextView
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:gravity="center_vertical"
android:text="Filter All Order"
android:textAppearance="#style/Base.TextAppearance.AppCompat.Title"
android:textColor="#android:color/white" />
</LinearLayout>
</android.support.design.widget.AppBarLayout>
<android.support.v4.widget.NestedScrollView
android:id="#+id/nested_scroll_view"
android:layout_width="match_parent"
android:layout_below="#id/app"
android:layout_above="#+id/fabFrame"
android:layout_height="match_parent"
android:scrollbars="none"
android:scrollingCache="true">
<LinearLayout
android:id="#+id/billBlock"
android:layout_width="match_parent"
android:layout_height="match_parent">
//many inner layout
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<View
android:layout_width="match_parent"
android:layout_height="1px"
android:background="#color/grey_10" />
<android.support.v7.widget.RecyclerView
android:id="#+id/print_payment_list"
android:layout_margin="10dp"
android:background="#color/grey_20"
android:layout_width="match_parent"
android:layout_height="wrap_content">
</android.support.v7.widget.RecyclerView>
</LinearLayout>
</LinearLayout>
</android.support.v4.widget.NestedScrollView>
<FrameLayout
android:id="#+id/fabFrame"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_marginTop="?attr/actionBarSize"
android:paddingBottom="#dimen/activity_vertical_margin"
android:paddingLeft="#dimen/activity_horizontal_margin"
android:paddingRight="#dimen/activity_horizontal_margin"
android:paddingTop="#dimen/activity_vertical_margin"
android:orientation="vertical">
<android.support.design.widget.FloatingActionButton
android:id="#+id/fab_mic"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="#dimen/spacing_middle"
android:clickable="true"
android:tint="#color/grey_80"
app:backgroundTint="#color/grey_20"
app:fabSize="mini"
app:rippleColor="#android:color/white"
app:srcCompat="#drawable/ic_mic" />
<android.support.design.widget.FloatingActionButton
android:id="#+id/fab_call"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="#dimen/spacing_middle"
android:clickable="true"
android:tint="#color/grey_80"
app:backgroundTint="#color/grey_20"
app:fabSize="mini"
app:rippleColor="#android:color/white"
app:srcCompat="#drawable/ic_photo_camera" />
<android.support.design.widget.FloatingActionButton
android:id="#+id/fab_add"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="#dimen/spacing_smlarge"
android:layout_marginLeft="#dimen/spacing_smlarge"
android:layout_marginRight="#dimen/spacing_smlarge"
android:layout_marginTop="#dimen/spacing_middle"
android:clickable="true"
android:tint="#android:color/white"
app:fabSize="normal"
app:rippleColor="#android:color/white"
app:srcCompat="#drawable/ic_add" />
<!--android:src="#drawable/ic_close_black_24dp"-->
</FrameLayout>
</RelativeLayout>
Always used linear layout for continuous Views and use Framelayout or Relative Layout when you what to show something position like right or bottom.

How do I remove divider between AppBarLayout and ViewPager?

I am new to Stackoverflow so please be gentle to me.
I tried removing it by setting the elevation of some views to 0dp but it did not help. Please check the screenshot and help me find a solution to this problem.
Here is a screenshot of the App:
I have highlighted divider which I want to remove.
XML file:
<?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"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
tools:openDrawer="start">
<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:id="#+id/main_content"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
tools:context="com.syedsauban.mjforums.launching">
<android.support.design.widget.AppBarLayout
android:id="#+id/appbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:elevation="0dp">
<android.support.v7.widget.Toolbar
android:id="#+id/toolbar"
android:layout_width="match_parent"
android:layout_height="67dp"
android:background="#F3F5F8"
app:layout_scrollFlags="scroll|enterAlways">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<ImageView
android:id="#+id/nav_menu_icon"
android:layout_width="28dp"
android:layout_height="28dp"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_alignParentTop="true"
android:layout_marginEnd="10dp"
android:layout_marginLeft="4dp"
android:layout_marginRight="10dp"
android:layout_marginStart="4dp"
android:layout_marginTop="18dp"
app:srcCompat="#drawable/menu_icon" />
<ImageView
android:layout_width="243dp"
android:layout_height="77dp"
android:layout_centerHorizontal="true"
android:layout_marginLeft="8dp"
android:layout_toRightOf="#id/nav_menu_icon"
android:src="#drawable/mjcet_forums_header" />
</RelativeLayout>
</android.support.v7.widget.Toolbar>
<com.syedsauban.mjforums.CustomTabLayout
android:id="#+id/tabs"
style="#style/MyTabLayout"
fontPath="font/weblysleekuil.ttf"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="2dp"
android:background="#drawable/tab"
android:elevation="0dp"
app:tabIndicatorColor="#80c7ff"
app:tabIndicatorHeight="3dp"
app:tabSelectedTextColor="#1D1D1D"
app:tabTextColor="#95989A"
tools:ignore="MissingPrefix" />
<android.support.v7.widget.CardView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="6dp"
android:background="#FFFFFFFF"
android:elevation="0dp"
app:cardCornerRadius="14dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<de.hdodenhof.circleimageview.CircleImageView
android:layout_width="60dp"
android:layout_height="60dp"
android:layout_gravity="center_vertical"
android:layout_marginLeft="6dp"
android:layout_weight="1"
android:src="#drawable/dp1"
app:civ_border_color="#80c7ff"
app:civ_border_width="2dp" />
<android.support.v7.widget.AppCompatEditText
android:layout_width="0px"
android:layout_height="70dp"
android:layout_margin="6dp"
android:layout_marginRight="10dp"
android:layout_weight="10"
android:backgroundTint="#80c7ff"
android:gravity="top"
android:hint="Hey user, feel free to ask!"
android:paddingTop="6dp"
android:textColorHint="#666666"
android:textSize="16sp" />
<View
android:layout_width="2dp"
android:layout_height="match_parent"
android:layout_marginBottom="8dp"
android:layout_marginTop="8dp"
android:background="#dde2e4" />
<ImageView
android:layout_width="30dp"
android:layout_height="30dp"
android:layout_gravity="center_vertical"
android:layout_weight="1"
android:src="#drawable/bell" />
</LinearLayout>
</android.support.v7.widget.CardView>
</android.support.design.widget.AppBarLayout>
<android.support.v4.view.ViewPager
android:id="#+id/container"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="#string/appbar_scrolling_view_behavior" />
</android.support.design.widget.CoordinatorLayout>
<android.support.design.widget.NavigationView
android:id="#+id/navigation_view"
android:layout_width="200dp"
android:layout_height="match_parent"
android:layout_gravity="start"
app:headerLayout="#layout/nav_header"
app:itemBackground="#color/secoond"
app:itemTextColor="#color/first"
app:menu="#menu/menu_navigation" />
</android.support.v4.widget.DrawerLayout>

AppbarLayout with Toolbar, Navigation Drawer, and tabs

I'm developing an app that has a Main Activity and a Navigation Drawer to switch between different fragments inside the Main Activity.
One of the fragments contains a tab layout.
My layouts are a mess and they don't behave or perform properly.
Here is my XML:
Main:
<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:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="right"
android:fitsSystemWindows="true"
android:clickable="true"
android:layoutDirection="rtl"
android:id="#+id/drawer_layout">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layoutDirection="rtl"
android:background="#EEEEEE"
android:clickable="true">
<include
android:id="#+id/toolbar"
android:gravity="right"
layout="#layout/toolbar"
android:clickable="true" />
<FrameLayout
android:id="#+id/content_frame"
android:layout_below="#id/toolbar"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:clickable="true" />
<android.support.design.widget.FloatingActionButton
android:id="#+id/mainFab"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:layout_gravity="bottom|end"
android:layout_marginLeft="16dp"
android:layout_marginBottom="16dp"
android:layout_marginTop="5dp"
android:elevation="8dp"
app:pressedTranslationZ="12dp"
app:backgroundTint="?android:colorAccent"
android:src="#drawable/ic_perm_phone_msg_white_24px" />
<LinearLayout
android:id="#+id/miniFabFrame"
android:orientation="vertical"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:visibility="invisible"
android:layout_alignParentLeft="true"
android:layout_gravity="bottom|end"
android:layout_marginLeft="20dp"
android:layout_above="#id/mainFab"
android:padding="0dp">
<android.support.design.widget.FloatingActionButton
android:id="#+id/messageFab"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:elevation="8dp"
android:layout_marginTop="5dp"
android:layout_marginRight="0dp"
android:layout_marginBottom="5dp"
android:layout_marginLeft="5dp"
app:pressedTranslationZ="12dp"
app:backgroundTint="?android:colorPrimary"
app:fabSize="mini"
android:src="#drawable/ic_textSMS_white_24px" />
<android.support.design.widget.FloatingActionButton
android:id="#+id/callFab"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:layout_marginTop="5dp"
android:layout_marginRight="0dp"
android:layout_marginBottom="5dp"
android:layout_marginLeft="5dp"
android:elevation="8dp"
app:pressedTranslationZ="12dp"
app:backgroundTint="?android:colorPrimary"
app:fabSize="mini"
android:src="#drawable/ic_call_white_24px" />
</LinearLayout>
</RelativeLayout>
<android.support.design.widget.NavigationView
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="right"
android:id="#+id/nav_view"
android:layoutDirection="rtl"
app:headerLayout="#layout/header"
app:menu="#menu/nav_menu" />
</android.support.v4.widget.DrawerLayout>
Tabs Fragment:
<LinearLayout 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:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:fitsSystemWindows="true"
android:id="#+id/halachot_layout"
android:layoutDirection="ltr">
<android.support.design.widget.AppBarLayout
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:theme="#style/ThemeOverlay.AppCompat.Dark.ActionBar">
<com.refractored.PagerSlidingTabStrip
android:id="#+id/halachotTabs"
android:layout_below="#id/halachot_layout"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="?attr/colorPrimary"
android:fitsSystemWindows="true"
pstsPaddingMiddle="false"
app:pstsShouldExpand="true" />
</android.support.design.widget.AppBarLayout>
<android.support.v4.view.ViewPager
android:id="#+id/halachotPager"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1" />
</LinearLayout>
I want to use Coordinator Layout in my Main layout, and use AppBarLayout to wrap the Toolbar, although I don't know how to use them.
If someone could please help me organize my layout properly, with some explanations of how this works and what I am doing wrong, I would appreciate it very very much.
Thanks!
Firstly create an activity layout which contains Navigation Drawer and ToolBar
<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.support.design.widget.CoordinatorLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true">
<android.support.design.widget.AppBarLayout
android:id="#+id/app_bar"
android:layout_width="match_parent"
android:layout_height="#dimen/app_bar_height"
android:background="#drawable/ab_bg2"
android:fitsSystemWindows="true"
android:theme="#style/AppTheme.AppBarOverlay">
<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:expandedTitleTextAppearance="#style/Base.TextAppearance.AppCompat.Subhead"
app:layout_scrollFlags="scroll|exitUntilCollapsed"
app:expandedTitleMarginBottom="40dp">
<android.support.v7.widget.Toolbar
android:id="#+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
app:layout_collapseMode="pin"
app:popupTheme="#style/AppTheme.PopupOverlay"
app:contentInsetStart="0dp"/>
</android.support.design.widget.CollapsingToolbarLayout>
</android.support.design.widget.AppBarLayout>
<!-- Framelayout to display Fragments -->
<FrameLayout
android:id="#+id/frame_container"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginBottom="5dp"
android:layout_marginRight="3dp"
android:layout_marginTop="5dp"
android:background="#drawable/linlayoutshape_shadow"
android:tag="#string/layout_default"/>
</android.support.design.widget.CoordinatorLayout>
<ListView
android:id="#+id/list_slidermenu"
android:layout_width="250dp"
android:layout_height="match_parent"
android:layout_gravity="right"
android:background="#color/Drawer_bg"
android:choiceMode="singleChoice"
android:divider="#color/Drawer_bg"
android:dividerHeight="10dp"
android:listSelector="#drawable/list_selector"
android:paddingLeft="10dp"
android:paddingRight="10dp"
android:paddingTop="10dp" />
Now create a Fragment which will show your Tab layout
<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">
<com.utils.PagerSlidingTabStrip
android:id="#+id/tabs"
android:layout_width="match_parent"
android:layout_height="45dp"
android:background="#drawable/background_tab"
app:pstsShouldExpand="true" />
<com.utils.CustomViewPager
android:id="#+id/pager"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="#+id/linHeader"
android:background="#drawable/background_tab"
tools:context=".TestBoardActivity" />
</RelativeLayout>

Categories