Bottom Sheet with fab partly outside the borders - android

I'm trying to implement bottom sheet that will overlap exactly a view not a
whole screen. Desirable
.
But here is actual result
end position
.
What I'm doing wrong?
Here is the code. I want to overlap Textview with id content_to_overlap.
<TextView
android:id="#+id/btn1"
android:layout_width="match_parent"
android:layout_height="48dp"
android:background="#399"
android:layout_marginBottom="4dp"
android:clipChildren="false"
android:clipToPadding="false"
android:gravity="center"
android:text="Text1" />
<TextView
android:id="#+id/btn2"
android:layout_width="match_parent"
android:layout_height="48dp"
android:layout_below="#+id/btn1"
android:background="#399"
android:clipChildren="false"
android:layout_marginBottom="4dp"
android:clipToPadding="false"
android:gravity="center"
android:text="Text2Text2Text2Text2" />
<android.support.design.widget.CoordinatorLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="#+id/btn2"
android:clipChildren="false"
android:clipToPadding="false">
<TextView
android:id="#+id/content_to_overlap"
android:layout_width="match_parent"
android:layout_height="64dp"
android:background="#B44"
android:gravity="center"
android:text="Text3" />
<FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginLeft="24dp"
android:clipChildren="false"
android:clipToPadding="false"
app:behavior_peekHeight="48dp"
app:layout_behavior="android.support.design.widget.BottomSheetBehavior"
android:background="#8FF0"
>
<android.support.design.widget.FloatingActionButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginTop="-48dp" />
</FrameLayout>
</android.support.design.widget.CoordinatorLayout>

Code Below is not perfect but is provided to give you an idea
Use anchor for fab
<android.support.design.widget.CoordinatorLayout
android:layout_width="match_parent"
android:layout_height="match_parent"/>
<TextView
android:id="#+id/btn1"
android:layout_width="match_parent"
android:layout_height="48dp"
android:background="#399"
android:layout_marginBottom="4dp"
android:clipChildren="false"
android:clipToPadding="false"
android:gravity="center"
android:text="Text1" />
<TextView
android:id="#+id/btn2"
android:layout_width="match_parent"
android:layout_height="48dp"
android:layout_below="#+id/btn1"
android:background="#399"
android:clipChildren="false"
android:layout_marginBottom="4dp"
android:clipToPadding="false"
android:gravity="center"
android:text="Text2Text2Text2Text2" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="#+id/btn2"
android:clipChildren="false"
android:clipToPadding="false">
<TextView
android:id="#+id/content_to_overlap"
android:layout_width="match_parent"
android:layout_height="64dp"
android:background="#B44"
app:behavior_peekHeight="48dp"
app:layout_behavior="android.support.design.widget.BottomSheetBehavior"
android:background="#8FF0"
android:gravity="center"
android:text="Text3" />
<android.support.design.widget.FloatingActionButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:anchor="#id/content_to_overlap" />
</android.support.design.widget.CoordinatorLayout>

Related

Toolbar on top with weightSum

