The view is not a child of CoordinatorLayout - android

I am getting java.lang.RuntimeException: Unable to start activity java.lang.IllegalArgumentException: The view is not a child of CoordinatorLayout.working with bottom sheet, I have tried lot of combination but still i am not getting solution. please tell me any solution.Thank you in advance.
<?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"
xmlns:tools="http://schemas.android.com/tools"
android:id="#+id/beyprod"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<LinearLayout
android:id="#+id/toolbarLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:orientation="vertical">
<include
android:id="#+id/toolbar"
layout="#layout/toolbar" />
</LinearLayout>
<!-- <LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<FrameLayout
android:id="#+id/bottom_sheet"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_behavior="#string/bottom_sheet_behavior" />
</LinearLayout>-->
<android.support.v4.widget.NestedScrollView
android:id="#+id/bottom_sheet"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport="true"
app:layout_behavior="#string/bottom_sheet_behavior">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".retailerModule.cart.activity.AddressListActivity">
<ProgressBar
android:id="#+id/progress_bar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/relaLaySearch"
android:layout_gravity="center|top"
android:visibility="gone" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_above="#+id/confirmBtn"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<android.support.v7.widget.RecyclerView
android:id="#+id/recycler"
android:layout_width="match_parent"
android:layout_height="wrap_content">
</android.support.v7.widget.RecyclerView>
</LinearLayout>
<TextView
android:id="#+id/addNewAddress"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_gravity="right"
android:layout_marginTop="15dp"
android:layout_marginRight="10dp"
android:layout_marginBottom="40dp"
android:background="#color/green"
android:gravity="center"
android:padding="10dp"
android:text="New Address"
android:textColor="#color/colorWhite" />
</LinearLayout>
<android.support.v7.widget.AppCompatButton
android:id="#+id/continueBtn"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_gravity="right"
android:background="#color/color_blue"
android:gravity="center"
android:text="SAVE"
android:textColor="#color/colorWhite"
android:visibility="gone" />
</RelativeLayout>
</LinearLayout>
</android.support.v4.widget.NestedScrollView>
</LinearLayout>
When i tried to run this line getting exception
NestedScrollView mBehavior = BottomSheetBehavior.from(bottom_sheet);

It tells you that you can only put a BottomSheetBehavior into a CoordinatorLayout.
So make CoordinatorLayout as your root layout and place it directly here (not in some nested views)

Related

Fragment layout not covering entire screen

