Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Content behind CoordinatorLayout AppBarLayout

I was creating a settings activity/layout for my app. I have a CoordinatorLayout with an AppBarLayout and Toolbar, then beneath that it includes content_settings.xml. When the content loads the .xml file is behind the app bar.

I'm using this same setup to load the main content and it works fine, but for some reason isn't rendering correctly within the Settings section.

activity_settings.xml

<android.support.design.widget.AppBarLayout     android:layout_width="match_parent"     android:layout_height="wrap_content"     android:theme="@style/AppTheme.AppBarOverlay">      <android.support.v7.widget.Toolbar         android:id="@+id/toolbar"         android:layout_width="match_parent"         android:layout_height="?attr/actionBarSize"         android:background="?attr/colorPrimary"         app:popupTheme="@style/AppTheme.PopupOverlay" />  </android.support.design.widget.AppBarLayout>  <include layout="@layout/content_setting" /> 

The content_settings.xml is just a FrameLayout that is replaced by a PreferenceFragment

<?xml version="1.0" encoding="utf-8"?> <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"     xmlns:app="http://schemas.android.com/apk/res-auto"     android:id="@+id/settings_container"     android:layout_width="match_parent"     android:layout_height="match_parent" /> 

enter image description here

like image 670
ENG618 Avatar asked Sep 30 '15 00:09

ENG618


People also ask

What is CoordinatorLayout used for?

CoordinatorLayout is a super-powered FrameLayout . CoordinatorLayout is intended for two primary use cases: As a top-level application decor or chrome layout. As a container for a specific interaction with one or more child views.

What is the use of AppBarLayout in Android?

AppBarLayout is a vertical LinearLayout which implements many of the features of material designs app bar concept, namely scrolling gestures. Children should provide their desired scrolling behavior through AppBarLayout.

What is the difference between AppBarLayout and ToolBar?

AppBarLayout is a parent layout of ToolBar and ToolBar is custom ActionBar. if you want scroll action on the ToolBar so you should write ToolBar into the AppBarLayout,before you will write code for scroll the ToolBar, you must know the NestedScrollBar,it is used to scroll the ToolBar.

How do you make AppBarLayout transparent?

Simply use app:elevation="0dp" inside "AppBarLayout" to remove the shadow.


1 Answers

add this to your Recyclerview :

app:layout_behavior="@string/appbar_scrolling_view_behavior" 
like image 133
Shashank Kumar Avatar answered Sep 27 '22 23:09

Shashank Kumar