I have a view with a title bar above (RelativeLayout) and below a LinearLayout with weightSum.
I used the weightSum because I wanted to distribute the three elements (ImageView, TextView, Button ) 100% contained in the page.
Everything works fine, but when I go to write something from the textview the keyboard appears and the bar disappears from the view because it drags over.
I tried various systems to try to insert the scoolview and keep the bar fixed at the top.
I used both the scrollview and the NestedScrollView and I also changed the bar created with the RelativeLayout to a toolbar.
but the content of the LinearLayout with the weightSum stretches a lot.
do you have any suggestion for me?
thank you
<?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:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#color/fond"
android:fillViewport="true"
tools:context=".client.FicheClient">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="fill_parent"
android:orientation="vertical">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="48dp"
android:layout_gravity="center|top"
android:gravity="center|top">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="48dp"
android:background="#color/surface_l"
android:orientation="horizontal"
android:paddingLeft="56dp"
android:paddingRight="56dp">
<TextView
android:id="#+id/txtNomFichier"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="12dp"
android:ellipsize="end"
android:fontFamily="#font/inter_bold_700t"
android:gravity="center_horizontal"
android:maxLines="1"
android:text="#string/label_document"
android:textColor="#color/white"
android:textSize="14sp" />
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:onClick="backList"
android:paddingStart="16dp"
android:paddingTop="12dp"
android:paddingEnd="16dp"
android:paddingBottom="12dp">
<ImageView
android:id="#+id/btn_Back"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:srcCompat="#drawable/icone_arrow_left_blanc" />
</LinearLayout>
<Button
android:id="#+id/btn_share"
android:layout_width="24dp"
android:layout_height="24dp"
android:layout_alignParentEnd="true"
android:layout_marginTop="12dp"
android:layout_marginEnd="16dp"
android:background="#drawable/fond_partage"
android:fontFamily="#font/inter_regular_400t"
android:onClick="launchPartage"
android:text=""
android:textColor="#color/blanc"
android:visibility="invisible" />
<ProgressBar
android:id="#+id/progressBarTop"
style="?android:attr/progressBarStyle"
android:layout_width="24dp"
android:layout_height="24dp"
android:layout_alignParentEnd="true"
android:layout_marginTop="12dp"
android:layout_marginEnd="16dp"
android:theme="#style/colorProgressBarTop" />
</RelativeLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:weightSum="100">
<LinearLayout
android:layout_margin="16dp"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="77"
android:background="#drawable/radius_gris"
android:orientation="vertical">
<ImageView
android:layout_gravity="center_horizontal|center_vertical"
android:id="#+id/imageView"
android:layout_width="match_parent"
android:layout_height="match_parent" />
<com.github.barteksc.pdfviewer.PDFView
android:layout_gravity="center_horizontal|center_vertical"
android:id="#+id/pdfView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:visibility="gone" />
</LinearLayout>
<LinearLayout
android:layout_weight="11"
android:layout_marginRight="16dp"
android:layout_marginLeft="16dp"
android:layout_marginBottom="16dp"
android:padding="12sp"
android:background="#drawable/radius_blanc"
android:layout_width="match_parent"
android:layout_height="0dp"
android:gravity="center_vertical"
android:orientation="vertical">
<TextView
android:id="#+id/txtLibelleNomFichier"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:fontFamily="#font/inter_regular_400t"
android:gravity="left|center_vertical"
android:text="#string/label_file_name_obligatoire"
android:textColor="#color/surface_h"
android:textSize="12sp" />
<EditText
android:id="#+id/txtNom"
android:layout_width="match_parent"
android:layout_height="18dp"
android:background="#drawable/textedit_blanc_rounded_corners"
android:textColor="#color/surface_k"
android:ellipsize="end"
android:textSize="12sp"
android:fontFamily="#font/inter_semi_bold_600t"
android:gravity="left|center_vertical"
android:inputType="text"
android:maxLines="1"
android:layout_marginTop="2dp"
android:scrollHorizontally="true" />
</LinearLayout>
<LinearLayout
android:background="#color/blanc"
android:layout_weight="12"
android:layout_width="match_parent"
android:layout_height="0dp"
android:gravity="center"
android:orientation="vertical">
<Button
android:id="#+id/btn_upload"
android:layout_width="match_parent"
android:layout_height="39dp"
android:layout_columnWeight="1"
android:layout_margin="16dp"
android:textAllCaps="false"
android:background="#drawable/radius_primary_5"
android:text="#string/btn_validate"
android:textColor="#color/blanc" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
</androidx.coordinatorlayout.widget.CoordinatorLayout>

Element LinearLayout is not allowed here - inside RelativeLayout

