I have AppBarLayout inside CoordinatorLayout while scrolling from AppBarLayout area from top to bottom then some time suddenly scrolls up.
here is the result1 result2
Layout :
<?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"
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.design.widget.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#color/white"
android:orientation="vertical"
app:elevation="0dp">
<FrameLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_scrollFlags="scroll">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<include layout="#layout/layout_header_title_list_item_listing" />
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_scrollFlags="scroll">
<ImageView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="#+id/imgThumbDetails"
android:layout_width="0dp"
android:layout_height="0dp"
android:adjustViewBounds="true"
android:visibility="invisible"
app:layout_constraintDimensionRatio="W,1:1.5"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<cn.jzvd.JZVideoPlayerStandard
android:id="#+id/videoplayerDetails"
android:layout_width="0dp"
android:layout_height="0dp"
android:visibility="invisible"
app:layout_constraintDimensionRatio="W,1:1.5"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<com.videosgifsimages.smallbang.SmallBangView
android:id="#+id/like_heart"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
android:layout_marginEnd="8dp"
android:layout_marginStart="8dp"
android:layout_marginTop="8dp"
android:clickable="false"
android:visibility="invisible"
app:circle_end_color="#00000000"
app:circle_start_color="#00000000"
app:dots_primary_color="#c60d2c"
app:dots_secondary_color="#e9cf0b"
app:layout_constraintBottom_toBottomOf="#+id/videoplayerDetails"
app:layout_constraintEnd_toEndOf="#+id/videoplayerDetails"
app:layout_constraintStart_toStartOf="#+id/videoplayerDetails"
app:layout_constraintTop_toTopOf="#+id/videoplayerDetails">
<ImageView
android:id="#+id/image"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:src="#drawable/ic_like_animate" />
</com.videosgifsimages.smallbang.SmallBangView>
</android.support.constraint.ConstraintLayout>
<include
layout="#layout/layout_bottom_list_item_listing"
android:layout_width="match_parent"
android:layout_height="54dp"
app:layout_scrollFlags="scroll" />
<FrameLayout
android:layout_width="match_parent"
android:layout_height="100dp"
android:background="#f2f2f2"
app:layout_scrollFlags="scroll">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="ad"
android:textColor="#565656"
android:textSize="12sp"
android:textStyle="normal" />
</FrameLayout>
</LinearLayout>
</FrameLayout>
</android.support.design.widget.AppBarLayout>
<android.support.v7.widget.RecyclerView
android:id="#+id/recyclerViewDetails"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#color/white"
app:layout_behavior="#string/appbar_scrolling_view_behavior" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="60dp"
android:layout_gravity="bottom"
android:background="#ecf0f1"
android:orientation="horizontal"
android:padding="10dp">
<EditText
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_gravity="center"
android:layout_weight="1"
android:background="#drawable/rounded_edittext_post_comment"
android:hint="Comment"
android:inputType="textPersonName"
android:paddingEnd="15dp"
android:paddingStart="15dp" />
<ImageView
android:layout_width="40dp"
android:layout_height="40dp"
android:layout_gravity="center"
android:layout_marginStart="17dp"
android:background="#drawable/circle_background_post_comment_btn"
android:scaleType="centerInside"
android:src="#drawable/ic_post_comment" />
</LinearLayout>
<View
android:id="#+id/viewDimBgForBottomSheet"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#99000000"
android:visibility="gone" />
<include layout="#layout/bottom_sheet" />
</android.support.design.widget.CoordinatorLayout>
Related
NestedScrollView is not working with ViewPager
Here is my code. Can you please suggest or help me. when i try NestedScrollView without ViewPager its working on other page. here is my layout file.
this RelativeLayout can be removed if needed as i have added this
<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="#ffffff"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#ffffff"
android:orientation="vertical">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="50dp"
android:background="#color/colorAccent">
<ImageView
android:id="#+id/back"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/back"
android:layout_marginLeft="10dp"
android:layout_centerVertical="true"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="मेरी प्रोफाइल"
android:textColor="#ffffff"
android:textSize="17sp"
android:layout_centerInParent="true"/>
</RelativeLayout>
NestedScrollView is used
<androidx.core.widget.NestedScrollView
android:id="#+id/nest_scrollview"
android:fillViewport="true"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:nestedScrollingEnabled="true"
>
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:orientation="vertical"
android:layout_height="wrap_content"
android:nestedScrollingEnabled="true"
>
<com.test.utils.RoundedImageView
android:id="#+id/iv_user_image"
android:layout_width="100dp"
android:layout_height="100dp"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
android:src="#drawable/uploadphoto"
android:tint="#color/colorPrimary"
android:layout_margin="10dp"/>
<TextView
android:id="#+id/tv_user_name"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_constraintTop_toTopOf="#+id/iv_user_image"
app:layout_constraintLeft_toRightOf="#+id/iv_user_image"
android:layout_marginTop="10dp"
android:layout_marginLeft="20dp"
android:textColor="#color/black"
android:textSize="18sp"
android:textAlignment="center"
android:text="Hitesh"/>
<TextView
android:id="#+id/tv_user_phone"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_constraintTop_toBottomOf="#+id/tv_user_name"
app:layout_constraintLeft_toRightOf="#+id/iv_user_image"
android:textAlignment="center"
android:layout_marginTop="5dp"
android:layout_marginLeft="20dp"
android:textColor="#color/quantum_orange"
android:textSize="15sp"/>
<TextView
android:id="#+id/tv_address"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_constraintTop_toBottomOf="#+id/iv_user_image"
app:layout_constraintLeft_toLeftOf="#+id/iv_user_image"
android:layout_marginTop="20dp"
android:textColor="#color/black"
android:drawableLeft="#drawable/gglocation"
android:text="Hitesh"/>
<androidx.constraintlayout.widget.ConstraintLayout
android:id="#+id/cl_referral"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_constraintTop_toBottomOf="#+id/tv_address"
android:background="#drawable/border_home_blue"
android:layout_marginRight="10dp"
android:layout_marginLeft="10dp"
android:layout_marginTop="20dp"
android:padding="5dp">
<ImageView
android:id="#+id/iv_referral"
android:layout_width="15dp"
android:layout_height="15dp"
android:src="#drawable/ic_trophy"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"/>
<TextView
android:id="#+id/tv_referral_code"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toRightOf="#+id/iv_referral"
android:textColor="#color/black"
android:layout_marginLeft="5dp"
android:textAllCaps="true"
android:gravity="center"
android:textSize="18sp"
android:text="Hitesh"/>
<TextView
android:id="#+id/tv_hint"
android:layout_width="0dp"
android:layout_height="wrap_content"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toRightOf="#+id/tv_referral_code"
app:layout_constraintRight_toLeftOf="#+id/iv_whatsapp"
android:layout_margin="10dp"
android:textAllCaps="true"
android:textSize="12sp"
android:text="अपना रेफरल कोड शेयर करे"/>
<ImageView
android:id="#+id/iv_whatsapp"
android:layout_width="25dp"
android:layout_height="25dp"
android:src="#drawable/ic_whatsapp"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintTop_toTopOf="parent"
/>
</androidx.constraintlayout.widget.ConstraintLayout>
<androidx.cardview.widget.CardView
android:id="#+id/rateus"
app:cardCornerRadius="6dp"
android:layout_margin="10dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
app:layout_constraintTop_toBottomOf="#+id/cl_referral"
app:layout_constraintLeft_toLeftOf="parent"
android:nestedScrollingEnabled="true">
<ImageView
android:layout_width="match_parent"
android:layout_height="150dp"
android:layout_centerVertical="true"
android:src="#drawable/rateus"
/>
</androidx.cardview.widget.CardView>
<com.google.android.material.tabs.TabLayout
android:id="#+id/tab_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_constraintTop_toBottomOf="#+id/rateus"
app:tabSelectedTextColor="#color/colorPrimary"
app:tabTextColor="#color/black"
app:tabIndicatorColor="#color/colorPrimary"
android:layout_marginTop="5dp"
android:nestedScrollingEnabled="true"
/>
this is my view pages
<androidx.viewpager.widget.ViewPager
android:id="#+id/pager"
android:layout_width="match_parent"
android:layout_height="0dp"
app:layout_constraintTop_toBottomOf="#id/tab_layout"
app:layout_behavior="#string/appbar_scrolling_view_behavior"
android:nestedScrollingEnabled="true"/>
</androidx.constraintlayout.widget.ConstraintLayout>
</LinearLayout>
</androidx.core.widget.NestedScrollView>
</LinearLayout>
Should be solved by setFillViewport (true):
<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:layout_width="match_parent"
android:id="#+id/nest_scrollview"
android:layout_height="match_parent"
app:layout_behavior="#string/appbar_scrolling_view_behavior"
tools:context="mio.kon.yyb.nestedscrollviewbug.ScrollingActivity"
tools:showIn="#layout/activity_scrolling">
<android.support.v4.view.ViewPager
android:id="#+id/viewpager"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
And in your activity set:
NestedScrollView scrollView = (NestedScrollView) findViewById (R.id.nest_scrollview);
scrollView.setFillViewport (true);
I'm facing one issue.
I have a coordinate layout and inside I have the toolbar and all that.
I have also one frame layout inside it and in-frame layout I have three fragments.
One chat fragment is there, in that I have one recycler view.
When moving to that tab I scroll the layout with AppBarLayout.LayoutParams.SCROLL_FLAG_SCROLL or AppBarLayout.LayoutParams.SCROLL_FLAG_EXIT_UNTIL_COLLAPSED.
But when I scroll recycler view, coordinate layout also scrolls.
I want the coordinate layout scroll only the first time and want to diable when recycler view scrolls.
Here is my XML file.
<?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:id="#+id/co_ordinate_layout"
android:layout_height="match_parent"
android:background="#color/offwhite">
<com.google.android.material.appbar.AppBarLayout
android:id="#+id/appBarLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#color/offwhite"
android:theme="#style/ThemeOverlay.AppCompat.Dark.ActionBar"
tools:ignore="ExtraText">
<com.google.android.material.appbar.CollapsingToolbarLayout
android:id="#+id/collapseBar"
android:layout_width="match_parent"
android:layout_height="200dp"
app:expandedTitleMarginBottom="94dp"
app:layout_scrollFlags="scroll|exitUntilCollapsed">
<androidx.appcompat.widget.Toolbar
android:id="#+id/toolbar"
android:layout_width="match_parent"
android:layout_height="100dp"
android:background="#null"
android:backgroundTint="#color/white"
android:visibility="visible"
app:layout_collapseMode="pin"
app:navigationIcon="#drawable/ic_cancel" />
</com.google.android.material.appbar.CollapsingToolbarLayout>
<TextView
android:id="#+id/tv_name"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="#dimen/_7sdp"
android:gravity="center"
android:orientation="vertical"
android:padding="#dimen/_7sdp"
android:text="Mimi51"
android:textColor="#color/secondary_text"
android:textSize="#dimen/_20sdp"
app:layout_scrollFlags="scroll|enterAlways|snap" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:gravity="center"
android:orientation="horizontal">
<LinearLayout
android:id="#+id/llProfile"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:orientation="vertical">
<TextView
android:id="#+id/tvProfile"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center"
android:orientation="vertical"
android:paddingStart="#dimen/_5sdp"
android:paddingEnd="#dimen/_5sdp"
android:text="#string/profile"
android:textAllCaps="true"
android:textColor="#color/secondary_text"
android:textSize="#dimen/normal_textsize"
android:textStyle="bold" />
<View
android:id="#+id/viewProfile"
android:layout_width="match_parent"
android:layout_height="#dimen/_2sdp"
android:background="#color/theme" />
</LinearLayout>
<LinearLayout
android:id="#+id/llPlayList"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:orientation="vertical">
<TextView
android:id="#+id/tvPlayList"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center"
android:orientation="vertical"
android:paddingStart="#dimen/_5sdp"
android:paddingEnd="#dimen/_5sdp"
android:text="#string/playlist"
android:textAllCaps="true"
android:textColor="#color/secondary_text"
android:textSize="#dimen/normal_textsize"
android:textStyle="bold" />
<View
android:id="#+id/viewPlayList"
android:layout_width="match_parent"
android:layout_height="#dimen/_2sdp"
android:background="#color/theme" />
</LinearLayout>
<LinearLayout
android:id="#+id/llChat"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:orientation="vertical">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_weight="1"
android:gravity="center"
android:orientation="horizontal"
android:paddingStart="#dimen/_5sdp"
android:paddingEnd="#dimen/_5sdp">
<TextView
android:id="#+id/tvChat"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
android:text="Chat"
android:textAllCaps="true"
android:textColor="#color/secondary_text"
android:textSize="#dimen/normal_textsize"
android:textStyle="bold" />
<TextView
android:id="#+id/tvChatConut"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="#dimen/_5sdp"
android:background="#drawable/stock_chat_count"
android:orientation="vertical"
android:paddingStart="#dimen/_10sdp"
android:paddingTop="#dimen/_2sdp"
android:paddingEnd="#dimen/_10sdp"
android:paddingBottom="#dimen/_2sdp"
android:text="1"
android:textAllCaps="true"
android:textColor="#color/theme"
android:textSize="#dimen/small_textsize" />
</LinearLayout>
<View
android:id="#+id/viewChat"
android:layout_width="match_parent"
android:layout_height="#dimen/_2sdp"
android:background="#color/theme" />
</LinearLayout>
</LinearLayout>
<View
android:id="#+id/view_header"
android:layout_width="match_parent"
android:layout_height="2dp"
android:background="#color/gray_light"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/cl_header" />
</com.google.android.material.appbar.AppBarLayout>
<FrameLayout
android:id="#+id/content_frame"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="#string/appbar_scrolling_view_behavior" />
<de.hdodenhof.circleimageview.CircleImageView
android:id="#+id/imgProfile"
android:layout_width="160dp"
android:layout_height="160dp"
android:layout_gravity="center_horizontal"
android:layout_marginTop="30dp"
android:elevation="8dp"
android:padding="3dp"
android:src="#color/theme"
app:layout_anchorGravity="top|center_horizontal"
app:layout_scrollFlags="scroll" />
</androidx.coordinatorlayout.widget.CoordinatorLayout>
I'm trying to add a horizantal recyclerview at the bottom in linearlayout but it always starts from top of linearlayout , here is my code
<?xml version="1.0" encoding="utf-8"?>
<androidx.drawerlayout.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="#+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true">
<androidx.fragment.app.FragmentContainerView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/fragment_container_view"
android:layout_width="match_parent"
android:layout_height="match_parent" />
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<androidx.cardview.widget.CardView
android:id="#+id/cardView"
android:layout_width="match_parent"
android:layout_height="40dp"
android:layout_marginLeft="16dp"
android:layout_marginTop="16dp"
android:layout_marginRight="16dp"
android:background="#color/white"
android:divider="#android:color/transparent"
android:elevation="100dp"
android:foreground="?android:attr/selectableItemBackground"
android:orientation="vertical"
app:cardBackgroundColor="#android:color/white"
app:cardCornerRadius="6dp"
app:cardElevation="66dp"
app:cardPreventCornerOverlap="false"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.076"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal">
<ImageView
android:id="#+id/menu_image_view"
android:layout_width="30dp"
android:layout_height="30dp"
android:layout_gravity="center_vertical"
android:layout_marginStart="8dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:srcCompat="#drawable/menu_icon" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="5dp"
android:layout_marginRight="5dp"
android:layout_weight="1"
android:layoutDirection="ltr"
android:orientation="horizontal"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toStartOf="#+id/frameLayout2"
app:layout_constraintStart_toEndOf="#+id/menu_image_view"
app:layout_constraintTop_toTopOf="parent">
<LinearLayout
android:id="#+id/medfast_linear_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="center"
android:gravity="center"
android:layoutDirection="ltr"
android:orientation="horizontal"
android:visibility="visible">
<com.plus.medfast.customViews.views.CustomRegularTextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="center"
android:gravity="center"
android:text="#string/be_healthy" />
</LinearLayout>
<LinearLayout
android:id="#+id/zinc_linear_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="center"
android:gravity="center"
android:layoutDirection="ltr"
android:orientation="horizontal"
android:visibility="gone">
<ImageView
android:layout_width="match_parent"
android:layout_height="30dp"
android:layout_weight="1.3"
android:src="#drawable/medfast_word_only" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginLeft="3dp"
android:layout_marginRight="-2dp"
android:layout_weight="1.7"
android:gravity="center">
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:src="#drawable/ic_deal" />
</LinearLayout>
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:src="#drawable/zinc" />
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1.9">
<FrameLayout
android:id="#+id/frameLayout2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginEnd="8dp"
android:layout_weight="1.1"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent">
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
android:id="#+id/medfast_ads_image_view"
android:layout_width="40dp"
android:layout_height="50dp"
android:layout_gravity="left"
android:src="#drawable/ic_logo"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<TextView
android:id="#+id/medfast_ads_text_view"
android:layout_width="15dp"
android:layout_height="15dp"
android:layout_gravity="top|end"
android:layout_marginTop="24dp"
android:background="#drawable/circle_view_white_solid"
android:gravity="center"
android:text="10"
android:textColor="#color/white"
android:textSize="10dp"
app:layout_constraintBottom_toTopOf="#+id/medfast_ads_image_view"
app:layout_constraintEnd_toEndOf="#+id/medfast_ads_image_view"
app:layout_constraintTop_toTopOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
</FrameLayout>
<FrameLayout
android:id="#+id/frameLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginEnd="8dp"
android:layout_weight="1.3"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent">
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
android:id="#+id/normal_ads_image_view"
android:layout_width="30dp"
android:layout_height="40dp"
android:layout_gravity="left"
android:src="#drawable/ic_notification"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<TextView
android:id="#+id/normal_ads_text_view"
android:layout_width="15dp"
android:layout_height="15dp"
android:layout_gravity="top|end"
android:layout_marginTop="16dp"
android:background="#drawable/circle_view_white_solid"
android:gravity="center"
android:text="10"
android:textColor="#color/white"
android:textSize="10dp"
app:layout_constraintBottom_toTopOf="#+id/normal_ads_image_view"
app:layout_constraintEnd_toEndOf="#+id/normal_ads_image_view"
app:layout_constraintTop_toTopOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
</FrameLayout>
</LinearLayout>
</LinearLayout>
</androidx.cardview.widget.CardView>
<ProgressBar
android:id="#+id/progressBar"
style="?android:attr/progressBarStyle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:visibility="gone"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<LinearLayout
android:layout_width="match_parent"
android:gravity="bottom"
android:layout_height="wrap_content"
app:layout_constraintBottom_toTopOf="#+id/focused_service_name_text_view"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent">
<androidx.recyclerview.widget.RecyclerView
android:id="#+id/services_recycler_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:clipToPadding="false" />
</LinearLayout>
<com.plus.medfast.customViews.views.CustomBoldTextView
android:id="#+id/focused_service_name_text_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
android:gravity="center"
android:textColor="#color/colorPrimary"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
<com.google.android.material.navigation.NavigationView
android:id="#+id/nav_view"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="start"
android:fitsSystemWindows="true"
app:headerLayout="#layout/nav_header_maps_navigation_drawer"
app:menu="#menu/core_activity_navigation_drawer" />
</androidx.drawerlayout.widget.DrawerLayout>
but the result as shown bellow, i need the recyclerview be in bottom because i wan't to translate Y axis of the view to up
Everything in my xml is well written.
after adding marginTop=20 to the recycler view item it works well
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="#+id/root_view"
android:layout_width="90dp"
android:layout_height="90dp"
android:layout_marginTop="20dp"
android:layout_marginBottom="20dp"
android:gravity="center"
android:orientation="vertical">
<LinearLayout
android:layout_width="80dp"
android:layout_height="80dp"
android:background="#drawable/circle_view_red"
android:gravity="center"
android:orientation="vertical">
<ImageView
android:id="#+id/service_image_view"
android:layout_width="50dp"
android:layout_height="50dp"
android:padding="5dp" />
<com.plus.medfast.customViews.views.CustomBoldTextView
android:id="#+id/service_name_text_view"
android:layout_width="60dp"
android:layout_height="match_parent"
android:layout_marginTop="-5dp"
android:gravity="center"
android:text="Test"
android:textColor="#color/white"
android:textSize="10dp"
android:visibility="visible" />
</LinearLayout>
</LinearLayout>
I have been trying to add CardView to navigationDrawer activity and collapsing toolbar layout all in one activity so that I can view all my contents form navigation drawer and collapse the layout and use card view as my buttons to make it more attractive. but it works fine as long as I don't add card views into the layout, but when I add the CardView into the code that is XML file and run the program the emulator shows that the app has not responding.
I need help with this, please anyone.
<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="#+id/drawer"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.example.madhu.management.DashBoard">
<android.support.design.widget.CoordinatorLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#e0e0e0">
<android.support.design.widget.AppBarLayout
android:id="#+id/appbar"
android:layout_width="match_parent"
android:layout_height="250dp"
android:theme="#style/ThemeOverlay.AppCompat.Dark.ActionBar">
<android.support.design.widget.CollapsingToolbarLayout
android:id="#+id/collapsingtoolbar"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#drawable/materialappbar"
app:contentScrim="?attr/colorPrimary"
app:expandedTitleMarginEnd="64dp"
app:expandedTitleMarginStart="480dp"
app:layout_scrollFlags="exitUntilCollapsed|scroll"
app:title="management">
<android.support.v7.widget.Toolbar
android:id="#+id/toolbarid"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
app:layout_collapseMode="pin"
app:popupTheme="#style/ThemeOverlay.AppCompat.Light" />
</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"
app:layout_behavior="#string/appbar_scrolling_view_behavior">
<LinearLayout
android:id="#+id/ll"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#fcfcfc"
android:gravity="center"
android:orientation="vertical"
android:padding="10dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:clipToPadding="false"
android:gravity="center"
android:orientation="horizontal">
<android.support.v7.widget.CardView
android:id="#+id/bankcardId"
android:layout_width="160dp"
android:layout_height="190dp"
android:layout_margin="10dp"
android:clickable="true"
android:foreground="?android:attr/selectableItemBackground">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:orientation="vertical">
<ImageView
android:layout_width="64dp"
android:layout_height="64dp"
android:background="#drawable/circlebackgroundpurple"
android:padding="10dp"
android:src="#drawable/ic_add_alert_white_24px" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:text="Notice"
android:textStyle="bold" />
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_margin="10dp"
android:background="#color/lightgray" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:padding="5dp"
android:text="department notice board"
android:textColor="#android:color/darker_gray" />
</LinearLayout>
</android.support.v7.widget.CardView>
<android.support.v7.widget.CardView
android:layout_width="160dp"
android:layout_height="190dp"
android:layout_margin="10dp"
android:clickable="true"
android:foreground="?android:attr/selectableItemBackground">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:orientation="vertical">
<ImageView
android:layout_width="64dp"
android:layout_height="64dp"
android:background="#drawable/circlebackgroundpink"
android:padding="10dp"
android:src="#drawable/ic_book_white_24px" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:text="Notes"
android:textStyle="bold" />
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_margin="10dp"
android:background="#color/lightgray" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:padding="5dp"
android:text="Notes from faculty"
android:textColor="#android:color/darker_gray" />
</LinearLayout>
</android.support.v7.widget.CardView>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:clipToPadding="false"
android:gravity="center"
android:orientation="horizontal">
<android.support.v7.widget.CardView
android:layout_width="160dp"
android:layout_height="190dp"
android:layout_margin="10dp"
android:clickable="true"
android:foreground="?android:attr/selectableItemBackground">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:orientation="vertical">
<ImageView
android:layout_width="64dp"
android:layout_height="64dp"
android:background="#drawable/circlebackgroundgreen"
android:padding="10dp"
android:src="#drawable/ic_help_outline_white_24px" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:text="Question papers"
android:textStyle="bold" />
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_margin="10dp"
android:background="#color/lightgray" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:padding="5dp"
android:text="Question banks and question papers"
android:textColor="#android:color/darker_gray" />
</LinearLayout>
</android.support.v7.widget.CardView>
<android.support.v7.widget.CardView
android:layout_width="160dp"
android:layout_height="190dp"
android:layout_margin="10dp"
android:clickable="true"
android:foreground="?android:attr/selectableItemBackground">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:orientation="vertical">
<ImageView
android:layout_width="64dp"
android:layout_height="64dp"
android:background="#drawable/circlebackgroundyellow"
android:padding="10dp"
android:src="#drawable/ic_update_white_24px" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:text="University Updates"
android:textStyle="bold" />
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_margin="10dp"
android:background="#color/lightgray" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:padding="5dp"
android:text="updates from university"
android:textColor="#android:color/darker_gray" />
</LinearLayout>
</android.support.v7.widget.CardView>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:clipToPadding="false"
android:gravity="center"
android:orientation="horizontal">
<android.support.v7.widget.CardView
android:layout_width="340dp"
android:layout_height="150dp"
android:layout_margin="10dp"
android:clickable="true"
android:foreground="?android:attr/selectableItemBackground">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:orientation="vertical">
<ImageView
android:layout_width="64dp"
android:layout_height="64dp"
android:background="#drawable/circlebackgroundpurple"
android:padding="10dp"
android:src="#drawable/ic_stars_white_24dp" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:text="Results"
android:textStyle="bold" />
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_margin="10dp"
android:background="#color/lightgray" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:padding="5dp"
android:text="semister results"
android:textColor="#android:color/darker_gray" />
</LinearLayout>
</android.support.v7.widget.CardView>
</LinearLayout>
</LinearLayout>
</android.support.v4.widget.NestedScrollView>
</android.support.design.widget.CoordinatorLayout>
<android.support.design.widget.NavigationView
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="start"
android:background="#ffffff"
app:headerLayout="#layout/header"
app:itemIconTint="#color/colorPrimaryDark"
app:itemTextColor="#color/colorPrimaryDark"
app:menu="#menu/drawermenu" />
</android.support.v4.widget.DrawerLayout>
The collapsing toolbar gets stuck in mid way, when i restore the fragment(containing the collapsing toolbar) from back stack. It is collapsing perfectly initially, but when i put the fragment in back-stack, move to next fragment and come back to this fragment then it gets stuck mid-way
XML
<?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"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<android.support.design.widget.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:fitsSystemWindows="true"
android:minHeight="0dp"
app:elevation="0dp">
<android.support.design.widget.CollapsingToolbarLayout
android:id="#+id/collapsing_toolbar"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:contentScrim="?attr/colorPrimary"
app:expandedTitleMarginEnd="64dp"
app:expandedTitleMarginStart="48dp"
app:layout_scrollFlags="scroll|exitUntilCollapsed">
<FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:minHeight="200dp"
android:transitionName="frame_layout"
app:layout_collapseMode="parallax"
app:layout_scrollFlags="scroll|exitUntilCollapsed">
<TextView
android:id="#+id/tiffin_service_initials_text_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="40dp"
android:background="#color/colorPrimary"
android:fontFamily="sans-serif-light"
android:gravity="center"
android:text="AB"
android:textColor="#color/md_white_1000"
android:textSize="40sp"
android:transitionName="text_view" />
</FrameLayout>
<android.support.v7.widget.Toolbar
android:id="#+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
app:layout_collapseMode="pin"
app:layout_scrollFlags="scroll|enterAlways"
app:titleTextColor="#color/md_white_1000" />
</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"
app:layout_behavior="#string/appbar_scrolling_view_behavior">
<LinearLayout
android:id="#+id/linear_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<android.support.v7.widget.CardView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
app:cardCornerRadius="0dp"
app:cardElevation="2dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:orientation="horizontal">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_weight="1"
android:clickable="true"
android:foreground="?selectableItemBackground"
android:gravity="center"
android:orientation="horizontal"
android:padding="16dp">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/ic_star" />
<TextView
android:id="#+id/rating_text_view"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="8dp"
android:text="4.7"
android:textSize="20sp" />
</LinearLayout>
<View
android:layout_width="0.2dp"
android:layout_height="match_parent"
android:alpha="0.5"
android:background="#android:color/darker_gray" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_weight="1"
android:clickable="true"
android:foreground="?selectableItemBackground"
android:gravity="center"
android:orientation="horizontal"
android:padding="16dp">
<ImageView
android:layout_width="28dp"
android:layout_height="28dp"
android:scaleType="centerCrop"
android:src="#drawable/ic_call"
android:tint="#color/colorAccent" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="8dp"
android:text="#string/call"
android:textSize="20sp" />
</LinearLayout>
<View
android:layout_width="0.2dp"
android:layout_height="match_parent"
android:alpha="0.5"
android:background="#android:color/darker_gray" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_weight="1"
android:clickable="true"
android:foreground="?selectableItemBackground"
android:gravity="center"
android:orientation="horizontal"
android:padding="16dp">
<ImageView
android:layout_width="24dp"
android:layout_height="24dp"
android:scaleType="centerCrop"
android:src="#drawable/ic_chat"
android:tint="#color/md_blue_500" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="8dp"
android:text="Chat"
android:textSize="20sp" />
</LinearLayout>
</LinearLayout>
</android.support.v7.widget.CardView>
<android.support.v7.widget.CardView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
android:layout_marginTop="8dp"
app:cardCornerRadius="0dp"
app:cardElevation="2dp">
<LinearLayout
android:id="#+id/menu_linear_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:orientation="vertical"
android:padding="16dp">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:alpha="0.5"
android:text="#string/menu"
android:textSize="20sp" />
<ProgressBar
android:id="#+id/progress_bar"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginTop="16dp" />
<android.support.v7.widget.RecyclerView
android:id="#+id/menu_recycler_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:visibility="gone">
</android.support.v7.widget.RecyclerView>
</LinearLayout>
</android.support.v7.widget.CardView>
<android.support.v7.widget.CardView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
android:layout_marginTop="8dp"
app:cardCornerRadius="0dp"
app:cardElevation="2dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="16dp"
android:layout_marginLeft="16dp"
android:layout_marginTop="16dp"
android:alpha="0.5"
android:text="#string/address"
android:textSize="20sp" />
<com.google.android.gms.maps.MapView
android:id="#+id/map_view"
android:layout_width="match_parent"
android:layout_height="200dp">
</com.google.android.gms.maps.MapView>
<TextView
android:id="#+id/address_text_view"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="16dp"
android:textSize="12sp" />
</LinearLayout>
</android.support.v7.widget.CardView>
</LinearLayout>
</android.support.v4.widget.NestedScrollView>
</android.support.design.widget.CoordinatorLayout>