Here we go :) I got a NestedScrollView with CollapsedToolbar. In this NSV I have a LinearLayout with two RecyclerViews. Problem is next, I can't set for that two Recyclers fix size and I don't need NSV scrolling => I need NSV height = [screen size] - [collapsed toolbar height]. Thats why my recyclers shows all items but I need half of screen height size.
<AppBarLayout ... />
<android.support.v4.widget.NestedScrollView
android:id="#+id/scrollView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scrollbars="none"
android:fitsSystemWindows="true"
app:layout_behavior="#string/appbar_scrolling_view_behavior">
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.v7.widget.RecyclerView
android:id="#+id/recycler_asks"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:scrollbars="none"
app:layoutManager="android.support.v7.widget.LinearLayoutManager"
app:layout_constraintBottom_toTopOf="#+id/divider"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
android:layout_marginBottom="#dimen/small_margin"
android:layout_above="#+id/divider"
android:background="#color/red"/>
<View
android:id="#+id/divider"
android:layout_width="match_parent"
android:layout_height="1dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"/>
<android.support.v7.widget.RecyclerView
android:id="#+id/recycler_bids"
android:layout_width="match_parent"
android:layout_height="0dp"
android:orientation="vertical"
android:scrollbars="none"
app:layout_constraintTop_toBottomOf="#+id/divider"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layoutManager="android.support.v7.widget.LinearLayoutManager"
android:layout_below="#+id/divider"
android:layout_marginTop="#dimen/small_margin"
android:background="#color/cyan"/>
</LinearLayout>
</android.support.v4.widget.NestedScrollView>
How can I fix this?
Never use scrollable in scrollable.
1. Create 1 recycler view with different types of view.
2. Add on it layout_behavior.
OUTPUT
Try this
<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.NestedScrollView
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/scrollView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
android:scrollbars="none"
android:fillViewport="true"
app:layout_constraintBottom_toTopOf="#+id/guideline"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="1.0">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#color/colorPrimaryDark"
android:orientation="vertical">
<android.support.v7.widget.RecyclerView
android:id="#+id/recycler_asks"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:scrollbars="none"
android:layout_weight="1"
app:layoutManager="android.support.v7.widget.LinearLayoutManager"
app:layout_constraintBottom_toTopOf="#+id/divider"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
android:layout_marginBottom="#dimen/small_margin"
android:layout_above="#+id/divider"
android:background="#color/colorPrimary"/>
<View
android:id="#+id/divider"
android:layout_width="match_parent"
android:layout_height="1dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"/>
<android.support.v7.widget.RecyclerView
android:id="#+id/recycler_bids"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:scrollbars="none"
android:layout_weight="1"
app:layout_constraintTop_toBottomOf="#+id/divider"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layoutManager="android.support.v7.widget.LinearLayoutManager"
android:layout_below="#+id/divider"
android:layout_marginTop="#dimen/small_margin"
android:background="#color/colorAccent"/>
</LinearLayout>
</android.support.v4.widget.NestedScrollView>
I the only way I found is to make it programatically like code below:
private void setContainerSize() {
LinearLayout contentContainer = getViewDataBinding().container;
Point point = SystemUtils.getScreenSize(this);
float px = SystemUtils.convertDpToPixel(getResources().getDimension(R.dimen.toolbar_size), this);
assert point != null;
ViewGroup.LayoutParams layoutParams = contentContainer.getLayoutParams();
layoutParams.height = (int)(point.getHeight() - px);
contentContainer.setLayoutParams(layoutParams);
contentContainer.requestLayout();
}
Related
If I put only RecyclerView into SwipeRefreshLayout I have buttons above RecyclerView. And if I put all into SwipeRefresh I have buttons disappear
<android.support.v4.widget.SwipeRefreshLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/swipe_container"
android:layout_width="match_parent"
app:layout_behavior="#string/appbar_scrolling_view_behavior"
android:layout_height="match_parent">
<android.support.v7.widget.RecyclerView
android:id="#+id/students_list"
android:layout_width="match_parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
android:layout_height="0dp"
android:layout_marginBottom="8dp"
app:layout_constraintBottom_toTopOf="#+id/buttonsLayout">
</android.support.v7.widget.RecyclerView>
</android.support.v4.widget.SwipeRefreshLayout>
<LinearLayout
android:id="#+id/buttonsLayout"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="8dp"
app:layout_constraintBottom_toBottomOf="parent"
android:orientation="horizontal">
<android.support.v7.widget.AppCompatButton
android:id="#+id/selectAllButton"
android:text="Выбрать всех"
android:layout_weight="1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
</LinearLayout>
Is there any way to fix this?
SwipeRefreshLayout accepts only one child, so maybe you can have a ConstraintLayout inside the SwipeRefreshLayout, and the RecyclerView with the Buttons inside the ConstraintLayout.
PS: I suggest a ConstraintLayout to avoid nested layouts.
<?xml version="1.0" encoding="utf-8"?>
<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"
app:layout_behavior="#string/appbar_scrolling_view_behavior">
<android.support.constraint.ConstraintLayout>
<android.support.v7.widget.RecyclerView
android:id="#+id/students_list"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_marginBottom="8dp"
app:layout_constraintBottom_toTopOf="#+id/selectAllButton"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent"/>
<android.support.v7.widget.AppCompatButton
android:id="#+id/selectAllButton"
android:text="Выбрать всех"
android:layout_weight="1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintBottom_toBottomOf="parent" />
</android.support.constraint.ConstraintLayout>
</android.support.v4.widget.SwipeRefreshLayout>
i have a NestedScrollView which contains a ConstaintLayout and inside of it there's a Viewpager and a Recyclerview
my problem is that the ViewPager isn't showing unless it has a fixed height, match_parent and wrap_content don't work
I've tried to set its height to wrap_content and measure it to be the tallest child's height but still didn't work, i kept changing fillViewport values and other views' heights,changing the parent layout from ConstaintLayout to LinearLayout and make its layout_weight="1" but still the only thing that worked is to set its height to fixed height
my layout:
<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/coordinatorlayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#color/colorWhite"
>
<android.support.design.widget.AppBarLayout
android:id="#+id/apSelectedLine"
android:layout_width="match_parent"
android:layout_height="350dp"
android:background="#color/colorWhite">
<android.support.design.widget.CollapsingToolbarLayout
android:id="#+id/collapsing_container"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:minHeight="250dp"
app:layout_scrollFlags="scroll|exitUntilCollapsed">
<fragment xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/map"
android:name="com.google.android.gms.maps.SupportMapFragment"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_collapseMode="parallax" />
<android.support.v7.widget.CardView
android:id="#+id/cvStep2Loading"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_margin="0dp"
android:background="#color/colorWhite"
android:backgroundTint="#color/colorWhite"
android:minWidth="100dp"
android:minHeight="40dp"
android:visibility="gone"
app:cardBackgroundColor="#color/colorWhite"
app:cardCornerRadius="8dp"
app:cardElevation="16dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<ProgressBar
android:id="#+id/pbStep2Loading"
style="?android:attr/progressBarStyleHorizontal"
android:layout_width="32dp"
android:layout_height="32dp"
android:layout_marginStart="8dp"
android:layout_marginLeft="8dp"
android:layout_marginTop="8dp"
android:layout_marginEnd="8dp"
android:layout_marginRight="8dp"
android:layout_marginBottom="8dp"
android:background="#drawable/circle_shape"
android:indeterminate="false"
android:max="100"
android:padding="4dp"
android:progress="0"
android:progressDrawable="#drawable/circular_progress" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginStart="8dp"
android:layout_marginLeft="8dp"
android:layout_marginTop="8dp"
android:layout_marginEnd="8dp"
android:layout_marginRight="8dp"
android:layout_marginBottom="8dp"
android:gravity="center"
android:text="loading.."
android:textColor="#color/grey" />
</LinearLayout>
</android.support.v7.widget.CardView>
</android.support.design.widget.CollapsingToolbarLayout>
</android.support.design.widget.AppBarLayout>
<android.support.v4.widget.NestedScrollView
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="#+id/nsBusesAndStops"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#color/colorWhite"
android:fillViewport="false"
app:layout_behavior="#string/appbar_scrolling_view_behavior">
<android.support.constraint.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="#+id/llNestSelectedLine"
android:visibility="visible">
<me.relex.circleindicator.CircleIndicator
android:id="#+id/indicator"
android:layout_width="match_parent"
android:layout_height="8dp"
android:layout_marginTop="8dp"
android:layout_marginBottom="8dp"
android:background="#color/colorWhite"
android:backgroundTint="#color/colorWhite"
app:ci_drawable_unselected="#drawable/unselected_grey_circle"
app:ci_drawable="#drawable/selected_black_circle"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintStart_toStartOf="parent"/>
<android.support.v4.view.ViewPager
android:id="#+id/vpSelectedLine"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#color/colorWhite"
app:layout_constraintTop_toBottomOf="#id/indicator"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintBottom_toTopOf="#id/rvStops"
>
</android.support.v4.view.ViewPager>
<android.support.v7.widget.RecyclerView
android:id="#+id/rvStops"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#color/colorWhite"
android:backgroundTint="#color/colorWhite"
android:nestedScrollingEnabled="false"
app:layout_constraintTop_toBottomOf="#id/vpSelectedLine"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
/>
</android.support.constraint.ConstraintLayout>
</android.support.v4.widget.NestedScrollView>
</android.support.design.widget.CoordinatorLayout>
i mustn't make it fixed height because the Viewpager contains a dynamic RecyclerView... so how to solve this without making the ViewPager height fixed?
try to put the ViewPager and the RecyclerView inside FitWindowsFrameLayout with layout_height="wrap_content" so your code look like this
<android.support.design.widget.CoordinatorLayout
...
<android.support.v4.widget.NestedScrollView
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="#+id/nsBusesAndStops"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#color/colorWhite"
android:fillViewport="false"
app:layout_behavior="#string/appbar_scrolling_view_behavior">
<android.support.constraint.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="#+id/llNestSelectedLine"
android:visibility="visible">
<me.relex.circleindicator.CircleIndicator
android:id="#+id/indicator"
android:layout_width="match_parent"
android:layout_height="8dp"
android:layout_marginTop="8dp"
android:layout_marginBottom="8dp"
android:background="#color/colorWhite"
android:backgroundTint="#color/colorWhite"
app:ci_drawable_unselected="#drawable/unselected_grey_circle"
app:ci_drawable="#drawable/selected_black_circle"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintStart_toStartOf="parent"/>
<android.support.v7.widget.FitWindowsFrameLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
tools:ignore="MissingConstraints">
<android.support.v4.view.ViewPager
android:id="#+id/vpSelectedLine"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#color/colorWhite"
app:layout_constraintTop_toBottomOf="#id/indicator"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintBottom_toTopOf="#id/rvStops"
>
</android.support.v4.view.ViewPager>
<android.support.v7.widget.RecyclerView
android:id="#+id/rvStops"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#color/colorWhite"
android:backgroundTint="#color/colorWhite"
android:nestedScrollingEnabled="false"
app:layout_constraintTop_toBottomOf="#id/vpSelectedLine"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintBottom_toBottomOf="parent"/>
</android.support.v7.widget.FitWindowsFrameLayout>
</android.support.constraint.ConstraintLayout>
</android.support.v4.widget.NestedScrollView>
</android.support.design.widget.CoordinatorLayout>
for more info about how to useFitWindowsFrameLayout
this googlesource link
after nearly a day trying to get around this i came up with this solution myself, i set the ViewPager height to fixed height (100dp for example) in xml initially and then when data come from the server i resize the ViewPager height to the total children height, note that i have a RecyclerView inside the ViewPager and here's the Kotlin code i used for this:
fun resizeViewPager(busesList: MutableList<Bus>){
childRecyclerView?.viewTreeObserver?.addOnGlobalLayoutListener(object : ViewTreeObserver.OnGlobalLayoutListener{
override fun onGlobalLayout() {
val firstChild = childRecyclerView?.getChildAt(0)
val height = firstChild?.height
if (height != null){
val totalHeight = height * busesList.size
val layoutParams = viewPager.layoutParams
layoutParams.height = totalHeight
viewPager.layoutParams = layoutParams
viewPager.requestLayout()
}
childRecyclerView?.viewTreeObserver?.removeOnGlobalLayoutListener(this)
}
})
}
can anybody explain why did this problem happen in the first place? and is there a better solution?
I have a requirement to show multiple items in a list and add a WebView in the end.
I have added a RecyclerView and a WebView, and put both of them in a ScrollView.
This is working fine, but it does not shows a scroll in webview.
I need my webview to have a vertical scroll.
This is my code.
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport="true"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/Title"
>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
>
<androidx.recyclerview.widget.RecyclerView
android:id="#+id/rvMatchday"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<WebView
android:layout_width="match_parent"
android:layout_height="300dp"
android:layout_gravity="bottom"
android:scrollbars="vertical"
android:background="#color/black"
android:id="#+id/twitterWebView"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/rvMatchday" />
</LinearLayout>
</ScrollView>
Then I created a parent layout file, and added above layout in that.
<ScrollView
android:layout_width="0dp"
android:layout_height="0dp"
android:fillViewport="true"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
<include layout="#layout/fragment_match"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</ScrollView>
I think you don't need to use scroll view as root because recycler view and web view having their own scrolling effects. Just try with Linear as root
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
>
<androidx.recyclerview.widget.RecyclerView
android:id="#+id/rvMatchday"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
/>
<WebView
android:layout_width="match_parent"
android:layout_height="300dp"
android:background="#color/black"
android:id="#+id/twitterWebView"
/>
</LinearLayout>
You don't need to use Scroll view in your layout.xml file as well as parent layout file.
like
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<androidx.recyclerview.widget.RecyclerView
android:id="#+id/rvMatchday"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<WebView
android:layout_width="match_parent"
android:layout_height="300dp"
android:layout_gravity="bottom"
android:scrollbars="vertical"
android:background="#android:color/black"
android:id="#+id/twitterWebView"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/rvMatchday" />
</LinearLayout>
and parent layout
<android.support.constraint.ConstraintLayout
android:layout_width="0dp"
android:layout_height="0dp"
android:fillViewport="true"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
<include layout="#layout/fragment_match"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</android.support.constraint.ConstraintLayout>
on your activity/fragment, set your webview as scrollable
webView.setVerticalScrollBarEnabled(true);
I tried to make the title as descriptive as possible.
I have a ConstraintLayout with two LinearLayout children that have ScrollViews inside as there are a lot of stuff inside. Each child has a weight of 1. The layout has constraints to top of toolbar, bottom, left and right to parent and a margin to top. So basically, this layout acts as a bottom sheet that slides up and down.
Both sub-views (LinearLayouts-s) can be "expanded", in which case, the other sub-view changes its visibility to gone.
So what happens is when I expand one layout and hide another, for some reason, the whole layout's alignment stays to top of the parent, preserving the margin, but gets cut to the bottom, leaving an empty space. I want it to move to the bottom of the screen is such case. I have also added app:layout_constraintVertical_bias="1.0", which I thought would take care of it. But it does not work. I will attach pictures.
So what I am trying to achieve is to make the sheet to get aligned bottom all the time. Here is my code:
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="#+id/container"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="?ord_canvas_secondary_color">
<include
android:id="#+id/toolbar"
layout="#layout/toolbar"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<FrameLayout
android:id="#+id/content"
android:layout_width="match_parent"
android:layout_height="0dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintTop_toBottomOf="#id/toolbar">
<include layout="#layout/merge_screen_container" />
</FrameLayout>
<View
android:id="#+id/dim_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:alpha="0.5"
android:background="#color/ord_black"
android:clickable="true"
android:focusable="true"
android:visibility="gone"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#id/toolbar" />
<FilterSheet
android:id="#+id/subscriptions_filter"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_marginStart="#dimen/dim_8x"
android:layout_marginTop="#dimen/dim_56x"
android:layout_marginEnd="#dimen/dim_8x"
android:layout_marginBottom="#dimen/dim_8x"
android:visibility="invisible"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#id/toolbar"
app:layout_constraintVertical_bias="1.0" />
</android.support.constraint.ConstraintLayout>
This should work. Please try.
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="#+id/container"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="?ord_canvas_secondary_color">
<include
android:id="#+id/toolbar"
layout="#layout/toolbar"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<FrameLayout
android:id="#+id/content"
android:layout_width="match_parent"
android:layout_height="0dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintTop_toBottomOf="#id/toolbar">
<include layout="#layout/merge_screen_container" />
</FrameLayout>
<View
android:id="#+id/dim_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:alpha="0.5"
android:background="#color/ord_black"
android:clickable="true"
android:focusable="true"
android:visibility="gone"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#id/toolbar" />
<android.support.constraint.ConstraintLayout
android:layout_width="0dp"
android:layout_height="0dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#id/toolbar"
app:layout_constraintVertical_bias="1.0" >
<FilterSheet
android:id="#+id/subscriptions_filter"
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_marginStart="#dimen/dim_8x"
android:layout_marginTop="#dimen/dim_56x"
android:layout_marginEnd="#dimen/dim_8x"
android:layout_marginBottom="#dimen/dim_8x"
android:visibility="invisible"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
/>
</android.support.constraint.ConstraintLayout>
</android.support.constraint.ConstraintLayout>
Try this
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="#+id/container"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="?ord_canvas_secondary_color">
<include
android:id="#+id/toolbar"
layout="#layout/toolbar"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<FrameLayout
android:id="#+id/content"
android:layout_width="0dp"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
android:layout_height="0dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintTop_toBottomOf="#id/toolbar">
<include layout="#layout/merge_screen_container" />
</FrameLayout>
<View
android:id="#+id/dim_layout"
android:layout_width="0dp"
android:layout_height="0dp"
android:alpha="0.5"
android:background="#color/ord_black"
android:clickable="true"
android:focusable="true"
android:visibility="gone"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#id/toolbar" />
<FilterSheet
android:id="#+id/subscriptions_filter"
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_marginStart="#dimen/dim_8x"
android:layout_marginTop="#dimen/dim_56x"
android:layout_marginEnd="#dimen/dim_8x"
android:layout_marginBottom="#dimen/dim_8x"
android:visibility="invisible"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#id/toolbar" />
</android.support.constraint.ConstraintLayout>
So, the answer from #Arti Patel kinda worked, but the filter view would still go beyond toolbar. I ended up using LinearLayout and FrameLayout.
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/container"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="?ord_canvas_secondary_color"
android:orientation="vertical">
<include
android:id="#+id/toolbar"
layout="#layout/toolbar" />
<include layout="#layout/merge_screen_container" />
</LinearLayout>
<View
android:id="#+id/dim_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:alpha="0.5"
android:background="#color/ord_black"
android:clickable="true"
android:focusable="true"
android:visibility="gone" />
<FilterSheet
android:id="#+id/subscriptions_filter"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:layout_marginStart="#dimen/dim_8x"
android:layout_marginTop="#dimen/filter_margin_top"
android:layout_marginEnd="#dimen/dim_8x"
android:layout_marginBottom="#dimen/dim_8x"
android:visibility="invisible" />
</FrameLayout>
Please take a look at my xml:
<android.support.constraint.ConstraintLayout
android:id="#+id/constraintLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="?attr/actionBarSize">
<RelativeLayout
android:id="#+id/layout_info"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:background="#color/colorPrimaryDark"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"/>
<include
layout="#layout/page"
android:layout_width="match_parent"
android:layout_height="0dp"/>
</android.support.constraint.ConstraintLayout>
I'm not able to add constraint to the <include>. The app namespace doesn't work (it works for the RelativeLayout) and auto fill doesn't show the constraint attributes. I want the included layout's height to be the remaining space in the ConstraintLayout, but how do I do it without constraints! Please help.
Try this
<android.support.constraint.ConstraintLayout
android:id="#+id/constraintLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="?attr/actionBarSize">
<RelativeLayout
android:id="#+id/layout_info"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:background="#color/colorPrimaryDark"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"/>
<include
layout="#layout/page"
android:layout_width="0dp"
android:layout_height="wrap_content"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent"/>
</android.support.constraint.ConstraintLayout>
<include layout="#layout/layout_no_friends_avalable"
android:id="#+id/inc_no_friend"
android:layout_width="match_parent"
android:layout_height="0dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toBottomOf="#+id/toolbar_main"
/>
When adding constraints in <include> tag we must use android:layout_width and android:layout_height both attributes.
try this:
<android.support.constraint.ConstraintLayout
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/constraintLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="?attr/actionBarSize">
<RelativeLayout
android:id="#+id/layout_info"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:background="#color/colorPrimaryDark"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
/>
<include
layout="#layout/page"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent" />
</android.support.constraint.ConstraintLayout>