I keep getting an error that my LinearLayout isn't allowed in my RelativeLayout object.
I am trying to create a multi-filter search bar. This LinearLayout is meant to hold different elements in the search bar. Here is my code:
<RelativeLayout 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="match_parent"
android:background="#FFFFFF">
<androidx.appcompat.widget.Toolbar
android:id="#+id/toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#212121"
android:minHeight="?attr/actionBarSize">
<TextView
android:id="#+id/toolbar_title"
style="#style/TextAppearance.AppCompat.Widget.ActionBar.Title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="#string/app_name"
android:textColor="#FFF" />
</androidx.appcompat.widget.Toolbar>
<RelativeLayout
android:id="#+id/view_search"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#50000000"
android:clickable="true"
android:visibility="invisible">
<ProgressBar
android:id="#+id/marker_progress"
style="?android:attr/progressBarStyle"
android:layout_width="50dp"
android:layout_height="50dp"
android:layout_centerInParent="true"
android:indeterminate="true"
android:visibility="gone" />
</RelativeLayout>
<ListView
android:id="#+id/listContainer"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#fff"
android:clipToPadding="false"
android:divider="#fff"
android:paddingTop="56dp"
android:visibility="gone" />
<androidx.appcompat.widget.CardView
android:id="#+id/card_search"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="4dp"
android:visibility="invisible"
card_view:cardCornerRadius="2dp">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<LinearLayout
android:id="#+id/linearLayout_search"
android:layout_width="match_parent"
android:layout_height="48dp">
<ImageView
android:id="#+id/image_search_back"
android:layout_width="48dp"
android:layout_height="48dp"
android:background="?android:attr/selectableItemBackground"
android:clickable="true"
android:padding="12dp"
android:src="#mipmap/ic_arrow_back" />
<EditText
android:id="#+id/edit_text_search"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="#fff"
android:focusable="true"
android:gravity="center_vertical"
android:hint="#string/search_restaurants_and_cuisines"
android:imeOptions="actionSearch"
android:inputType="textCapWords"
android:maxLines="1"
android:paddingLeft="12dp"
android:paddingRight="8dp" />
</LinearLayout>
<View
android:id="#+id/line_divider"
android:layout_width="match_parent"
android:layout_height=".5dp"
android:layout_below="#+id/linearLayout_search"
android:background="#eee" />
<androidx.recyclerview.widget.RecyclerView
android:id="#+id/recyclerView"
android:layout_width="match_parent"
android:layout_height="250dp"
android:layout_below="#+id/line_divider"
android:divider="#FFFFFF" />
</RelativeLayout>
</androidx.appcompat.widget.CardView>
<TextView
android:id="#+id/txtNoResultsFound"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:gravity="center"
android:padding="#dimen/activity_horizontal_margin"
android:text="#string/no_results_found" />
<ListView
android:id="#+id/listView"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_below="#+id/toolbar"
android:layout_marginBottom="#dimen/corners_small_value"
android:layout_marginLeft="#dimen/corners_small_value"
android:layout_marginRight="#dimen/corners_small_value">
</ListView>
<View
android:id="#+id/toolbar_shadow"
android:layout_width="match_parent"
android:layout_height="4dp"
android:layout_below="#+id/toolbar"
android:background="#drawable/toolbar_shadow" />
</RelativeLayout>
Why is this happening? I made sure it is in the updated androidx CardView, so not sure why LinearLayout is still not allowed to be in the RelativeLayout inside CardView.
It looks like you have a typo in your CardView tag:
<androidx.appcompat.widget.CardView
That should look like this instead:
<androidx.cardview.widget.CardView ...
(Replace .appcompat. with .cardview.).

AppBarLayout leaves previous expanded view spacing after fragment change