I was trying to have a map displayed on one of the fragments of the Bottom Navigation.
But, attached fragment is not covering complete screen. i tried adding background color to the fragment is as below:
While trying to add a map to the fragment it also is not convering the complete screen instead it shows only a bit of the screen.
Below my layout code:
Bottom Navigation.xml:
<RelativeLayout 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="#color/grey_5">
<include
android:id="#+id/search_bar"
layout="#layout/include_card_view_search_bar" />
<androidx.core.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:layout_width="match_parent"
android:layout_height="match_parent"
android:descendantFocusability="blocksDescendants"
android:orientation="vertical">
<View
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:layout_marginBottom="#dimen/spacing_middle" />
<FrameLayout
android:id="#+id/content"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="#color/blue_500"/>
</LinearLayout>
</androidx.core.widget.NestedScrollView>
<com.google.android.material.bottomnavigation.BottomNavigationView
android:id="#+id/navigation"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_gravity="bottom"
android:background="#color/blue_grey_700"
app:itemIconTint="#drawable/color_state_white_2"
app:itemTextColor="#drawable/color_state_white_2"
app:menu="#menu/menu_bottom_navigation_shifting" />
</RelativeLayout>
My Map Fragment:
<RelativeLayout 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="#color/grey_5">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<fragment
android:id="#+id/map"
android:name="com.google.android.gms.maps.SupportMapFragment"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:orientation="vertical">
<View
android:layout_width="match_parent"
android:layout_height="5dp"
android:background="#drawable/bg_gradient_soft" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="50dp"
android:background="#android:color/white"
android:orientation="horizontal">
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:gravity="center"
android:orientation="horizontal"
android:padding="#dimen/spacing_medium">
<ImageButton
android:id="#+id/map_button"
android:layout_width="?attr/actionBarSize"
android:layout_height="?attr/actionBarSize"
android:background="?attr/selectableItemBackgroundBorderless"
android:onClick="clickAction"
android:tint="#color/colorPrimary"
app:srcCompat="#drawable/ic_near_me" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Map"
android:textAppearance="#style/Base.TextAppearance.AppCompat.Subhead"
android:textColor="#color/colorPrimary"
android:textStyle="bold" />
</LinearLayout>
<View
android:layout_width="?attr/actionBarSize"
android:layout_height="0dp" />
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:gravity="center"
android:padding="#dimen/spacing_medium">
<ImageButton
android:id="#+id/list_button"
android:layout_width="?attr/actionBarSize"
android:layout_height="?attr/actionBarSize"
android:background="?attr/selectableItemBackgroundBorderless"
android:onClick="clickAction"
android:tint="#color/colorPrimary"
app:srcCompat="#drawable/ic_format_list_bulleted" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="List"
android:textAppearance="#style/Base.TextAppearance.AppCompat.Subhead"
android:textColor="#color/colorPrimary"
android:textStyle="bold" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
<com.google.android.material.floatingactionbutton.FloatingActionButton
android:id="#+id/add_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_centerInParent="true"
android:layout_marginBottom="15dp"
android:clickable="true"
android:onClick="clickAction"
android:tint="#android:color/white"
app:backgroundTint="#color/colorPrimary"
app:elevation="2dp"
app:fabSize="normal"
app:rippleColor="#color/deep_orange_400"
app:srcCompat="#drawable/ic_add" />
</RelativeLayout>
Attaching the Map using my code:
mapFragment = (SupportMapFragment) this.getChildFragmentManager().findFragmentById(R.id.map);
The app looks like below:
add android:fillViewport="true" in NestedScrollView
<RelativeLayout 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="#color/grey_5">
<include
android:id="#+id/search_bar"
layout="#layout/include_card_view_search_bar" />
<androidx.core.widget.NestedScrollView
android:id="#+id/nested_scroll_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scrollbars="none"
android:scrollingCache="true"
android:fillViewport="true">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:descendantFocusability="blocksDescendants"
android:orientation="vertical">
<View
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:layout_marginBottom="#dimen/spacing_middle" />
<FrameLayout
android:id="#+id/content"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="#color/blue_500"/>
</LinearLayout>
</androidx.core.widget.NestedScrollView>
<com.google.android.material.bottomnavigation.BottomNavigationView
android:id="#+id/navigation"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_gravity="bottom"
android:background="#color/blue_grey_700"
app:itemIconTint="#drawable/color_state_white_2"
app:itemTextColor="#drawable/color_state_white_2"
app:menu="#menu/menu_bottom_navigation_shifting" />
</RelativeLayout>
If NestedScrollView is not necessary try using some other ViewGroup i.e LinearLayout or RelativeLayout in its place. It seems the issue is in wrapping fragment content inside NestedScrollView.
You have taken FrameLayout(id-content) inside NestedScrollView, try removing NestedScrollView from there and adding it to the layout by which you are replacing it with FrameLayout(id-content)

How to make CardView overlap AppBarLayout

