I have CoordinatorLayout with NestedScrollView and CollapsingToolbarLayout. I put everything inside CollapsingToolbarLayout which i want to show on screen first then add NestedScrollView to show more content but NestedScrollView is not visible on screen.
Here is my XML 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:fitsSystemWindows="true"
android:clipToPadding="false"
android:background="?android:attr/colorBackground"
android:id="#+id/viewuserProfileMain"
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.design.widget.AppBarLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true">
<android.support.design.widget.CollapsingToolbarLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<RelativeLayout
android:id="#+id/relativeParent"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
android:id="#+id/upCoverPhoto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#color/redName"/>
<!--PUT TOOLBAR HERE-->
<RelativeLayout
android:id="#+id/upDetails"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#drawable/diagonal_cut_layerlist"
android:elevation="12dp"
android:translationZ="12dp"
android:layout_marginLeft="15dp"
android:layout_marginRight="15dp"
android:layout_marginTop="115dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="115dp"
android:layout_marginRight="10dp"
android:gravity="end"
android:orientation="horizontal">
<Button
android:id="#+id/Button_FollowFriends"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
style="#style/AppButton"
android:text="Follow"
/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<de.hdodenhof.circleimageview.CircleImageView
android:id="#+id/profilePicture_Cut"
android:layout_width="80dp"
android:layout_height="80dp"
android:src="#drawable/baby"
app:civ_border_width="2dp"
app:civ_border_color="#color/primary"
android:layout_marginTop="85dp"
android:layout_marginLeft="15dp"/>
<TextView
android:id="#+id/upUserName"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#color/secondary_text"
android:layout_marginTop="10dp"
android:textSize="28sp"
android:layout_marginLeft="10dp"
android:text="Susan Ledger"/>
<TextView
android:id="#+id/upUserCity"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:drawableLeft="#drawable/home"
android:drawablePadding="5dp"
android:layout_marginTop="5dp"
android:layout_marginLeft="10dp"
android:textSize="18sp"
android:textColor="#color/secondary_text"
android:text="Delhi,India"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="15dp"
android:gravity="center"
android:orientation="horizontal"
android:weightSum="3">
<Button
android:id="#+id/Button_AddFriend"
android:layout_width="0dp"
android:layout_height="wrap_content"
style="#style/AppButton"
android:text="Add Friend"
android:layout_weight="1"/>
<Button
android:id="#+id/Button_RejectRequest"
android:layout_width="0dp"
android:layout_height="wrap_content"
style="#style/AppButton"
android:text="Reject"
android:layout_weight="1"/>
<Button
android:id="#+id/Button_MessageFriend"
android:layout_width="0dp"
android:layout_height="wrap_content"
style="#style/AppButton"
android:text="Message"
android:layout_weight="1"/>
</LinearLayout>
</LinearLayout>
</RelativeLayout>
</RelativeLayout>
</android.support.design.widget.CollapsingToolbarLayout>
</android.support.design.widget.AppBarLayout>
<android.support.v4.widget.NestedScrollView
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="#+id/up_NestedScrollView"
android:fillViewport="true"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="#string/appbar_scrolling_view_behavior">
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingLeft="5dp"
android:paddingRight="5dp"
>
<!--To show tab on top of view pager-->
<android.support.design.widget.TabLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:tabMode="scrollable"
app:tabTextColor="#color/place_autocomplete_prediction_primary_text_highlight"
app:tabSelectedTextColor="#color/primary_text"
app:tabIndicatorColor="#color/primary_light"
android:id="#+id/up_Viewpager_Tab">
</android.support.design.widget.TabLayout>
<android.support.v4.view.ViewPager
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="#id/userProfile_Viewpager_Tab"
android:id="#+id/up_Viewpager_ViewPager">
</android.support.v4.view.ViewPager>
</RelativeLayout>
</android.support.v4.widget.NestedScrollView>
</android.support.design.widget.CoordinatorLayout>
try give
<android.support.design.widget.AppBarLayout
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:fitsSystemWindows="true">
Because AppBar could not be match_parent
Give wrap_content in height of your AppBarLayout
<android.support.design.widget.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
And
`android:fitsSystemWindows="false"
app:contentScrim="?attr/colorPrimary"
app:layout_scrollFlags="scroll|enterAlways"`
these lines to your CollapsingToolbarLayout
Related
I have an app and I want to animate the keyboard something like this:
OR is the gif is not working, you can go to this url and get the gif.
Please ignore the first image. I am asking about the second one.
What do I need to do to achieve such an animation? This is my xml code:
<?xml version="1.0" encoding="utf-8"?>
<androidx.coordinatorlayout.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent">
<FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="#+id/fragmentContainer"
android:visibility="gone"/>
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<com.google.android.material.appbar.AppBarLayout
android:id="#+id/appBarLayout"
app:layout_constraintTop_toTopOf="parent"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<androidx.appcompat.widget.Toolbar
android:layout_width="match_parent"
android:layout_height="?actionBarSize"
app:navigationIcon="#drawable/left"
android:id="#+id/toolbar"
app:popupTheme="#style/Theme.MyApplication.PopupMenu">
<com.mikhaellopez.circularimageview.CircularImageView
android:id="#+id/image"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#mipmap/ic_launcher"
app:civ_border="false"
android:layout_margin="#dimen/_6sdp"/>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:orientation="vertical"
android:paddingStart="#dimen/_10sdp"
android:gravity="center_vertical">
<TextView
android:id="#+id/title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Telegram"
android:textColor="#color/white"
android:textStyle="bold"
android:textSize="#dimen/_13sdp"/>
<View
android:layout_width="wrap_content"
android:layout_height="#dimen/_3sdp"/>
<TextView
android:id="#+id/lastSeenTV"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="last seen 1 minute ago"
android:textSize="#dimen/_9sdp"
android:textColor="#color/white"/>
</LinearLayout>
</androidx.appcompat.widget.Toolbar>
</com.google.android.material.appbar.AppBarLayout>
<androidx.recyclerview.widget.RecyclerView
android:id="#+id/recyclerView"
app:layout_constraintTop_toBottomOf="#id/appBarLayout"
android:layout_width="match_parent"
android:layout_height="0dp"
app:layout_constraintBottom_toTopOf="#id/bottomBar"
android:padding="#dimen/_5sdp"
android:background="#E4E4E4"
app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager"
app:reverseLayout="true"
/>
<LinearLayout
android:id="#+id/bottomBar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:minHeight="#dimen/_40sdp"
android:orientation="vertical"
app:layout_constraintBottom_toBottomOf="parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:minHeight="#dimen/_40sdp"
android:orientation="horizontal"
android:background="#color/white">
<ImageView
android:id="#+id/emoji"
android:layout_width="#dimen/_23sdp"
android:layout_height="#dimen/_23sdp"
android:src="#drawable/emoji"
app:tint="#android:color/darker_gray"
android:layout_gravity="center_vertical"
android:layout_marginStart="#dimen/_7sdp"
android:background="?selectableItemBackgroundBorderless"/>
<com.vanniktech.emoji.EmojiEditText
android:id="#+id/message"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:hint="Message"
android:maxHeight="#dimen/_100sdp"
android:textColorHint="#android:color/darker_gray"
android:paddingVertical="#dimen/_7sdp"
android:paddingHorizontal="#dimen/_7sdp"
android:textColor="#android:color/darker_gray"
tools:text="#string/sample_long_text"
android:backgroundTint="#android:color/transparent"
tools:ignore="HardcodedText" />
<ImageView
android:id="#+id/send"
android:layout_width="#dimen/_23sdp"
android:layout_height="#dimen/_23sdp"
android:src="#drawable/send"
app:tint="#android:color/darker_gray"
android:layout_gravity="center_vertical"
android:layout_marginHorizontal="#dimen/_7sdp"
android:background="?selectableItemBackgroundBorderless"/>
</LinearLayout>
</LinearLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
</androidx.coordinatorlayout.widget.CoordinatorLayout>
Collapsing toolbar layout and the recycler view should work together while swiping but working separately.
suggest to me what to do! given below are my code and resulting gif part of my project.
the toolbar layout is not showing fully if I swipe the screen from bottom to top.
the toolbar layout is closed and only return if I swipe to toolbar layout separately.
i want to toolbar layout to be in the same manner when i swipe the screen up and down.
Code of my layout
<?xml version="1.0" encoding="utf-8"?>
<androidx.coordinatorlayout.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".ui.review.reviewActivity">
<com.google.android.material.appbar.AppBarLayout
android:id="#+id/app_bar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:fitsSystemWindows="true">
<com.google.android.material.appbar.CollapsingToolbarLayout
android:id="#+id/collaps_toolbar"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
app:contentScrim="?attr/colorPrimary"
app:expandedTitleMarginEnd="64dp"
app:expandedTitleMarginStart="48dp"
app:expandedTitleTextAppearance="#android:color/transparent"
app:layout_scrollFlags="scroll|exitUntilCollapsed"
app:titleEnabled="true">
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="150dp"
android:gravity="center_vertical"
app:layout_collapseMode="parallax"
app:layout_collapseParallaxMultiplier="0.7">
<ImageView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:contentDescription="TODO"
android:src="#drawable/cover_image"
app:layout_constraintTop_toTopOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
<FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_collapseMode="parallax">
<TextView
android:id="#+id/textView_title"
android:layout_width="wrap_content"
android:layout_height="?attr/actionBarSize"
android:layout_gravity="center_horizontal"
android:layout_marginTop="130dp"
android:gravity="center"
android:maxLines="1"
android:text="title"
android:textColor="#FFF"
android:textSize="24sp" />
</FrameLayout>
<androidx.appcompat.widget.Toolbar
android:id="#+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:theme="#style/Theme.AppTheme.PopupOverlay"
app:layout_collapseMode="parallax" />
</com.google.android.material.appbar.CollapsingToolbarLayout>
</com.google.android.material.appbar.AppBarLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="#string/appbar_scrolling_view_behavior">
<androidx.recyclerview.widget.RecyclerView
android:id="#+id/review_list"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fadeScrollbars="false"
android:scrollbars="vertical"
app:layout_behavior="#string/appbar_scrolling_view_behavior" />
</RelativeLayout>
</androidx.coordinatorlayout.widget.CoordinatorLayout>
Final result
Try this:
<?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"
xmlns:tools="http://schemas.android.com/tools"
android:id="#+id/itineraryListFragment"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="?android:windowBackground">
<androidx.coordinatorlayout.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent">
<com.google.android.material.appbar.AppBarLayout
android:id="#+id/app_bar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:fitsSystemWindows="true">
<com.google.android.material.appbar.CollapsingToolbarLayout
android:id="#+id/toolbar_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:contentScrim="?attr/colorPrimary"
app:layout_scrollFlags="scroll|enterAlways">
<Button
android:id="#+id/button_arrow"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="#dimen/activity_start_margin"
android:layout_marginTop="#dimen/_20sdp"
android:layout_marginEnd="#dimen/activity_end_margin"
android:background="#null"
android:clickable="true"
android:drawableStart="#drawable/ic_arrow_booking_details"
android:gravity="start|center_vertical" />
<ImageView
android:id="#+id/iv_background_image"
android:layout_width="match_parent"
android:layout_height="#dimen/_123sdp"
android:contentDescription="#string/name_app"
android:scaleType="centerCrop"
app:srcCompat="#drawable/booking_details_background" />
<ImageView
android:id="#+id/iv_background_rectangle"
android:layout_width="match_parent"
android:layout_height="#dimen/_123sdp"
android:scaleType="centerCrop"
app:layout_collapseMode="parallax"
app:srcCompat="#drawable/rectangle_booking_details" />
<TextView
android:id="#+id/tv_background_title"
style="#style/font_title_bookingdetails"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="#dimen/activity_start_margin"
android:layout_marginTop="95dp"
android:layout_marginEnd="#dimen/activity_end_margin"
android:gravity="start|center_vertical"
android:text="#string/text_trek_everest_name"
android:textColor="#color/colorPrimary" />
<androidx.constraintlayout.widget.Guideline
android:id="#+id/guideline9"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
app:layout_constraintGuide_begin="26dp" />
<androidx.appcompat.widget.Toolbar
android:layout_width="?attr/actionBarSize"
android:layout_height="wrap_content"
app:layout_collapseMode="pin"
app:layout_scrollFlags="scroll|enterAlways"
app:popupTheme="#style/ThemeOverlay.AppCompat.Light" />
</com.google.android.material.appbar.CollapsingToolbarLayout>
</com.google.android.material.appbar.AppBarLayout>
<androidx.core.widget.NestedScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_behavior="#string/appbar_scrolling_view_behavior">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView
android:id="#+id/tv_title_itinerary_list"
style="#style/font_title_day1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="#dimen/activity_start_margin"
android:layout_marginTop="#dimen/_15sdp"
android:layout_marginBottom="#dimen/activity_end_margin"
android:gravity="center_vertical"
android:text="#string/dashboard_itinerary"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.235" />
<include layout="#layout/booking_itinerary_recyclerview" />
</LinearLayout>
</androidx.core.widget.NestedScrollView>
</androidx.coordinatorlayout.widget.CoordinatorLayout>
</FrameLayout>
This is the output of this code.
:)
I want to change my constraintlayout to a LinearLayout. I tried it with the green (second area) and it worked perfectly. Unfortunately, the top part doesn't work as well as the bottom part. The problem is that the red area always occupies the entire area and does not go to the toolbar.
How can I make the height of the red area only up to the toolbar + distance?
I don't want to change something "more" in my Toolbar XML, otherwise the layout on all other pages is wrong.
Is there an option that allows android: layout_height = "match_parent- toolbar"?
I would like it to end up looking like the second picture. The red area should be at a distance from the toolbar and be at a maximum. So no matter how much content is in the red area, it should always be as large as possible by far. How can I do that? I'm really looking forward to helpful answers! Thanks in advance.
My current status:
What I want to achieve:
My try
<?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:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#ececec"
android:orientation="horizontal">
<androidx.cardview.widget.CardView
android:id="#+id/cardViewMiddle"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="center"
android:layout_marginBottom="8dp"
android:elevation="8dp"
android:layout_marginTop="20dp"
android:layout_marginEnd="8dp"
android:layout_marginStart="8dp"
android:gravity="center"
app:cardBackgroundColor="#color/Red"
app:cardCornerRadius="15dp">
</androidx.cardview.widget.CardView>
</LinearLayout>
XML
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.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:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#ececec">
<androidx.cardview.widget.CardView
android:id="#+id/cardViewMiddle"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_gravity="center"
android:layout_marginBottom="8dp"
android:elevation="8dp"
android:layout_marginEnd="8dp"
android:layout_marginStart="8dp"
android:gravity="center"
app:cardBackgroundColor="#color/Red"
app:cardCornerRadius="15dp"
app:layout_constraintBottom_toTopOf="#+id/cardViewCheckout"
app:layout_constraintTop_toTopOf="parent">
</androidx.cardview.widget.CardView>
<androidx.cardview.widget.CardView
android:id="#+id/cardViewCheckout"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_alignParentStart="true"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:layout_marginStart="24dp"
android:layout_marginEnd="24dp"
android:layout_marginBottom="10dp"
android:elevation="8dp"
app:cardBackgroundColor="#fff"
app:cardCornerRadius="15dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_gravity="center">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_marginTop="5sp"
android:layout_marginBottom="5sp"
android:layout_gravity="center">
<TextView
android:id="#+id/textViewSumme"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Summe "
android:layout_gravity="center"/>
<TextView
android:id="#+id/textViewSumme2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="0,00"
android:layout_gravity="center"/>
</LinearLayout>
<Button
android:id="#+id/btn_user_geldaufladen"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:background="#drawable/button_order_checkout"
android:backgroundTint="#04C3B1"
android:elevation="16dp"
android:text="AUFLADEN"
android:textColor="#FFFFFF"
android:textStyle="bold"
android:layout_marginBottom="10sp"/>
</LinearLayout>
</androidx.cardview.widget.CardView>
</androidx.constraintlayout.widget.ConstraintLayout>
Toolbar
<androidx.coordinatorlayout.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".UserHomeActivity">
<com.google.android.material.appbar.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="#style/AppTheme.AppBarOverlay">
<androidx.appcompat.widget.Toolbar
android:id="#+id/toolbar"
android:layout_width="match_parent"
android:layout_height="45dp"
android:background="?attr/colorPrimary"
app:popupTheme="#style/AppTheme.PopupOverlay" />
</com.google.android.material.appbar.AppBarLayout>
<include layout="#layout/user_content_main"
/>
</androidx.coordinatorlayout.widget.CoordinatorLayout>
Try this.
<?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"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#ececec"
android:padding="16dp"
android:orientation="vertical"
android:layout_below="#+id/appBar"
android:weightSum="10">
<androidx.cardview.widget.CardView
android:id="#+id/cardViewMiddle"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="7"
android:layout_gravity="center"
android:layout_marginBottom="8dp"
android:elevation="8dp"
android:layout_marginEnd="24dp"
android:layout_marginStart="24dp"
android:gravity="center"
app:cardBackgroundColor="#f00"
app:cardCornerRadius="15dp"
app:layout_constraintBottom_toTopOf="#+id/cardViewCheckout"
app:layout_constraintTop_toTopOf="parent">
</androidx.cardview.widget.CardView>
<androidx.cardview.widget.CardView
android:id="#+id/cardViewCheckout"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="3"
android:layout_marginStart="24dp"
android:layout_marginEnd="24dp"
android:layout_marginBottom="10dp"
android:elevation="8dp"
app:cardBackgroundColor="#fff"
app:cardCornerRadius="15dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_gravity="center">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_marginTop="5sp"
android:layout_marginBottom="5sp"
android:layout_gravity="center">
<TextView
android:id="#+id/textViewSumme"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Summe "
android:layout_gravity="center"/>
<TextView
android:id="#+id/textViewSumme2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="0,00"
android:layout_gravity="center"/>
</LinearLayout>
<Button
android:id="#+id/btn_user_geldaufladen"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:background="#color/colorPrimaryDark"
android:backgroundTint="#04C3B1"
android:elevation="16dp"
android:text="AUFLADEN"
android:textColor="#FFFFFF"
android:textStyle="bold"
android:layout_marginBottom="10sp"/>
</LinearLayout>
</androidx.cardview.widget.CardView>
</LinearLayout>
<com.google.android.material.appbar.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/appBar"
>
<androidx.appcompat.widget.Toolbar
android:id="#+id/toolbar"
android:layout_width="match_parent"
android:layout_height="45dp"
android:background="?attr/colorPrimary"
/>
</com.google.android.material.appbar.AppBarLayout>
</RelativeLayout>
Could you try to replace your (include) tag with this:
<include layout="#layout/user_content_main"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="com.google.android.material.appbar.AppBarLayout$ScrollingViewBehavior"
/>
I want to create like bellow image.
For creating like this I write the bellow code.
<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:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="posoft.shariful.rupkotharpata.Profile"
android:orientation="vertical">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="220dp">
<include layout="#layout/toolbar"></include>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="220dp"
android:background="#drawable/b1"
android:orientation="horizontal">
<ImageView
android:layout_width="80dp"
android:layout_height="80dp"
android:contentDescription="#string/todo"
android:src="#drawable/p1"
android:layout_gravity="center_vertical"
android:layout_marginTop="10dp"
android:layout_marginStart="20dp"/>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_gravity="bottom"
android:layout_marginStart="10dp"
android:layout_marginBottom="20dp"
android:paddingTop="5dp"
android:paddingBottom="5dp"
android:paddingStart="10dp"
android:paddingEnd="10dp">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="30sp"
android:text="#string/test_user_full_name"
android:textColor="#color/white" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="19sp"
android:text="#string/test_user"
android:textColor="#color/white"
android:layout_marginTop="5dp"/>
</LinearLayout>
</LinearLayout>
</RelativeLayout>
</LinearLayout>
It working. But the problem is, It don't show app toolbar.
Note : The tools of toolbar working.
Now how I can show toolbar or toolbar tools?
This is happening because your LinearLayout is displaying over your toolbar(Views inside a RelativeLayout display over one other, and you haven't mentioned any view to display above or below the other one).
Assign an id to your toolbar, and instruct your LinearLayout to be below it, something like this:
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="220dp">
<include
android:id="#+id/toolbar"
layout="#layout/toolbar"></include>
<LinearLayout
android:layout_below="#+id/toolbar"
android:layout_width="match_parent"
android:layout_height="220dp"
android:background="#drawable/b1"
android:orientation="horizontal">
You might also need to increase your parent RelativeLayout's height from 220dp to something like 250dp to accommodate both the children without clipping the bottom one.
You need to use CollapsingToolbarLayout with AppBarLayout over there.
For your reference I have posted one xml file. refer this..
<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"
xmlns:custom="http://schemas.android.com/apk/res-auto"
android:id="#+id/coordinator_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.news.moneycontrol.MainActivity">
<android.support.v4.widget.SwipeRefreshLayout
android:id="#+id/swipe_refresh_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="#string/appbar_scrolling_view_behavior">
<android.support.v7.widget.RecyclerView
android:id="#+id/recycler_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#color/bg_dashboard"
/>
</android.support.v4.widget.SwipeRefreshLayout>
<android.support.design.widget.AppBarLayout
android:id="#+id/appbar_layout"
android:layout_width="match_parent"
android:layout_height="240dp"
app:theme="#style/ThemeOverlay.AppCompat.Dark.ActionBar">
<android.support.design.widget.CollapsingToolbarLayout
android:id="#+id/collapsing_toolbar"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:elevation="#dimen/toolbar_elevation"
app:contentScrim="?attr/colorPrimary"
app:layout_scrollFlags="scroll|exitUntilCollapsed">
<!-- <ImageView
android:id="#+id/flexible_image"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:src="#mipmap/home_cover"
android:scaleType="centerCrop"
app:layout_collapseMode="parallax"/>-->
<android.support.v7.widget.Toolbar
android:id="#+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="#android:color/transparent"
app:contentInsetLeft="0dp"
app:contentInsetStart="0dp"
app:contentInsetStartWithNavigation="0dp"
app:layout_collapseMode="pin" />
</android.support.design.widget.CollapsingToolbarLayout>
</android.support.design.widget.AppBarLayout>
<com.news.moneycontrol.progressbar.CircularProgressView
android:id="#+id/progress_view"
android:layout_width="40dp"
android:layout_height="40dp"
android:layout_gravity="center"
android:padding="0dp"
android:layout_marginTop="100dp"
app:cpv_animAutostart="false"
app:cpv_indeterminate="true"
app:cpv_thickness="4dp" />
<ImageView
android:id="#+id/no_internet"
android:layout_width="100dp"
android:layout_height="100dp"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_gravity="center"
android:layout_marginTop="150dp"
android:visibility="invisible"
android:src="#mipmap/ic_connection_error" />
<com.xxx.CustomFont
android:id="#+id/text_internet"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="24sp"
android:paddingLeft="10dp"
android:paddingRight="10dp"
android:textColor="#9B9B9B"
android:layout_gravity="center"
android:text="No Internet Connection"
android:textStyle="bold"
android:visibility="invisible"
android:layout_marginTop="270dp"
android:paddingBottom="10dp"/>
</android.support.design.widget.CoordinatorLayout>
hope you have listed below necessary gradles!
compile 'com.android.support:appcompat-v7:25.2.0'
compile 'com.android.support:recyclerview-v7:25.2.0'
compile 'com.android.support:cardview-v7:25.2.0'
compile 'com.android.support:design:25.2.0'
Add new scroll activity then in activity layout file put imageview in collapsing toolbar layout
<android.support.design.widget.CollapsingToolbarLayout
android:id="#+id/toolbar_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#drawable/test_background_image"
android:fitsSystemWindows="true"
app:contentScrim="?attr/colorPrimary"
app:layout_collapseMode="pin"
app:layout_scrollFlags="scroll|exitUntilCollapsed">
<ImageView
android:id="#+id/groupImage"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scaleType="fitXY" />
</android.support.design.widget.CollapsingToolbarLayout>
Wrap the layout in toolbar as follows
<?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:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.v7.widget.Toolbar
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:contentInsetLeft="0dp"
android:contentInsetStart="0dp"
app:contentInsetLeft="0dp"
app:contentInsetStart="0dp"
android:contentInsetRight="0dp"
android:contentInsetEnd="0dp"
app:contentInsetRight="0dp"
app:contentInsetEnd="0dp"
>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="220dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="220dp"
android:background="#color/colorPrimaryDark"
android:orientation="horizontal">
<ImageView
android:layout_width="80dp"
android:layout_height="80dp"
android:contentDescription="todo"
android:src="#color/colorPrimaryDark"
android:layout_gravity="center_vertical"
android:layout_marginTop="10dp"
/>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_gravity="bottom"
android:layout_marginBottom="20dp"
android:paddingTop="5dp"
android:paddingBottom="5dp"
android:paddingStart="10dp"
android:paddingEnd="10dp">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="30sp"
android:text="Full name"
android:textColor="#color/colorAccent" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="19sp"
android:text="user"
android:textColor="#color/theme_color"
android:layout_marginTop="5dp"/>
</LinearLayout>
</LinearLayout>
</RelativeLayout>
</LinearLayout>
</android.support.v7.widget.Toolbar>
</LinearLayout>
I have Activity where I have a CollapsingTableLayout and I'd to display in the bottom of the screen an Editext but I have some problems
When I scroll to bottom, all text not displayed
And when I clic in Editext in the bottom, Toolbar is not displayed
I follow this link to do this
Here is my Layout
<?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.support.design.widget.CoordinatorLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
tools:context=".DetailActivity">
<android.support.design.widget.AppBarLayout
android:id="#+id/appBarLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:fitsSystemWindows="true"
android:theme="#style/ThemeOverlay.AppCompat.Dark.ActionBar">
<android.support.design.widget.CollapsingToolbarLayout
android:id="#+id/collapsing_toolbar"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
app:contentScrim="?attr/colorPrimary"
app:expandedTitleMarginEnd="64dp"
app:expandedTitleMarginStart="48dp"
app:layout_scrollFlags="scroll|exitUntilCollapsed">
<ImageView
android:id="#+id/image_toolbar"
android:layout_width="match_parent"
android:layout_height="250dp"
android:scaleType="centerCrop"
app:layout_collapseMode="parallax" />
<android.support.v7.widget.Toolbar
android:id="#+id/toolbar"
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:id="#+id/scroll"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="#string/appbar_scrolling_view_behavior"
app:behavior_overlapTop="64dp">
<android.support.v7.widget.CardView
app:cardElevation="6dp"
android:id="#+id/detail_info"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="10dp">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:id="#+id/detail_title"
android:text="Title"
android:textSize="20dp"
android:layout_marginHorizontal="10dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textColor="#android:color/black"/>
<TextView
android:id="#+id/detail_description"
android:text="Description"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/detail_title"
android:textColor="#android:color/black"
android:layout_margin="10dp"/>
</RelativeLayout>
</android.support.v7.widget.CardView>
</android.support.v4.widget.NestedScrollView>
</android.support.design.widget.CoordinatorLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:background="#android:color/darker_gray">
<EditText
android:id="#+id/detail_comment"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="6"/>
<ImageView
android:id="#+id/detail_add_comment"
android:text="add"
android:layout_width="0dp"
android:layout_height="match_parent"
android:src="#mipmap/ic_send"
android:layout_weight="1"/>
</LinearLayout>
</RelativeLayout>
Thank you for help