I have the following layout :
<?xml version="1.0" encoding="utf-8"?>
<nl.psdcompany.duonavigationdrawer.views.DuoDrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="#+id/drawer_layout_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:contentScaleOpen="0.87"
app:marginFactor="0.7">
<nl.psdcompany.duonavigationdrawer.views.DuoMenuView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="#+id/drawer_menu_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:tag="#string/tag_menu"
app:footer="#layout/drawer_footer"
app:header="#layout/drawer_header" />
<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/main_content"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:tag="#string/tag_content"
android:translationZ="8dp">
<include layout="#layout/layout_toolbar" />
<FrameLayout
android:id="#+id/main_container"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#color/white"
app:layout_behavior="#string/appbar_scrolling_view_behavior"/>
</android.support.design.widget.CoordinatorLayout>
</nl.psdcompany.duonavigationdrawer.views.DuoDrawerLayout>
The include layout is
<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.AppBarLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="#+id/appbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:elevation="0dp">
<android.support.design.widget.CollapsingToolbarLayout
android:id="#+id/collapsing_toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:translationZ="4dp"
app:contentScrim="#color/colorPrimary"
app:layout_scrollFlags="exitUntilCollapsed|snap"
app:scrimAnimationDuration="250">
<!--
Toolbar Collapsing Layout
-->
<LinearLayout
android:id="#+id/collapsing_container"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="16dp"
android:layout_marginEnd="32dp"
android:layout_marginStart="32dp"
android:layout_marginTop="56dp"
android:orientation="vertical"
android:visibility="visible"
app:layout_collapseMode="parallax">
<TextView
android:id="#+id/collapsing_toolbar_title"
fontPath="#string/font_sf_ui_display_black"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ellipsize="end"
android:textColor="#color/white"
android:textSize="24sp"
android:visibility="visible" />
<TextView
android:id="#+id/collapsing_toolbar_secondary_title"
fontPath="#string/font_sf_ui_display_regular"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="-3dp"
android:textColor="#color/dark_red"
android:textSize="#dimen/text_small"
android:visibility="visible" />
</LinearLayout>
<android.support.v7.widget.Toolbar
android:id="#+id/toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#color/transparent"
app:contentInsetEnd="0dp"
app:contentInsetLeft="0dp"
app:contentInsetRight="0dp"
app:contentInsetStart="0dp"
app:layout_collapseMode="pin">
<RelativeLayout
android:id="#+id/toolbar_container"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:paddingEnd="#dimen/margin_medium"
android:paddingStart="#dimen/margin_medium">
<!--
Toolbar TOP Layout
-->
<RelativeLayout
android:id="#+id/toolbar_top_container"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:minHeight="?attr/actionBarSize">
<RelativeLayout
android:id="#+id/default_toolbar_container"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:orientation="horizontal"
android:visibility="visible">
<!-- Starting icons container -->
<FrameLayout
android:id="#+id/toolbar_left_icon_container"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentStart="true"
android:layout_centerVertical="true"
android:layout_gravity="center"
android:layout_marginEnd="#dimen/margin_small">
<ImageView
android:id="#+id/toolbar_hamburger"
android:layout_width="#dimen/toolbar_icon_size"
android:layout_height="#dimen/toolbar_icon_size"
android:layout_gravity="center"
android:tint="#color/white"
android:visibility="gone"
app:srcCompat="#drawable/ic_burger_menu_white" />
<ImageView
android:id="#+id/toolbar_start_icon"
android:layout_width="#dimen/toolbar_icon_size"
android:layout_height="#dimen/toolbar_icon_size"
android:layout_gravity="center"
android:tint="#android:color/white"
android:visibility="gone"
app:srcCompat="#drawable/ic_back_button_white" />
<TextView
android:id="#+id/toolbar_start_text_icon"
fontPath="#string/font_sf_ui_display_bold"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="Cancel"
android:textColor="#color/dark_red"
android:textSize="#dimen/text_medium"
android:visibility="gone"
app:srcCompat="#drawable/ic_back_button_white" />
</FrameLayout>
<!-- Step Progress Bar -->
<FrameLayout
android:id="#+id/progress_bar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_toEndOf="#id/toolbar_left_icon_container"
android:visibility="gone"/>
<!-- Main title centered in the toolbar -->
<LinearLayout
android:id="#+id/toolbar_title_container"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:gravity="center"
android:orientation="vertical">
<TextView
android:id="#+id/toolbar_main_title"
fontPath="#string/font_sf_ui_display_black"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:ellipsize="end"
android:maxLines="1"
android:text="View Offer"
android:textAllCaps="true"
android:textColor="#color/white"
android:textSize="15sp"
android:visibility="gone" />
<TextView
android:id="#+id/toolbar_secondary_title"
fontPath="#string/font_sf_ui_display_regular"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="-3dp"
android:text="last visit on 15-03"
android:textColor="#color/dark_red"
android:textSize="#dimen/text_small"
android:visibility="gone" />
</LinearLayout>
<!-- Secondary end icon -->
<ImageView
android:id="#+id/toolbar_secondary_end_icon"
android:layout_width="#dimen/toolbar_icon_size"
android:layout_height="#dimen/toolbar_icon_size"
android:layout_centerVertical="true"
android:layout_gravity="center"
android:layout_marginEnd="#dimen/margin_small"
android:layout_toStartOf="#+id/toolbar_end_icon_container"
android:visibility="gone"
app:srcCompat="#drawable/ic_share_white" />
<!-- Primary end icon container-->
<FrameLayout
android:id="#+id/toolbar_end_icon_container"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_centerVertical="true">
<ImageView
android:id="#+id/toolbar_primary_end_icon"
android:layout_width="#dimen/toolbar_icon_size"
android:layout_height="#dimen/toolbar_icon_size"
android:layout_gravity="center"
android:visibility="gone"
app:srcCompat="#drawable/ic_share_white" />
<!-- Badge counter container -->
<FrameLayout
android:id="#+id/toolbar_badge_counter_container"
android:layout_width="28dp"
android:layout_height="28dp"
android:visibility="gone">
<ImageView
android:id="#+id/toolbar_badge_icon"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="center"
android:padding="4dp"
android:visibility="gone"
app:srcCompat="#drawable/ic_bell_notifications" />
<TextView
android:id="#+id/toolbar_badge_counter"
fontPath="#string/font_sf_ui_display_medium"
android:layout_width="15dp"
android:layout_height="15dp"
android:layout_gravity="end"
android:background="#drawable/circle_blue"
android:gravity="center"
android:text="3"
android:textColor="#color/white"
android:textSize="9sp"
android:visibility="gone" />
</FrameLayout>
<TextView
android:id="#+id/toolbar_right_text_icon"
fontPath="#string/font_sf_ui_display_bold"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#color/dark_red"
android:textSize="#dimen/text_medium"
android:visibility="gone" />
</FrameLayout>
<Button
android:id="#+id/change_postal_code_button"
android:layout_width="wrap_content"
android:visibility="gone"
android:layout_height="wrap_content"
android:layout_marginRight="#dimen/margin_small"
android:layout_toLeftOf="#+id/toolbar_end_icon_container"
android:background="#drawable/rounded_background_blue"
android:drawablePadding="#dimen/margin_small"
android:drawableStart="#drawable/ic_navigation_white"
android:minHeight="0dp"
android:paddingBottom="#dimen/margin_small"
android:paddingLeft="#dimen/margin_small_medium"
android:paddingRight="#dimen/margin_small_medium"
android:paddingTop="#dimen/margin_small"
android:text="1234 AA, Amsterdam"
android:textAllCaps="false"
android:textColor="#color/white" />
</RelativeLayout>
</RelativeLayout>
<!--
Toolbar BOTTOM Layout
-->
<LinearLayout
android:id="#+id/toolbar_bottom_container"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/toolbar_top_container"
android:orientation="vertical"
android:paddingBottom="#dimen/margin_medium"
android:visibility="gone">
<TextView
android:id="#+id/toolbar_bottom_title"
fontPath="#string/font_sf_ui_display_black"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ellipsize="end"
android:text="View Offer"
android:textColor="#color/white"
android:textSize="24sp"
android:visibility="gone" />
<TextView
android:id="#+id/toolbar_bottom_secondary_title"
fontPath="#string/font_sf_ui_display_regular"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="-3dp"
android:text="last visit on 15-04"
android:textColor="#color/dark_red"
android:textSize="#dimen/text_small"
android:visibility="gone" />
<include
android:id="#+id/search_toolbar"
layout="#layout/layout_search_offers" />
</LinearLayout>
</RelativeLayout>
</android.support.v7.widget.Toolbar>
</android.support.design.widget.CollapsingToolbarLayout>
</android.support.design.widget.AppBarLayout>
It consists of an AppBarLayout with an CollapsingToolbarLayout which has as the first child a Linear that's acting as the collapse layout and a Toolbar layout which holds the top bar and a static bottom one when I need a bottom non collapsing toolbar.
The collapsing works great, I can set my ToolBar to have only the top layout or only the bottom but when I change the visibility of items to Gone the AppBarLayout(or the CollapsingToolbarLayout) doesn't resize and keeps the spacing.
Example image :
After fragment change (I set views to Gone to reset the layouts)
Thank you for your time;