I have tried to accomplish something similar to the following layout.
There are a few things to note. The cardview that overlaps the appbar is not supposed to be a part of a nestedscrollview as I have a nestedscrollview in the xml layout. The cardview is positioned correctly but it comes just beneath the appbarlayout.
I just got the solution to this now. I did not give the CardView an elevation value before and that was wrong. I just assumed that making it come last in the CoordinatorLayout should place it on top. It works now. I have added an elevation value. Here is the code -
<xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:app="http://schemas.android.com/apk/res-auto">
<android.support.design.widget.AppBarLayout
android:id="#+id/appBar"
android:layout_width="match_parent"
android:layout_height="250dp"
>
<android.support.design.widget.CollapsingToolbarLayout
android:id="#+id/toolbarlayout"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
android:id="#+id/image"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:src="#drawable/quotes"
android:scaleType="centerCrop"/>
<android.support.v7.widget.Toolbar
android:id="#+id/tool"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
app:layout_collapseMode="parallax"/>
</android.support.design.widget.CollapsingToolbarLayout>
</android.support.design.widget.AppBarLayout>
<android.support.v4.widget.NestedScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#color/colorWhite"
app:layout_behavior="#string/appbar_scrolling_view_behavior"
/>
<android.support.v7.widget.CardView
android:layout_width="match_parent"
android:layout_height="100dp"
android:layout_marginRight="32dp"
android:layout_marginLeft="32dp"
app:layout_anchor="#id/appBar"
app:layout_anchorGravity="bottom|center"
app:cardElevation="#dimen/small_padding"
/>
</android.support.design.widget.CoordinatorLayout>
Try with the following layout.
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout android:layout_width="match_parent"
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_height="match_parent"
xmlns:app="http://schemas.android.com/apk/res-auto">
<android.support.v7.widget.Toolbar
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="#+id/toolbar"
android:layout_width="match_parent"
android:layout_height="200dp"
android:background="#color/colorAccent"
app:popupTheme="#style/ThemeOverlay.AppCompat.Light"
app:layout_scrollFlags="scroll|enterAlways"
app:layout_collapseMode="pin">
<ImageView
android:id="#+id/toolbar_logo"
android:src="#drawable/ic_launcher"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="center"/>
</android.support.v7.widget.Toolbar>
<android.support.v7.widget.CardView
android:layout_width="match_parent"
android:layout_height="100dp"
android:layout_marginLeft="45dp"
android:layout_marginRight="45dp"
app:cardCornerRadius="8dp"
app:cardElevation="7dp"
android:layout_marginTop="150dp"
android:id="#+id/cardView">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:padding="10dp">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:orientation="vertical">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="Photos" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="376" />
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_weight="1">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Followers"
android:layout_gravity="center"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="1769"
android:layout_gravity="center"/>
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_weight="1">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Following"
android:layout_gravity="center"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="127"
android:layout_gravity="center"/>
</LinearLayout>
</LinearLayout>
</android.support.v7.widget.CardView>
</RelativeLayout>

How to use NestedScrollView

