Hi I have complex layout includes views on top and recycle view at bottom recycle view data can go up to 5000 rows when using nested scroll view it will freez for long time when use normal scroll view its working but only recycle view will be scrolling but i want all views to scroll
<?xml version="1.0" encoding="utf-8"?>
<layout 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">
<data>
<import type="android.view.View"/>
<variable
name="item"
type="xxx.models.Category" />
<variable
name="query"
type="String" />
</data>
<ScrollView
android:id="#+id/sc"
android:layout_width="match_parent"
android:layout_height="wrap_content"
tools:ignore="UselessParent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="#dimen/_5sdp"
android:orientation="vertical"
tools:context=".ui.home.HomeFragment">
<LinearLayout
android:visibility="#{query.isEmpty() ? View.GONE : View.VISIBLE,default= gone}"
android:orientation="horizontal"
android:layout_width="match_parent"
android:gravity="center_vertical"
android:layout_marginBottom="#dimen/_5sdp"
android:layout_marginHorizontal="#dimen/_5sdp"
android:background="#color/darkgrey"
android:layout_height="wrap_content">
<TextView
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="wrap_content"
tools:text="Abaya"
android:text= "#{String.format(#string/query, query)}"
android:layout_margin="#dimen/_5sdp"
android:maxLines="1"
android:ellipsize="end"
android:gravity="center"
android:textColor="#color/white"
android:padding="#dimen/_5sdp"
style="#style/titleText" />
<ImageView
android:id="#+id/clear"
android:layout_width="#dimen/_24sdp"
android:layout_height="#dimen/_24sdp"
android:layout_marginHorizontal="#dimen/_5sdp"
android:foreground="?attr/selectableItemBackground"
android:src="#drawable/ic_close"
app:tint="#color/white" />
</LinearLayout>
<androidx.cardview.widget.CardView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginHorizontal="#dimen/_5sdp"
app:cardCornerRadius="#dimen/_5sdp">
<ae.eds.fatima.helper.SliderView
android:id="#+id/slider"
android:overScrollMode="never"
android:layout_width="match_parent"
app:cardElevation="#dimen/_5sdp"
android:layout_height="#dimen/_120sdp" />
</androidx.cardview.widget.CardView>
<androidx.recyclerview.widget.RecyclerView
android:id="#+id/categories"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:overScrollMode="never"
android:layout_gravity="start"
android:layout_marginTop="#dimen/_5sdp"
tools:itemCount="8"
app:spanCount="4"
android:orientation="vertical"
app:layoutManager="androidx.recyclerview.widget.GridLayoutManager"
tools:listitem="#layout/home_subcategory_entry" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="#dimen/_5sdp"
android:orientation="horizontal">
<TextView
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="wrap_content"
android:textSize="#dimen/header4"
android:textColor="#color/black"
android:text="Recomended" />
<TextView
android:id="#+id/filter"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="end"
android:textSize="#dimen/header4"
android:drawableStart="#drawable/ic_filter"
android:textColor="#color/black"
android:text="Filter" />
</LinearLayout>
<androidx.recyclerview.widget.RecyclerView
android:id="#+id/products"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:nestedScrollingEnabled="true"
android:overScrollMode="never"
android:orientation="vertical"
tools:itemCount="10"
app:spanCount="2"
app:layoutManager="androidx.recyclerview.widget.GridLayoutManager"
tools:listitem="#layout/product_entry" />
</LinearLayout>
</ScrollView>
</layout>
I tried nestedscroll false and using fragment type but looking forother soultion like how to measure and update scrollview height after update adapter
try to use collapsing layout instead of nested scroll view
<?xml version="1.0" encoding="utf-8"?>
<layout 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">
<data>
<import type="android.view.View"/>
<variable
name="item"
type="xxx.models.Category" />
<variable
name="query"
type="String" />
</data>
<androidx.coordinatorlayout.widget.CoordinatorLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<com.google.android.material.appbar.AppBarLayout
android:id="#+id/appbar"
android:background="#color/layoutBg"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<com.google.android.material.appbar.CollapsingToolbarLayout
android:id="#+id/collapsing_toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:contentScrim="?attr/colorPrimary"
app:layout_scrollFlags="scroll|exitUntilCollapsed">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="#dimen/_5sdp"
android:orientation="vertical"
tools:context=".ui.home.HomeFragment">
<LinearLayout
android:visibility="#{query.isEmpty() ? View.GONE : View.VISIBLE,default= gone}"
android:orientation="horizontal"
android:layout_width="match_parent"
android:gravity="center_vertical"
android:layout_marginBottom="#dimen/_5sdp"
android:layout_marginHorizontal="#dimen/_5sdp"
android:background="#color/darkgrey"
android:layout_height="wrap_content">
<TextView
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="wrap_content"
tools:text="Abaya"
android:text= "#{String.format(#string/query, query)}"
android:layout_margin="#dimen/_5sdp"
android:maxLines="1"
android:ellipsize="end"
android:gravity="center"
android:textColor="#color/white"
android:padding="#dimen/_5sdp"
style="#style/titleText" />
<ImageView
android:id="#+id/clear"
android:layout_width="#dimen/_24sdp"
android:layout_height="#dimen/_24sdp"
android:layout_marginHorizontal="#dimen/_5sdp"
android:foreground="?attr/selectableItemBackground"
android:src="#drawable/ic_close"
app:tint="#color/white" />
</LinearLayout>
<androidx.cardview.widget.CardView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginHorizontal="#dimen/_5sdp"
app:cardCornerRadius="#dimen/_5sdp">
<ae.eds.fatima.helper.SliderView
android:id="#+id/slider"
android:overScrollMode="never"
android:layout_width="match_parent"
app:cardElevation="#dimen/_5sdp"
android:visibility="gone"
android:layout_height="#dimen/_120sdp" />
</androidx.cardview.widget.CardView>
<androidx.recyclerview.widget.RecyclerView
android:id="#+id/categories"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:overScrollMode="never"
android:layout_gravity="start"
android:layout_marginTop="#dimen/_5sdp"
tools:itemCount="8"
app:spanCount="4"
android:orientation="vertical"
app:layoutManager="androidx.recyclerview.widget.GridLayoutManager"
tools:listitem="#layout/home_subcategory_entry" />
</LinearLayout>
</com.google.android.material.appbar.CollapsingToolbarLayout>
</com.google.android.material.appbar.AppBarLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_behavior="#string/appbar_scrolling_view_behavior"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="#dimen/_35sdp"
android:gravity="center_vertical"
android:paddingHorizontal="#dimen/_10sdp"
android:orientation="horizontal">
<TextView
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="match_parent"
android:textSize="#dimen/header4"
android:gravity="center_vertical"
android:textColor="#color/black"
android:text="#string/recommended" />
<TextView
android:id="#+id/filter"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="end"
android:gravity="center_vertical"
android:textSize="#dimen/header4"
android:textColor="#color/black"
android:text="#string/filter_sort"
app:drawableStartCompat="#drawable/ic_filter" />
</LinearLayout>
<androidx.recyclerview.widget.RecyclerView
android:id="#+id/products"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:overScrollMode="never"
android:orientation="vertical"
tools:itemCount="10"
app:spanCount="2"
app:layout_behavior="#string/appbar_scrolling_view_behavior"
app:layoutManager="androidx.recyclerview.widget.GridLayoutManager"
tools:listitem="#layout/product_entry" />
</LinearLayout>
</androidx.coordinatorlayout.widget.CoordinatorLayout>
</layout>
Related
I want to scroll tollbar while scrolling fragment in drawer layout.
Below is my xml layouts:
activity_main.xml
<?xml version="1.0" encoding="utf-8"?>
<layout 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">
<data></data>
<androidx.drawerlayout.widget.DrawerLayout
android:id="#+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#color/colorPrimary"
android:elevation="0dp"
android:keepScreenOn="true"
app:elevation="0dp"
tools:context=".ui.activities.CulpabilityHome">
<FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:id="#+id/llOutertwo"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="#dimen/_70sdp"
android:layout_marginBottom="#dimen/_70sdp"
android:background="#color/red"
android:orientation="horizontal"
android:visibility="visible" />
<LinearLayout
android:id="#+id/llOuterone"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginStart="#dimen/_10sdp"
android:layout_marginTop="#dimen/_40sdp"
android:layout_marginBottom="#dimen/_40sdp"
android:background="#color/black"
android:orientation="horizontal"
android:visibility="visible" />
<LinearLayout
android:id="#+id/llToolbar"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#color/gray_bg"
android:orientation="vertical">
<include
android:id="#+id/navHeader"
layout="#layout/layout_home_toolbar" />
<View
android:layout_width="match_parent"
android:layout_height="#dimen/_1sdp"
android:background="#color/gray_bg" />
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport="true"
android:scrollbars="none">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<LinearLayout
android:id="#+id/bottomNavigation"
android:layout_width="match_parent"
android:layout_height="#dimen/_40sdp"
android:layout_gravity="bottom"
android:background="#color/white"
android:gravity="center_vertical|center_horizontal"
android:orientation="horizontal">
<ImageView
android:id="#+id/home"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="#dimen/_5sdp"
android:layout_marginEnd="#dimen/_5sdp"
android:layout_weight="0.25"
android:padding="#dimen/_10sdp"
android:src="#mipmap/home"
tools:ignore="RtlCompat" />
<ImageView
android:id="#+id/map"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="#dimen/_5sdp"
android:layout_weight="0.25"
android:padding="#dimen/_10sdp"
android:src="#mipmap/map"
tools:ignore="RtlCompat" />
<ImageView
android:id="#+id/myVideo"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="#dimen/_5sdp"
android:layout_weight="0.25"
android:padding="#dimen/_10sdp"
android:src="#drawable/ic_my_video"
tools:ignore="RtlCompat" />
<!-- <ImageView-->
<!-- android:id="#+id/chat"-->
<!-- android:layout_width="match_parent"-->
<!-- android:layout_height="wrap_content"-->
<!-- android:layout_marginStart="#dimen/_5sdp"-->
<!-- android:layout_marginEnd="#dimen/_5sdp"-->
<!-- android:layout_weight="0.25"-->
<!-- android:padding="#dimen/_10sdp"-->
<!-- android:src="#mipmap/chats_icon"-->
<!-- tools:ignore="RtlCompat" />-->
<FrameLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="0.25">
<ImageView
android:id="#+id/notification"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="#dimen/_5sdp"
android:layout_marginEnd="#dimen/_5sdp"
android:padding="#dimen/_10sdp"
android:src="#mipmap/notification"
tools:ignore="RtlCompat" />
<TextView
android:id="#+id/txtNotificationCountBadge"
android:layout_width="#dimen/_17sdp"
android:layout_height="#dimen/_17sdp"
android:layout_gravity="top"
android:layout_marginStart="50dp"
android:layout_marginTop="3dp"
android:layout_marginEnd="-5dp"
android:background="#drawable/circle_notification_badge"
android:gravity="center"
android:text="99+"
android:textColor="#android:color/white"
android:textSize="9sp"
android:visibility="gone"
tools:visibility="visible" />
</FrameLayout>
</LinearLayout>
<View
android:layout_width="match_parent"
android:layout_height="#dimen/_1sdp"
android:background="#color/gray_bg" />
<FrameLayout
android:id="#+id/home_fram"
android:layout_width="match_parent"
android:layout_height="match_parent"
/>
</LinearLayout>
</ScrollView>
</LinearLayout>
</FrameLayout>
<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:background="#color/colorPrimary"
android:fitsSystemWindows="true"
app:elevation="0dp"
app:headerLayout="#layout/nav_header_main"
app:itemBackground="#android:color/transparent"
app:itemIconTint="#color/white"
app:itemTextColor="#color/white"
app:itemVerticalPadding="#dimen/_12sdp"
app:menu="#menu/activity_main_drawer">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:orientation="vertical"
android:padding="#dimen/_16sdp">
<TextView
android:id="#+id/txtVersion"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:fontFamily="#font/gt_walsheim_pro_light"
android:gravity="start"
android:text="#string/app_version"
android:textColor="#color/white"
android:textSize="#dimen/_10sdp" />
</LinearLayout>
</com.google.android.material.navigation.NavigationView>
</androidx.drawerlayout.widget.DrawerLayout>
</layout>
layout_home_toolbar.xml
<?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="wrap_content"
app:layout_scrollFlags="scroll|enterAlways">
<androidx.appcompat.widget.Toolbar
android:id="#+id/mainTool"
android:layout_width="match_parent"
android:layout_height="?actionBarSize"
android:background="#color/white"
android:contentInsetStart="0dp"
android:contentInsetLeft="0dp"
android:contentInsetEnd="0dp"
android:contentInsetRight="0dp"
app:contentInsetEnd="0dp"
app:contentInsetLeft="0dp"
app:contentInsetRight="0dp"
app:contentInsetStart="0dp"
>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<de.hdodenhof.circleimageview.CircleImageView
android:id="#+id/HeaderToolLogo"
android:layout_width="#dimen/_32sdp"
android:layout_height="#dimen/_32sdp"
android:layout_alignParentStart="true"
android:layout_centerVertical="true"
android:layout_marginStart="#dimen/_10sdp"
android:src="#mipmap/culpa_header_icon"
app:civ_border_color="#color/colorPrimary"
app:civ_border_width="#dimen/_1sdp" />
<TextView
android:id="#+id/HeaderToolText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:fontFamily="#font/gt_walsheim_pro_medium"
android:text="#string/home"
android:textColor="#color/colorPrimary"
android:textSize="#dimen/_15ssp" />
<ImageView
android:id="#+id/search"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_marginStart="#dimen/_5sdp"
android:layout_toStartOf="#+id/chat"
android:padding="#dimen/_5sdp"
android:src="#mipmap/search_home"
app:tint="#color/colorPrimary"
tools:ignore="RtlCompat" />
<ImageView
android:id="#+id/chat"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_centerVertical="true"
android:layout_marginStart="#dimen/_5sdp"
android:layout_marginEnd="#dimen/_5sdp"
android:layout_weight="0.25"
android:padding="#dimen/_5sdp"
android:src="#mipmap/chats_icon"
app:tint="#color/colorPrimary"
tools:ignore="RtlCompat" />
</RelativeLayout>
</androidx.appcompat.widget.Toolbar>
</LinearLayout>
I want to make toolbar hide while user scroll content like facebook.
I also tried to Appbarlayout but its not working so please help me to solve this issue.
Thanks in advance
I am very confused why my recyclerview has this huge extra space between it. I am still new to design in Android and will appreciate feedback.
Here is my student_layout to be displayed in the recyclerview
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout
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"
xmlns:tools="http://schemas.android.com/tools">
<LinearLayout
android:id="#+id/linearLayout"
android:layout_width="match_parent"
android:layout_height="74dp"
android:layout_marginTop="6dp"
android:orientation="horizontal"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.8"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
<LinearLayout
android:layout_width="174dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:orientation="vertical">
<TextView
android:id="#+id/username"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingTop="#dimen/usernamePaddingTop"
android:textColor="#color/_black"
android:textSize="#dimen/usernameTextSize"
tools:text="Student" />
</LinearLayout>
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center"
android:textSize="15sp"
android:paddingTop="4dp"
android:textColor="#color/grey"/>
<androidx.appcompat.widget.AppCompatButton
android:id="#+id/login"
android:layout_width="#dimen/loginWidth"
android:layout_height="#dimen/loginHeight"
android:layout_weight="1"
android:visibility="gone"
android:paddingLeft="#dimen/loginPadding"
android:paddingRight="#dimen/loginPadding"
android:drawableStart="#drawable/blue_button"
android:background="#drawable/blue_background" />
</LinearLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
My MainFragment with a Recyclcer view
<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/main"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".ui.main.MainFragment">
<androidx.recyclerview.widget.RecyclerView
android:id="#+id/studentlogs"
app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager"
android:layout_width="match_parent"
android:layout_height="wrap_content"
tools:listitem="#layout/student_logs_fragment"
/>
</LinearLayout>
The image on my emulator
change android:layout_width="match_parent" to android:layout_width="wrap_content" and android:layout_height="match_parent" to android:layout_height="wrap_content" in student_layout xml file.
<androidx.constraintlayout.widget.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_parent"
android:layout_height="wrap_parent"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools">
You have to try wrap_parent instead of match_parent in constraintLayout.
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_parent"
android:layout_height="wrap_parent"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools">
<LinearLayout
android:id="#+id/linearLayout"
android:layout_width="match_parent"
android:layout_height="74dp"
android:layout_marginTop="6dp"
android:orientation="horizontal"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.8"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
<LinearLayout
android:layout_width="174dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:orientation="vertical">
<TextView
android:id="#+id/username"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingTop="#dimen/usernamePaddingTop"
android:textColor="#color/_black"
android:textSize="#dimen/usernameTextSize"
tools:text="Student" />
</LinearLayout>
<TextView
android:id="#+id/time"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center"
android:textSize="15sp"
android:paddingTop="4dp"
android:textColor="#color/grey"/>
<androidx.appcompat.widget.AppCompatButton
android:id="#+id/login"
android:layout_width="#dimen/loginWidth"
android:layout_height="#dimen/loginHeight"
android:layout_weight="1"
android:visibility="gone"
android:paddingLeft="#dimen/loginPadding"
android:paddingRight="#dimen/loginPadding"
android:drawableStart="#drawable/blue_button"
android:background="#drawable/blue_background" />
</LinearLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
Replace the code at student_layout
I have an AppBar and other things in my layout. When the user scrolls down, I want AppBar(actually, the Toolbar to hide. This is what I have tried, the app bar isn't hiding all small part it just stays there. Actually I think the problem is with my header of the screen it gets collapsed and adds a small space when I scroll.
As you can see in second image some part stays it doesn't hide. I need to hide that part while scrolling.
Please provide me solution what am I doing wrong?
<?xml version="1.0" encoding="utf-8"?>
<layout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<androidx.coordinatorlayout.widget.CoordinatorLayout
android:id="#+id/activity_main"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
android:orientation="vertical">
<com.google.android.material.appbar.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#color/white">
<com.google.android.material.appbar.CollapsingToolbarLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
app:contentScrim="?attr/colorPrimary"
app:expandedTitleTextAppearance="#style/TextAppearance.AppCompat.Title"
app:layout_scrollFlags="scroll|exitUntilCollapsed"
app:titleEnabled="false">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:orientation="vertical">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<ImageView
android:id="#+id/slideIV"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:adjustViewBounds="true"
android:src="#drawable/ic_dish" />
<View
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_above="#+id/bottomButtonRL"
android:layout_gravity="bottom"
android:background="#drawable/gradient_bg" />
<View style="#style/itemBottomViewLarge" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_margin="#dimen/_20"
android:gravity="center_vertical"
android:orientation="vertical">
<de.hdodenhof.circleimageview.CircleImageView
android:layout_width="80dp"
android:layout_height="80dp"
android:src="#drawable/fake_chef_bg"
app:civ_border_color="#color/border_grey_color"
app:civ_border_width="#dimen/_2" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="#dimen/_5"
android:orientation="vertical">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:fontFamily="#font/bold_font"
android:text="#string/fatima_al_zahraa"
android:textColor="#color/white"
android:textSize="#dimen/large_text_size"
android:textStyle="bold" />
<TextView
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:fontFamily="#font/regular_font"
android:text="#string/presenter_of_the_cuient"
android:textColor="#color/white"
android:textSize="#dimen/app_text_size" />
</LinearLayout>
</LinearLayout>
<RelativeLayout
android:id="#+id/bottomButtonRL"
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_below="#+id/slideIV"
android:layout_marginTop="-25dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<View
android:layout_width="match_parent"
android:layout_height="#dimen/_0"
android:layout_weight="1" />
<View
android:layout_width="match_parent"
android:layout_height="#dimen/_0"
android:layout_weight="1"
android:background="#color/defaultColor" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:paddingStart="#dimen/_20"
android:paddingLeft="#dimen/_20">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:adjustViewBounds="true"
android:src="#drawable/ic_share" />
<RelativeLayout
android:layout_width="220dp"
android:layout_height="wrap_content"
android:layout_marginStart="#dimen/_10"
android:layout_marginLeft="#dimen/_10"
android:background="#drawable/ic_rec1">
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fontFamily="#font/regular_font"
android:gravity="center"
android:layout_centerInParent="true"
android:text="#string/add_to_fav"
android:textColor="#color/white"
android:textSize="#dimen/medium_text_size" />
</RelativeLayout>
</LinearLayout>
</RelativeLayout>
</RelativeLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#drawable/bottom_radius_view">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:fontFamily="#font/regular_font"
android:padding="#dimen/_20"
android:text="#string/galetes_fires_au_plates_fires_au_plates_fires_au_plates_fires_au_plates_fires_au_plates"
android:textColor="#color/white"
android:textSize="#dimen/app_text_size" />
</LinearLayout>
</LinearLayout>
<androidx.appcompat.widget.Toolbar
android:visibility="gone"
android:id="#+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
app:layout_collapseMode="pin"
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="match_parent"
app:layout_behavior="#string/appbar_scrolling_view_behavior">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:paddingLeft="#dimen/_20"
android:paddingTop="#dimen/_10"
android:paddingRight="#dimen/_20">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:fontFamily="#font/bold_font"
android:padding="#dimen/_5"
android:text="#string/les_videos"
android:textColor="#color/medium_grey_text_color"
android:textSize="#dimen/large_text_size" />
<androidx.recyclerview.widget.RecyclerView
android:id="#+id/itemFRV"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="#dimen/_5" />
</LinearLayout>
</androidx.core.widget.NestedScrollView>
</androidx.coordinatorlayout.widget.CoordinatorLayout>
</layout>
This is the header code:
<?xml version="1.0" encoding="utf-8"?>
<layout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="#dimen/header_height"
android:background="#color/white"
android:gravity="center"
android:orientation="horizontal"
android:paddingLeft="#dimen/_20"
android:paddingRight="#dimen/_20">
<LinearLayout
android:id="#+id/backLL"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="left"
android:gravity="center"
android:paddingRight="#dimen/_20"
android:layout_marginBottom="#dimen/_10"
android:visibility="gone">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:adjustViewBounds="true"
android:src="#drawable/ic_back" />
</LinearLayout>
<ImageView
android:id="#+id/logoIV"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="left"
android:adjustViewBounds="true"
android:paddingStart="0dp"
android:paddingTop="#dimen/_15"
android:paddingEnd="#dimen/_10"
android:layout_marginBottom="#dimen/_10"
android:src="#drawable/ic_header_logo" />
<View
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1" />
<ImageView
android:id="#+id/profileIV"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="right"
android:adjustViewBounds="true"
android:paddingStart="#dimen/_10"
android:paddingTop="#dimen/_15"
android:paddingEnd="0dp"
android:layout_marginBottom="#dimen/_10"
android:src="#drawable/ic_default_user" />
</LinearLayout>
</layout>
Answer to the problem is just remove
android:fitsSystemWindows="true"
Change the layout_scrollFlags
app:layout_scrollFlags="scroll|exitUntilCollapsed"
replace above line with
app:layout_scrollFlags="scroll|enterAlways|enterAlwaysCollapsed"
Hi I have a two recyclerView with one bottom view. When i click an item in recyclerView a popup window with editText should come. When i touch an editText the keyboard is triggered, the linear layout gets pushed up. I don't want to push up the layout the keyboard should visible above the screen.
XML code
<?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"
android:isScrollContainer="false">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_above="#+id/relative_layout"
android:orientation="vertical">
<include layout="#layout/app_toolbar" />
<View
android:layout_width="match_parent"
android:layout_height="#dimen/margin_1dp"
android:background="#color/black_color_10_percent" />
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#color/black_color_2_percent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<RelativeLayout
android:id="#+id/tool_tip_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:background="#color/color_white"
android:gravity="center_vertical"
android:padding="5dp">
<TextView
android:id="#+id/text_view_user_tool_tip_label"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_marginLeft="#dimen/margin_10dp"
android:layout_toLeftOf="#+id/image_view_remove_tool_tip"
android:gravity="center|left"
android:singleLine="true"
android:textColor="#color/icon_un_selected_color"
android:textSize="#dimen/text_size_12dp" />
<ImageView
android:id="#+id/image_view_remove_tool_tip"
android:layout_width="#dimen/margin_24dp"
android:layout_height="#dimen/margin_24dp"
android:layout_alignParentRight="true"
android:layout_gravity="right|center_vertical"
android:layout_marginRight="#dimen/margin_10dp"
android:background="#drawable/circle_grey_bg"
android:padding="#dimen/margin_6dp"
android:src="#drawable/ic_close_white_24dp" />
</RelativeLayout>
<android.support.v7.widget.CardView
android:id="#+id/card_view_your_suggestions"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="2"
app:cardBackgroundColor="#color/light_grey_color"
app:cardCornerRadius="0dp"
app:cardElevation="0.5dp"
app:cardMaxElevation="1dp"
app:cardPreventCornerOverlap="true"
app:cardUseCompatPadding="true"
app:contentPaddingBottom="0dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<TextView
android:layout_width="match_parent"
android:layout_height="#dimen/margin_40dp"
android:background="#color/color_grey"
android:gravity="center|left"
android:paddingLeft="#dimen/margin_12dp"
android:text="#string/text_your_selections"
android:textColor="#color/black_color_87_percent"
android:textSize="#dimen/text_size_14dp" />
<android.support.v7.widget.RecyclerView
android:id="#+id/recycler_view_your_selection_list"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:scrollbars="none" />
</LinearLayout>
</android.support.v7.widget.CardView>
<android.support.v7.widget.CardView
android:id="#+id/card_view_suggestions"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_marginTop="#dimen/margin_6dp"
android:layout_weight="3"
android:background="#android:color/white"
app:cardCornerRadius="0dp"
app:cardElevation="0dp"
app:cardMaxElevation="1dp"
app:cardPreventCornerOverlap="true"
app:cardUseCompatPadding="true"
app:contentPaddingBottom="0dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<TextView
android:layout_width="match_parent"
android:layout_height="#dimen/margin_40dp"
android:background="#color/color_grey"
android:gravity="center|left"
android:paddingLeft="#dimen/margin_12dp"
android:text="#string/text_your_suggestions"
android:textColor="#color/black_color_87_percent"
android:textSize="#dimen/text_size_14dp" />
<android.support.v7.widget.RecyclerView
android:id="#+id/recycler_view_your_suggestion_list"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#android:color/white"
android:fadeScrollbars="false"
android:scrollbarThumbVertical="#drawable/scrollbar_thumb"
android:scrollbarTrackVertical="#drawable/scrollbar_track"
android:scrollbars="vertical" />
</LinearLayout>
</android.support.v7.widget.CardView>
<android.support.v7.widget.CardView
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_marginTop="#dimen/margin_8dp"
android:layout_weight="1.1"
android:visibility="gone"
app:cardBackgroundColor="#color/light_grey_color"
app:cardCornerRadius="0dp"
app:cardElevation="0dp"
app:cardMaxElevation="1dp"
app:cardPreventCornerOverlap="true"
app:cardUseCompatPadding="true"
app:contentPaddingBottom="0dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<TextView
android:layout_width="match_parent"
android:layout_height="#dimen/margin_40dp"
android:background="#color/colorPrimaryDark"
android:gravity="center|left"
android:paddingLeft="#dimen/margin_12dp"
android:text="#string/text_add_new"
android:textColor="#color/black_color_87_percent"
android:textSize="#dimen/text_size_14dp" />
<abihealth.emrappabi.widgets.MyCustomTextView
android:id="#+id/text_view_add_new_element"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="#dimen/margin_8dp"
android:background="#drawable/edit_text_bg"
android:maxLines="1"
android:paddingLeft="#dimen/margin_8dp" />
</LinearLayout>
</android.support.v7.widget.CardView>
</LinearLayout>
</RelativeLayout>
</LinearLayout>
<RelativeLayout
android:id="#+id/relative_layout"
android:layout_width="match_parent"
android:layout_height="#dimen/margin_40dp"
android:layout_alignParentBottom="true"
android:background="#color/color_grey">
<LinearLayout
android:id="#+id/add_new_phrase_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="#dimen/margin_6dp"
android:background="#android:color/white"
android:gravity="center_vertical"
android:orientation="horizontal">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="#dimen/margin_6dp"
android:src="#drawable/icon_add_drawable" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center|left"
android:paddingLeft="#dimen/margin_2dp"
android:text="#string/text_add_phrase"
android:textColor="#color/black_54_percent"
android:textSize="#dimen/text_size_14dp" />
</LinearLayout>
</RelativeLayout>
</RelativeLayout>
Add to your activity in manifest , this works for me
<activity
...
android:windowSoftInputMode="adjustNothing">
</activity>
I have my layout setup as follows:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<include layout="#layout/my_toolbar" />
<android.support.v4.widget.SwipeRefreshLayout
android:id="#+id/swipe_refresh"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<com.my.SubView
android:id="#+id/my_list_subview"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#color/white" />
</android.support.v4.widget.SwipeRefreshLayout>
<TextView
android:id="#+id/text_content"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="#dimen/padding_medium"
android:layout_margin="#dimen/padding_medium"
android:text="Hello"
android:textSize="14sp"
android:maxLines="3"/>
</LinearLayout>
The problem is that the SwipeRefreshLayout takes up the entire screen and the textview doesn't show up at all.
The blue line in the above image is where the text view is. Is there anything I am missing? This seems to be so simple a problem, its ludicrous!
Image 2 in response to the answer by #Tomar
try this
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<include layout="#layout/my_toolbar"
android:id="#+id/top_layout"/>
<android.support.v4.widget.SwipeRefreshLayout
android:id="#+id/swipe_refresh"
android:layout_width="match_parent"
android:layout_above="#+id/text_content"
android:layout_below="#+id/top_layout"
android:layout_height="wrap_content">
<com.my.SubView
android:id="#+id/my_list_subview"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#color/white" />
</android.support.v4.widget.SwipeRefreshLayout>
<TextView
android:id="#+id/text_content"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="#dimen/padding_medium"
android:layout_margin="#dimen/padding_medium"
android:text="Hello"
android:textSize="14sp"
android:layout_alignParentBottom="true"
android:maxLines="3"/>
</RelativeLayout>
As I mentioned above, I worked it out with ConstraintLayout as below. I do not know why I need to use a large bottom margin and padding in the swipe refresh layout for it to sit above the text. Without these, it doesn't work!
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#color/white"
xmlns:app="http://schemas.android.com/apk/res-auto">
<include layout="#layout/toolbar"
android:id="#+id/my_toolbar"
android:layout_height="wrap_content"
android:layout_width="0dp"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"/>
<android.support.v4.widget.SwipeRefreshLayout
android:id="#+id/swipe_refresh"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginBottom="#dimen/padding_large"
android:paddingBottom="#dimen/padding_super_large"
app:layout_constraintTop_toBottomOf="#+id/my_toolbar"
app:layout_constraintBottom_toTopOf="#+id/text_content"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent">
<com.my.SubView
android:id="#+id/my_list_subview"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:background="#color/white"/>
</android.support.v4.widget.SwipeRefreshLayout>
<EditText
android:id="#+id/text_content"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:background="#color/white"
android:hint="#string/write_message"
android:textSize="14sp"
android:maxLines="3"
android:padding="#dimen/padding_medium"
android:paddingLeft="#dimen/padding_large"
app:layout_constraintTop_toBottomOf="#+id/swipe_refresh"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
tools:visibility="visible"
tools:layout_editor_absoluteX="0dp" />
</android.support.constraint.ConstraintLayout>
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<androidx.swiperefreshlayout.widget.SwipeRefreshLayout
android:id="#+id/srl_reload_list"
android:layout_width="0dp"
android:layout_height="0dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toBottomOf="parent">
<androidx.recyclerview.widget.RecyclerView
android:id="#+id/recyclerView_openOrderList"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true" />
</androidx.swiperefreshlayout.widget.SwipeRefreshLayout>
</androidx.constraintlayout.widget.ConstraintLayout>