how to align a view below centered in parent view in a relative layout

I want to align a Framelayout below a view which has centerInParent attribute set to true in a relative layout. I've tried layout_below but it doesn't work. then I tried to remove centerInParent and tried center_horizontal and center_vertical but it doesn't help also, the FrameLayout still stuck to the top of the layout.
Here is my layout code:
<android.support.percent.PercentRelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="?actionBarSize"
android:layout_marginTop="?actionBarSize"
android:background="#android:color/transparent">
<ImageView
android:id="#+id/backdrop"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#android:color/white"
android:fitsSystemWindows="true"
android:scaleType="centerCrop"
app:layout_collapseMode="parallax"
app:layout_collapseParallaxMultiplier="0"
tools:src="#drawable/car_engine" />
<View
android:id="#+id/center_point"
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:background="#color/g" />
<View
android:id="#+id/tab_scrim"
android:layout_width="match_parent"
android:layout_height="#dimen/gradiant_height"
android:layout_alignParentBottom="true"
android:background="#drawable/tab_scrim"
app:layout_heightPercent="40%" />
<FrameLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#id/center_point">
<TextView
android:id="#+id/car_title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingBottom="5dp"
android:paddingTop="2dp"
android:textAlignment="center"
android:textColor="#color/w"
android:textSize="20sp"
android:textStyle="bold"
tools:text="#string/car_header_text" />
<TextView
android:id="#+id/car_subtitle"
style="#style/TitleWhite"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#id/car_title"
android:paddingBottom="4dp"
android:paddingTop="4dp"
android:text="#string/car_sub_header"
android:textAlignment="center" />
</FrameLayout>
</android.support.percent.PercentRelativeLayout>
Set your PercentRelativeLayout height to match_parent.
<android.support.percent.PercentRelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginBottom="?actionBarSize"
android:layout_marginTop="?actionBarSize"
android:background="#android:color/transparent">
Please try this.
<FrameLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:ali="#id/center_point">
<TextView
android:id="#+id/car_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingBottom="5dp"
android:paddingTop="2dp"
android:textAlignment="center"
android:textColor="#color/w"
android:textSize="20sp"
android:textStyle="bold"
tools:text="#string/car_header_text" />
<TextView
android:id="#+id/car_subtitle"
style="#style/TitleWhite"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#id/car_title"
android:paddingBottom="4dp"
android:paddingTop="4dp"
android:text="#string/car_sub_header"
android:textAlignment="center" />
</FrameLayout>
Please check if you wrongly uses android:ali
<FrameLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#id/center_point">
And your PercentRelativeLayout height must be fixed or match_parent
Here is my code
<?xml version="1.0" encoding="utf-8"?>
<ImageView
android:id="#+id/backdrop"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#android:color/white"
android:fitsSystemWindows="true"
android:scaleType="centerCrop"
app:layout_collapseMode="parallax"
app:layout_collapseParallaxMultiplier="0"
tools:src="#mipmap/ic_launcher" />
<View
android:id="#+id/tab_scrim"
android:layout_width="match_parent"
android:layout_height="2dp"
android:layout_alignParentBottom="true"
android:background="#android:color/black"
app:layout_heightPercent="40%" />
<FrameLayout
android:layout_width="match_parent"
android:layout_height="100dp"
android:background="#android:color/holo_red_dark"
android:layout_centerVertical="true">
<TextView
android:id="#+id/car_title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingBottom="5dp"
android:paddingTop="2dp"
android:textAlignment="center"
android:textColor="#android:color/black"
android:textSize="20sp"
android:textStyle="bold"
android:text="car carcar"
android:layout_gravity="left"/>
<TextView
android:id="#+id/car_subtitle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#id/car_title"
android:paddingBottom="4dp"
android:paddingTop="4dp"
android:text="car header subtitle"
android:textAlignment="center"
android:layout_gravity="bottom"/>
</FrameLayout>
and screen shot