In my application I want use NestedScrollView into DrawerLayout.
And for this I write below code.
I want show FAB in bottom of layout, but show me below of card!
I don't want show in below of card, I want show bottom of layout!
Please see below image to understand what I mean:
My codes:
<android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:ads="http://schemas.android.com/apk/res-auto"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="#+id/toNightDrawerLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
tools:openDrawer="end">
<android.support.v4.widget.NestedScrollView
android:layout_width="match_parent"
android:layout_height="match_parent">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<RelativeLayout
android:id="#+id/reviewSerialFrag_newsCommentsLay"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:visibility="visible">
<android.support.v7.widget.CardView
android:id="#+id/reviewSerialFrag_newsCommentsCard"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="#dimen/padding8"
ads:cardBackgroundColor="#android:color/white"
ads:cardElevation="#dimen/size2"
app:contentPadding="#dimen/padding8">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<RelativeLayout
android:id="#+id/reviewSerialFrag_newsCommentsHeaderLay"
android:layout_width="match_parent"
android:layout_height="#dimen/size50">
<ImageView
android:id="#+id/reviewSerialFrag_newsCommentsHeaderImage"
android:layout_width="#dimen/size35"
android:layout_height="#dimen/size35"
android:layout_centerVertical="true"
android:alpha="0.8"
android:src="#drawable/ic_comments"
android:tint="#color/darkBlueGrey" />
<TextView
android:id="#+id/reviewSerialFrag_newsCommentsUserTypeText"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_margin="#dimen/padding10"
android:layout_toRightOf="#+id/reviewSerialFrag_newsCommentsHeaderImage"
android:fontFamily="sans-serif-light"
android:gravity="center_vertical"
android:textColor="#color/darkBlueGrey"
android:textSize="#dimen/font16" />
<TextView
android:id="#+id/reviewSerialFrag_newsCommentsReviewTypeText"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_margin="#dimen/padding10"
android:layout_toRightOf="#+id/reviewSerialFrag_newsCommentsUserTypeText"
android:fontFamily="sans-serif-light"
android:gravity="center_vertical"
android:textColor="#color/darkBlueGrey"
android:textSize="#dimen/font14" />
</RelativeLayout>
<android.support.v7.widget.RecyclerView
android:id="#+id/reviewSerialFrag_newsCommentsRecyclerView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/reviewSerialFrag_newsCommentsHeaderLay"
android:layout_marginTop="#dimen/padding5" />
</RelativeLayout>
</android.support.v7.widget.CardView>
</RelativeLayout>
<!--EmptyList-->
<RelativeLayout
android:id="#+id/reviewSerialFrag_EmptyLsy"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:visibility="gone">
<include layout="#layout/empty_list" />
</RelativeLayout>
<android.support.design.widget.FloatingActionButton
android:id="#+id/reviewSerialFrag_FilterBtn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"
android:layout_margin="#dimen/padding15"
android:src="#drawable/ic_filter"
app:fabSize="normal" />
</RelativeLayout>
</android.support.v4.widget.NestedScrollView>
</android.support.v4.widget.DrawerLayout>
How can I fix this problem?
Hey man try this code :
<android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:ads="http://schemas.android.com/apk/res-auto"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="#+id/toNightDrawerLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
tools:openDrawer="end">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.v4.widget.NestedScrollView
android:layout_width="match_parent"
android:layout_height="match_parent">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<RelativeLayout
android:id="#+id/reviewSerialFrag_newsCommentsLay"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:visibility="visible">
<android.support.v7.widget.CardView
android:id="#+id/reviewSerialFrag_newsCommentsCard"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="#dimen/padding8"
ads:cardBackgroundColor="#android:color/white"
ads:cardElevation="#dimen/size2"
app:contentPadding="#dimen/padding8">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<RelativeLayout
android:id="#+id/reviewSerialFrag_newsCommentsHeaderLay"
android:layout_width="match_parent"
android:layout_height="#dimen/size50">
<ImageView
android:id="#+id/reviewSerialFrag_newsCommentsHeaderImage"
android:layout_width="#dimen/size35"
android:layout_height="#dimen/size35"
android:layout_centerVertical="true"
android:alpha="0.8"
android:src="#drawable/ic_comments"
android:tint="#color/darkBlueGrey" />
<TextView
android:id="#+id/reviewSerialFrag_newsCommentsUserTypeText"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_margin="#dimen/padding10"
android:layout_toRightOf="#+id/reviewSerialFrag_newsCommentsHeaderImage"
android:fontFamily="sans-serif-light"
android:gravity="center_vertical"
android:textColor="#color/darkBlueGrey"
android:textSize="#dimen/font16" />
<TextView
android:id="#+id/reviewSerialFrag_newsCommentsReviewTypeText"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_margin="#dimen/padding10"
android:layout_toRightOf="#+id/reviewSerialFrag_newsCommentsUserTypeText"
android:fontFamily="sans-serif-light"
android:gravity="center_vertical"
android:textColor="#color/darkBlueGrey"
android:textSize="#dimen/font14" />
</RelativeLayout>
<android.support.v7.widget.RecyclerView
android:id="#+id/reviewSerialFrag_newsCommentsRecyclerView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/reviewSerialFrag_newsCommentsHeaderLay"
android:layout_marginTop="#dimen/padding5" />
</RelativeLayout>
</android.support.v7.widget.CardView>
</RelativeLayout>
<!--EmptyList-->
<RelativeLayout
android:id="#+id/reviewSerialFrag_EmptyLsy"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:visibility="gone">
<include layout="#layout/empty_list" />
</RelativeLayout>
</RelativeLayout>
</android.support.v4.widget.NestedScrollView>
<android.support.design.widget.FloatingActionButton
android:id="#+id/reviewSerialFrag_FilterBtn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"
android:layout_margin="#dimen/padding15"
android:src="#drawable/ic_filter"
app:fabSize="normal" />
</RelativeLayout>
</android.support.v4.widget.DrawerLayout>
So try do that:
<android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:ads="http://schemas.android.com/apk/res-auto"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="#+id/toNightDrawerLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
tools:openDrawer="end">
<android.support.design.widget.CoordinatorLayout
android:id="#+id/main_content"
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.v4.widget.NestedScrollView
android:layout_width="match_parent"
android:layout_height="match_parent">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<RelativeLayout
android:id="#+id/reviewSerialFrag_newsCommentsLay"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:visibility="visible">
<android.support.v7.widget.CardView
android:id="#+id/reviewSerialFrag_newsCommentsCard"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="#dimen/padding8"
ads:cardBackgroundColor="#android:color/white"
ads:cardElevation="#dimen/size2"
app:contentPadding="#dimen/padding8">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<RelativeLayout
android:id="#+id/reviewSerialFrag_newsCommentsHeaderLay"
android:layout_width="match_parent"
android:layout_height="#dimen/size50">
<ImageView
android:id="#+id/reviewSerialFrag_newsCommentsHeaderImage"
android:layout_width="#dimen/size35"
android:layout_height="#dimen/size35"
android:layout_centerVertical="true"
android:alpha="0.8"
android:src="#drawable/ic_comments"
android:tint="#color/darkBlueGrey" />
<TextView
android:id="#+id/reviewSerialFrag_newsCommentsUserTypeText"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_margin="#dimen/padding10"
android:layout_toRightOf="#+id/reviewSerialFrag_newsCommentsHeaderImage"
android:fontFamily="sans-serif-light"
android:gravity="center_vertical"
android:textColor="#color/darkBlueGrey"
android:textSize="#dimen/font16" />
<TextView
android:id="#+id/reviewSerialFrag_newsCommentsReviewTypeText"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_margin="#dimen/padding10"
android:layout_toRightOf="#+id/reviewSerialFrag_newsCommentsUserTypeText"
android:fontFamily="sans-serif-light"
android:gravity="center_vertical"
android:textColor="#color/darkBlueGrey"
android:textSize="#dimen/font14" />
</RelativeLayout>
<android.support.v7.widget.RecyclerView
android:id="#+id/reviewSerialFrag_newsCommentsRecyclerView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/reviewSerialFrag_newsCommentsHeaderLay"
android:layout_marginTop="#dimen/padding5" />
</RelativeLayout>
</android.support.v7.widget.CardView>
</RelativeLayout>
<!--EmptyList-->
<RelativeLayout
android:id="#+id/reviewSerialFrag_EmptyLsy"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:visibility="gone">
<include layout="#layout/empty_list" />
</RelativeLayout>
</RelativeLayout>
</android.support.v4.widget.NestedScrollView>
<android.support.design.widget.FloatingActionButton
android:id="#+id/reviewSerialFrag_FilterBtn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="end|bottom"
android:layout_margin="#dimen/padding15"
android:src="#drawable/ic_filter"
app:fabSize="normal" />
</android.support.design.widget.CoordinatorLayout>
</android.support.v4.widget.DrawerLayout>
Set all contect inside a coordinator layout and fab outside the nestedscrollview .If not work ask me to send other possible way.
<android.support.design.widget.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="#style/Widget.AppTheme.AppBarOverlay">
<include
layout="#layout/include_layout_toolbar_scroll"/>
</android.support.design.widget.AppBarLayout>
<include layout="#layout/include_layout_content_with_nestedscroll"/>
<android.support.design.widget.FloatingActionButton
android:id="#+id/fab_task_accept"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="end|bottom"
android:layout_margin="#dimen/fab_margin"
android:src="#drawable/ic_accepted"
app:layout_behavior="pass.to.FabScrollBehavior.Class"
app:theme="#style/Widget.AppTheme.Fab"/>
< /android.support.design.widget.CoordinatorLayout>
use coordinatorlayout
use this link

App bar not pushed up when focused on edit text field

I have a static image on appbar and below that I am using scrollView which contain my edit text.So the problem is that when I focus on edit text soft keyboard hide my fields.It can't push the app bar image up.I try using android:windowSoftInputMode="adjustPan|adjustUnspecified" all these combination but it didn't work .Can any one suggest better way out.
my root view
<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="#+id/activity_register_simplify"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
tools:context="org.tta.mobile.view.Register_simplify">
<android.support.v4.view.ViewPager
android:id="#+id/viewpager"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="#string/appbar_scrolling_view_behavior" />
<android.support.design.widget.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#ffffff"
android:fitsSystemWindows="false"
app:expanded="false">
<LinearLayout
android:layout_width="413dp"
android:layout_height="145dp"
android:background="#drawable/mx_header_banner">
</LinearLayout>
<!--Tab layout-->
<LinearLayout
android:layout_height="64dp"
android:id="#+id/register_simplified_tablayout_ll_id"
android:visibility="visible"
android:orientation="vertical"
android:layout_width="match_parent">
<android.support.design.widget.TabLayout
android:layout_width="match_parent"
app:tabMode="fixed"
app:tabGravity="fill"
android:layout_height="#dimen/mx_signup_signin_top_tablayout_height"
style="#style/MyCustomTabLayout"
app:tabTextColor="#color/black"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
app:tabIndicatorColor="#22d2c5"
android:id="#+id/mRegisteractivityTabs">
<android.support.design.widget.TabItem
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAlignment="center"
android:text="SIGN-IN"
/>
<android.support.design.widget.TabItem
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAlignment="center"
android:text="REGISTER"
/>
</android.support.design.widget.TabLayout>
</LinearLayout>
</android.support.design.widget.AppBarLayout>
</android.support.design.widget.CoordinatorLayout>
and my view inside pageviewer which contain fields
<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"
android:id="#+id/mx_sign_up_fragment"
android:orientation="vertical"
android:background="#android:color/white"
tools:context="org.tta.mobile.mx_views.SignUpFragment">
<!--android:paddingTop="#dimen/mx_scroll_view_top_padding"-->
<ScrollView
android:id="#+id/scrollview_register"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="50dp"
android:background="#android:color/white"
android:layout_centerVertical="true"
android:layout_alignParentStart="true">
<LinearLayout
android:id="#+id/registrationLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<LinearLayout
android:id="#+id/manprax_sign_in_Layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_marginLeft="20dp"
android:layout_marginRight="20dp">
<LinearLayout
android:id="#+id/message_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:visibility="gone">
<include layout="#layout/panel_message_with_check" />
</LinearLayout>
<LinearLayout
android:id="#+id/required_fields_layout_register"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_marginTop="5dp"/>
</LinearLayout>
</LinearLayout>
</ScrollView>
<LinearLayout
android:id="#+id/mx_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:background="#android:color/white"
android:layout_alignParentBottom="true">
<!-- <FrameLayout
android:layout_height="40dp"
android:layout_width="match_parent"
android:focusable="true"
android:id="#+id/mx_signup_remember_me_layout" >
<CheckBox
android:layout_width="match_parent"
android:id="#+id/mx_signup_remember_me_Chkbx"
android:text="Remember me"
android:layout_height="40dp" />
</FrameLayout>-->
<FrameLayout
style="#style/edX.Widget.Sign_In_Manprax_Layout"
android:layout_height="#dimen/mx_btn_height"
android:layout_width="match_parent"
android:layout_alignParentBottom="true"
android:focusable="true"
android:id="#+id/send_OTP_button_layout"
android:contentDescription="#string/create_account_btn">
<TextView
style="#style/edX.Widget.SignInButton"
android:id="#+id/send_OTP_tv"
android:text="#string/send_OTP_text" />
<include layout="#layout/button_progress_indicator" />
</FrameLayout>
</LinearLayout>
</RelativeLayout>