Navigation drawer Layout doesn't take full height even though specified

I would like my button to be at the bottom of my layout but it doesn't seem to be working. Somehow it's stuck at the middle of my screen and it won't go down... code below. My main LinearLayout seems to have a match_parent height though...
<ScrimInsetsScrollView
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="#dimen/navdrawer_width"
android:layout_height="match_parent"
android:layout_gravity="start"
android:id="#+id/navdrawer"
android:background="#color/navdrawer_background"
android:fitsSystemWindows="true"
app:insetForeground="#4000">
<LinearLayout android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<FrameLayout
android:id="#+id/chosen_account_view"
android:layout_width="match_parent"
android:layout_height="#dimen/navdrawer_chosen_account_height"
android:layout_alignParentTop="true">
<!--android:foreground="?photoItemForeground"-->
<!-->-->
<ImageView android:layout_width="match_parent"
android:layout_height="match_parent"
android:scaleType="centerCrop"
android:src="#drawable/ic_foodie_nav_image"
android:tint="#color/session_photo_scrim"
android:id="#+id/profile_cover_image"
/>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingLeft="#dimen/keyline_1"
android:paddingRight="#dimen/keyline_1"
android:paddingTop="#dimen/keyline_1"
android:id="#+id/chosen_account_content_view"
android:onClick="showProfile">
<com.pkmmte.view.CircularImageView
android:id="#+id/profile_image"
android:layout_width="#dimen/navdrawer_profile_image_size"
android:layout_height="#dimen/navdrawer_profile_image_size"
android:src="#drawable/ic_action_person"
android:scaleType="centerCrop"
android:layout_marginTop="16dp"
/>
<ImageView
android:id="#+id/expand_account_box_indicator"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:visibility="gone"
android:layout_marginLeft="16dp"
android:paddingBottom="16dp"
android:layout_alignParentEnd="true"
android:layout_alignParentBottom="true"
android:scaleType="center"
android:src="#drawable/ic_drawer_accounts_expand" />
<TextView
android:id="#+id/profile_email_text"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignLeft="#id/profile_image"
android:layout_toLeftOf="#id/expand_account_box_indicator"
android:layout_alignParentBottom="true"
android:paddingBottom="16dp"
android:textSize="#dimen/text_size_medium"
android:textColor="#color/body_text_2_inverse"
android:maxLines="1"
android:singleLine="true"
android:ellipsize="end"/>
<TextView
android:id="#+id/profile_name_text"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_above="#id/profile_email_text"
android:layout_alignLeft="#id/profile_image"
android:layout_toLeftOf="#id/expand_account_box_indicator"
android:textSize="#dimen/text_size_large"
android:textColor="#color/body_text_1_inverse"
android:maxLines="1"
android:singleLine="true"
android:ellipsize="end"
android:textStyle="bold"/>
</RelativeLayout>
</FrameLayout>
<FrameLayout android:layout_width="match_parent"
android:layout_height="wrap_content"
>
<!-- Account items -->
<LinearLayout
android:id="#+id/account_list"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:orientation="vertical"
android:visibility="invisible" />
<LinearLayout
android:id="#+id/navdrawer_items_list"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:layout_marginBottom="8dp"
android:orientation="vertical"
/>
</FrameLayout>
<Button
android:layout_width="wrap_content"
android:layout_height="50dp"
android:background="#color/red_500"
android:layout_gravity="bottom"
android:gravity="bottom"
/>
</LinearLayout>
</ScrimInsetsScrollView>
The solution is in that post LinearLayout not expanding inside a ScrollView
Found the solution myself in the end. The problem was not with the
LinearLayout, but with the ScrollView (seems weird, considering the
fact that the ScrollView was expanding, while the LinearLayout
wasn't).
The solution was to use android:fillViewport="true" on the ScrollView.
Just use it on the Scrimset

Categories

Resources