Layout is behind Navigation bar (out of screen)

I created a Basic-Activity and have the activity_main which includes the content_main. But at the Design-Screen I can see, that the included content_main starts below the toolbar and ends behind the navigationbar. I think that the Included layout is as high as the full screen and not as high as the space between toolbar and the end of screen. What can I do?
Screenshot of Designscreen
Activity_Main
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.htlhl.kellergassen_app.MainActivity"
android:fitsSystemWindows="true">
<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="#color/KG_orange">
<android.support.v7.widget.AppCompatTextView
android:id="#+id/toolbar_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="#string/HomeActivity"
style="#style/Toolbartitle_KG" />
</android.support.v7.widget.Toolbar>
</android.support.design.widget.AppBarLayout>
<include layout="#layout/content_main" />
</android.support.design.widget.CoordinatorLayout>
Content_Main
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#drawable/background2"
android:paddingTop="#dimen/activity_vertical_margin"
app:layout_behavior="#string/appbar_scrolling_view_behavior"
tools:context="com.htlhl.kellergassen_app.MainActivity"
tools:showIn="#layout/activity_main"
android:id="#+id/rl_main">
<LinearLayout
android:id="#+id/linearLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentEnd="false"
android:layout_alignParentStart="true"
android:layout_alignParentTop="true"
android:orientation="vertical"
android:onClick="here">
<ImageView
android:id="#+id/Kellergassenlogo"
android:layout_width="150dp"
android:layout_height="150dp"
android:layout_gravity="center_horizontal"
android:layout_marginTop="0dp"
android:contentDescription="#string/ButtonKellergasse"
android:onClick="toKellerkatze"
android:src="#drawable/kk_logo" />
<Button
android:id="#+id/btnToKellergasse"
android:layout_width="180dp"
android:layout_height="36dp"
android:layout_gravity="center_horizontal"
android:layout_marginTop="12dp"
android:background="#drawable/roundbutton"
android:onClick="toKellerkatze"
android:text="#string/ButtonKellergasse"
android:textColor="#color/white"
android:textSize="15sp" />
<ImageView
android:id="#+id/Routenlogo"
android:layout_width="150dp"
android:layout_height="150dp"
android:layout_gravity="top|bottom|center_horizontal"
android:layout_marginTop="15dp"
android:contentDescription="#string/ButtonRoute"
android:onClick="toRouten"
android:src="#drawable/routenlogo" />
<Button
android:id="#+id/btnToRouten"
android:layout_width="180dp"
android:layout_height="36dp"
android:layout_gravity="center_horizontal"
android:layout_marginTop="12dp"
android:background="#drawable/roundbutton"
android:onClick="toRouten"
android:text="#string/ButtonRoute"
android:textColor="#color/white"
android:textSize="15sp" />
</LinearLayout>
<Button
android:id="#+id/btnParse"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="parse"
android:textColor="#color/black"
android:background="#color/KG_green"
android:onClick="startParsing"/>
<LinearLayout
android:id="#+id/layout_bottom_main"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:orientation="horizontal"
android:weightSum="3">
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginBottom="10dp"
android:layout_marginStart="10dp"
android:layout_weight="2"
android:gravity="center"
android:orientation="vertical">
<fragment
android:id="#+id/fragmentChooseLang"
android:name="com.htlhl.kellergassen_app.FragmentLanguage"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<TextView
android:id="#+id/tvChooseLang"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:drawableTop="#drawable/german_flag"
android:text="#string/chooseLanguage"
android:textSize="12sp"
android:textStyle="bold" />
</LinearLayout>
<Button
android:id="#+id/btnToImpressum"
style="?android:attr/borderlessButtonStyle"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="#string/ButtonImpressum"
android:textSize="15sp"
android:textStyle="bold"
android:layout_gravity="bottom"/>
</LinearLayout>
</RelativeLayout>
The Layout named "layout_bootom_main" is not shown, because it is layout_alignParentBottom and the parents end is out of screen.
You can add scroll view in content_main as parent view for both linear layouts.
<RelativeLayout>
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:id="#+id/linearLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<!-- Add your linear layouts here -->
</LinearLayout>
</ScrollView>
</RelativeLaout>
And while designing in android studio try to preview the design with device having more hight
You could wrap everything inside a scrollview like this:
<RelativeLayout
......>
<ScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content">
<-! All the layout children in here-->
</ScrollView>
</RelativeLaout>

Categories

Resources