I keep getting an error that my LinearLayout isn't allowed in my RelativeLayout object.
I am trying to create a multi-filter search bar. This LinearLayout is meant to hold different elements in the search bar. Here is my code:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:card_view="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#FFFFFF">
<androidx.appcompat.widget.Toolbar
android:id="#+id/toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#212121"
android:minHeight="?attr/actionBarSize">
<TextView
android:id="#+id/toolbar_title"
style="#style/TextAppearance.AppCompat.Widget.ActionBar.Title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="#string/app_name"
android:textColor="#FFF" />
</androidx.appcompat.widget.Toolbar>
<RelativeLayout
android:id="#+id/view_search"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#50000000"
android:clickable="true"
android:visibility="invisible">
<ProgressBar
android:id="#+id/marker_progress"
style="?android:attr/progressBarStyle"
android:layout_width="50dp"
android:layout_height="50dp"
android:layout_centerInParent="true"
android:indeterminate="true"
android:visibility="gone" />
</RelativeLayout>
<ListView
android:id="#+id/listContainer"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#fff"
android:clipToPadding="false"
android:divider="#fff"
android:paddingTop="56dp"
android:visibility="gone" />
<androidx.appcompat.widget.CardView
android:id="#+id/card_search"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="4dp"
android:visibility="invisible"
card_view:cardCornerRadius="2dp">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<LinearLayout
android:id="#+id/linearLayout_search"
android:layout_width="match_parent"
android:layout_height="48dp">
<ImageView
android:id="#+id/image_search_back"
android:layout_width="48dp"
android:layout_height="48dp"
android:background="?android:attr/selectableItemBackground"
android:clickable="true"
android:padding="12dp"
android:src="#mipmap/ic_arrow_back" />
<EditText
android:id="#+id/edit_text_search"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="#fff"
android:focusable="true"
android:gravity="center_vertical"
android:hint="#string/search_restaurants_and_cuisines"
android:imeOptions="actionSearch"
android:inputType="textCapWords"
android:maxLines="1"
android:paddingLeft="12dp"
android:paddingRight="8dp" />
</LinearLayout>
<View
android:id="#+id/line_divider"
android:layout_width="match_parent"
android:layout_height=".5dp"
android:layout_below="#+id/linearLayout_search"
android:background="#eee" />
<androidx.recyclerview.widget.RecyclerView
android:id="#+id/recyclerView"
android:layout_width="match_parent"
android:layout_height="250dp"
android:layout_below="#+id/line_divider"
android:divider="#FFFFFF" />
</RelativeLayout>
</androidx.appcompat.widget.CardView>
<TextView
android:id="#+id/txtNoResultsFound"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:gravity="center"
android:padding="#dimen/activity_horizontal_margin"
android:text="#string/no_results_found" />
<ListView
android:id="#+id/listView"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_below="#+id/toolbar"
android:layout_marginBottom="#dimen/corners_small_value"
android:layout_marginLeft="#dimen/corners_small_value"
android:layout_marginRight="#dimen/corners_small_value">
</ListView>
<View
android:id="#+id/toolbar_shadow"
android:layout_width="match_parent"
android:layout_height="4dp"
android:layout_below="#+id/toolbar"
android:background="#drawable/toolbar_shadow" />
</RelativeLayout>
Why is this happening? I made sure it is in the updated androidx CardView, so not sure why LinearLayout is still not allowed to be in the RelativeLayout inside CardView.
It looks like you have a typo in your CardView tag:
<androidx.appcompat.widget.CardView
That should look like this instead:
<androidx.cardview.widget.CardView ...
(Replace .appcompat. with .cardview.).
Related
Good morning to everybody, I have a little problem about resizing of layout when keyboard is shown.
In manifest I have adjustResize and also I tried to use adjustPan but I have problem with scrolling of recyclerview.
My layout code is:
<LinearLayout
android:id="#+id/layoutGeneralHome"
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context=".fragments.fragment_home">
<LinearLayout
android:id="#+id/layoutRecycler"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="0.9">
<android.support.v7.widget.RecyclerView
android:id="#+id/listChatGeneral"
android:layout_width="match_parent"
android:layout_height="match_parent"
/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="0.10"
android:orientation="horizontal">
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="0.75"
android:orientation="vertical">
<EditText
android:id="#+id/edtMessage"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Scrivi messaggio"/>
</LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="0.25">
<Button
android:id="#+id/btnSend"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:text="INVIA"
android:textSize="18sp"/>
</LinearLayout>
</LinearLayout>
</LinearLayout>
Thanks who could help me
You have no need to add scrollview, Using Relative layout U can achieve Screen like u want.
I have add Relative layout and Code like below.
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#color/white"
android:orientation="vertical">
<android.support.v7.widget.RecyclerView
android:id="#+id/listChatGeneral"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_above="#+id/llSendView" />
<LinearLayout
android:id="#+id/llSendView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:gravity="center_vertical"
android:orientation="horizontal">
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="0.75"
android:orientation="vertical">
<EditText
android:id="#+id/edtMessage"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Scrivi messaggio" />
</LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="0.25">
<Button
android:id="#+id/btnSend"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:text="INVIA"
android:textSize="18sp" />
</LinearLayout>
</LinearLayout>
</RelativeLayout>
This is my view in my app, it's work fine, Try this:
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:ads="http://schemas.android.com/apk/res-auto"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="#string/appbar_scrolling_view_behavior"
tools:mContext="hvasoftware.com.tudiendanhngon.view.activities.CommentActivity">
<androidx.recyclerview.widget.RecyclerView
android:id="#+id/rvComment"
android:layout_width="match_parent"
android:layout_height="0dp"
android:visibility="gone"
ads:layout_constraintBottom_toTopOf="#+id/viewComment"
ads:layout_constraintTop_toBottomOf="parent" />
<ProgressBar
android:id="#+id/progressBar"
style="?android:attr/progressBarStyle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:indeterminate="true"
android:indeterminateTint="#color/colorAccent"
android:visibility="visible"
ads:layout_constraintBottom_toBottomOf="parent"
ads:layout_constraintLeft_toLeftOf="parent"
ads:layout_constraintRight_toRightOf="parent"
ads:layout_constraintTop_toTopOf="parent"
tools:targetApi="lollipop" />
<androidx.constraintlayout.widget.ConstraintLayout
android:id="#+id/viewComment"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
>
<EditText
android:id="#+id/edtComment"
android:layout_width="match_parent"
android:layout_height="50dp"
android:fontFamily="sans-serif-light"
android:inputType="textCapSentences"
android:paddingLeft="9dp"
android:paddingRight="50dp"
android:textColor="#color/colorAccent"
android:textSize="14sp"
ads:layout_constraintBottom_toBottomOf="parent"
ads:layout_constraintLeft_toLeftOf="parent"
ads:layout_constraintRight_toLeftOf="#+id/ibUpComment" />
<ImageButton
android:id="#+id/ibUpComment"
android:layout_width="23dp"
android:layout_height="26dp"
ads:layout_constraintBottom_toBottomOf="#id/edtComment"
ads:layout_constraintRight_toRightOf="parent"
ads:layout_constraintTop_toTopOf="#+id/edtComment" />
<ProgressBar
android:id="#+id/progressBarUpload"
style="?android:attr/progressBarStyle"
android:layout_width="26dp"
android:layout_height="26dp"
android:layout_centerInParent="true"
android:layout_marginEnd="16dp"
android:indeterminate="true"
android:indeterminateTint="#color/colorAccent"
android:visibility="gone"
ads:layout_constraintBottom_toBottomOf="#id/edtComment"
ads:layout_constraintRight_toRightOf="parent"
ads:layout_constraintTop_toTopOf="#+id/edtComment"
tools:targetApi="lollipop" />
</androidx.constraintlayout.widget.ConstraintLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
I have created a recyclerview adapter class, with an item layout which contains a cardview inside which there are some textviews and imageviews. The problem I am facing is that when the views are recycled, my cardview size changes and it hides the content of another cardview.
I think the issue is because I have different card heights for each item. So when an item is recycled, it takes the height of another card which is different. How to fix this? Please help..
Video link of the problem: https://drive.google.com/file/d/1nlgq-eQ-rhRNadOyzg4FwjVzrIk88Ve8/view?usp=sharing
open_up_list_view.xml
<?xml version="1.0" encoding="utf-8"?>
<ScrollView 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="wrap_content">
<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="wrap_content">
<android.support.v7.widget.CardView
android:id="#+id/openUpCardView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="#dimen/nav_header_vertical_spacing"
android:layout_marginEnd="#dimen/dimen_16x"
android:layout_marginLeft="#dimen/activity_vertical_margin"
android:layout_marginRight="#dimen/dimen_16x"
android:layout_marginStart="#dimen/activity_vertical_margin"
android:layout_marginTop="#dimen/dimen_4x"
android:clickable="true"
android:focusable="true"
app:cardCornerRadius="#dimen/dimen_8x">
<RelativeLayout
android:id="#+id/openUpRelativeLayout"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="#dimen/dimen_8x"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal">
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<ProgressBar
android:id="#+id/openUpAuthorImageProgress"
android:layout_width="wrap_content"
android:layout_height="match_parent" />
<de.hdodenhof.circleimageview.CircleImageView
android:id="#+id/openUpAuthorImage"
android:layout_width="#dimen/dimen_48x"
android:layout_height="#dimen/dimen_48x"
android:layout_marginBottom="#dimen/dimen_4x"
android:layout_marginLeft="#dimen/dimen_4x"
android:layout_marginRight="#dimen/dimen_4x"
android:layout_marginTop="#dimen/dimen_4x"
app:civ_border_color="#FF000000"
app:civ_border_width="2dp" />
</RelativeLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:id="#+id/openUpAuthorName"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="#dimen/cardview_default_radius"
android:layout_marginLeft="#dimen/dimen_8x"
android:layout_marginRight="#dimen/dimen_8x"
android:layout_marginTop="#dimen/dimen_8x"
android:text="loading.."
android:textColor="#color/colorPrimaryDark"
android:textSize="#dimen/dimen_16x"
android:textStyle="bold" />
<TextView
android:id="#+id/openUpDate"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#id/openUpAuthorName"
android:layout_marginLeft="#dimen/dimen_8x"
android:textSize="#dimen/dimen_12x" />
</RelativeLayout>
</LinearLayout>
<TextView
android:id="#+id/openUpTextView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_gravity="left"
android:autoLink="web"
android:padding="#dimen/dimen_4x"
android:textAlignment="textStart"
android:textColor="#color/cardview_dark_background"
android:textSize="#dimen/dimen_16x" />
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<ProgressBar
android:id="#+id/openUpImageProgress"
android:layout_width="match_parent"
android:layout_height="match_parent" />
<com.github.chrisbanes.photoview.PhotoView
android:id="#+id/openUpImageView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="#dimen/dimen_8x"
android:layout_marginLeft="#dimen/dimen_4x"
android:layout_marginRight="#dimen/dimen_4x"
android:layout_marginTop="#dimen/dimen_8x"
android:layout_weight="1"
app:srcCompat="#drawable/common_google_signin_btn_icon_dark" />
</RelativeLayout>
<View
android:layout_width="match_parent"
android:layout_height="0.5dp"
android:background="#android:color/darker_gray"
android:hapticFeedbackEnabled="false"></View>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal">
<CheckBox
android:id="#+id/openUpLikeIcon"
android:layout_width="#dimen/dimen_32x"
android:layout_height="#dimen/dimen_24x"
android:layout_marginBottom="#dimen/dimen_4x"
android:layout_marginLeft="16dp"
android:layout_marginStart="16dp"
android:layout_marginTop="8dp"
android:background="#drawable/thumb_off"
android:button="#null"
android:checked="false"
android:clickable="true"
android:focusable="true"
android:stateListAnimator="#animator/scale"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintTop_toBottomOf="#+id/image" />
<TextView
android:id="#+id/openUpLikeTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="#dimen/nav_header_vertical_spacing"
android:layout_marginTop="#dimen/dimen_8x"
android:text="loading.."
android:textSize="#dimen/dimen_16x" />
<ImageView
android:id="#+id/openUpCommentIcon"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_marginLeft="#dimen/fab_margin"
android:layout_marginTop="#dimen/dimen_8x"
app:srcCompat="#drawable/comment_icon" />
<TextView
android:id="#+id/openUpCommentTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="#dimen/dimen_8x"
android:text="loading.."
android:textSize="#dimen/dimen_16x" />
<TextView
android:id="#+id/openUpDeleteText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="#dimen/dimen_4x"
android:layout_marginTop="#dimen/dimen_8x"
android:layout_weight="1"
android:gravity="center_horizontal"
android:text="Delete"
android:textSize="#dimen/dimen_16x" />
</LinearLayout>
<View
android:id="#+id/commentSeparatorView"
android:layout_width="match_parent"
android:layout_height="1.5dp"
android:layout_marginTop="#dimen/nav_header_vertical_spacing"
android:background="#color/colorPrimaryDark"
android:hapticFeedbackEnabled="false"></View>
<TextView
android:id="#+id/commentSeparatorText"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="#dimen/dimen_8x"
android:gravity="center"
android:text="Comments"
android:textColor="#color/common_google_signin_btn_text_dark_focused" />
<LinearLayout
android:id="#+id/commentsLL"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="#dimen/dimen_4x"
android:background="#null"
android:orientation="vertical">
<android.support.v7.widget.RecyclerView
android:id="#+id/commentsRecyclerView"
android:layout_width="match_parent"
android:layout_height="match_parent">
</android.support.v7.widget.RecyclerView>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal">
<android.support.design.widget.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:hint="Add a comment..">
<android.support.design.widget.TextInputEditText
android:id="#+id/commentEditText"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</android.support.design.widget.TextInputLayout>
<android.support.v7.widget.AppCompatButton
android:id="#+id/commentPostButton"
android:layout_width="80dp"
android:layout_height="wrap_content"
android:backgroundTint="#color/colorPrimaryDark"
android:text="POST"
android:textColor="#color/cardview_light_background" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
</RelativeLayout>
</android.support.v7.widget.CardView>
</RelativeLayout>
</ScrollView>
EDIT: RecyclerView layout
fragment_open_up.xml
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.bittentech.localvariable.fragments.OpenUpFragment">
<!-- TODO: Update blank fragment layout -->
<TextView
android:id="#+id/openUpEmptyView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical|center_horizontal"
android:gravity="center_vertical|center_horizontal"
android:text="All caught up!!" />
<android.support.v4.widget.SwipeRefreshLayout
android:id="#+id/openUpSwipeRefresh"
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.v7.widget.RecyclerView
android:id="#+id/openUpRecyclerView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:nestedScrollingEnabled="false"/>
</android.support.v4.widget.SwipeRefreshLayout>
</FrameLayout>
This question already has answers here:
How to disable RecyclerView scrolling to make the layout listen its ScrollView parent?
(3 answers)
Closed 5 years ago.
I have problem with ScrollView. I'm trying to get it in Relative Layout. I have tried some solutions,but nothing works.I tried setting my relative layout's height to match_parent but it doesn't work also. I can get it to work with linear layout but I don't want to use it for some reason.
MY Xml code:
`
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
xmlns:app="http://schemas.android.com/apk/res-auto">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:weightSum="100">
<LinearLayout
android:id="#+id/actionbarh"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#color/helpdesk_color"
android:orientation="horizontal"
android:weightSum="100">
<ImageView
android:id="#+id/htoolback"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:padding="03dp"
app:srcCompat="#drawable/ic_back"
android:tint="#FFFFFF"
android:layout_gravity="center"
android:gravity="center" />
<TextView
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="83"
android:textColorHint="#FFFFFF"
android:layout_gravity="center"
android:gravity="center"
android:textSize="#dimen/action_size"
android:hint="Help Desk"/>
<android.support.v7.widget.Toolbar
android:id="#+id/toolbar1"
android:layout_height="wrap_content"
android:layout_width="0dp"
android:layout_weight="15"
android:fitsSystemWindows="true"
android:theme="#style/Theme"
android:listSelector="#android:color/transparent"
app:popupTheme="#style/MyApp.PopupMenu"
android:gravity="center"
app:titleTextColor="#color/white"
xmlns:app="http://schemas.android.com/apk/res-auto"
/>
</LinearLayout>
<RelativeLayout
android:id="#+id/relativelayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:clickable="false"
android:orientation="vertical" >
<LinearLayout
android:id="#+id/sublinerlayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="10dp"
android:orientation="horizontal">
<ImageView
android:layout_width="0dp"
android:layout_height="match_parent"
app:srcCompat="#drawable/ic_profile"
android:tint="#000000"
android:layout_weight="12"/>
<TextView
android:id="#+id/hstudentname"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="82"
android:textSize="#dimen/large_size"
android:textColorHint="#000000"
android:gravity="left|center"/>
</LinearLayout>
<ScrollView
android:id="#+id/help"
android:layout_width="match_parent"
android:layout_height="fill_parent"
android:fadeScrollbars="true"
android:scrollbars="vertical"
android:layout_marginBottom="80dp"
android:fillViewport="true">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:scrollbars="vertical"
android:fillViewport="true"
android:fadeScrollbars="true"
android:layout_marginBottom="80dp"
android:orientation="vertical">
<LinearLayout
android:id="#+id/idframe"
android:layout_width="match_parent"
android:orientation="vertical"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:padding="2dp"
android:background="#drawable/cardviewhelp"
android:layout_height="wrap_content">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
><ImageView
android:layout_width="wrap_content"
app:srcCompat="#drawable/ic_ticket"
android:layout_height="wrap_content" />
<TextView
android:id="#+id/subject"
android:layout_width="match_parent"
android:paddingLeft="05dp"
android:paddingRight="05dp"
android:gravity="left|center"
android:textColor="#000000"
android:textSize="#dimen/large_size"
android:layout_height="match_parent" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<EditText
android:id="#+id/comment"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="70"
android:textSize="#dimen/medium_m_size"
android:paddingLeft="10dp"
android:editable="false"
android:hint="hint"
android:focusable="false"
android:scrollbars="vertical"
android:gravity="left|center"
android:textColorHint="#000000"
android:background="#00000000"
android:textColor="#000000"/>
<TextView
android:id="#+id/datetime"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="30"
android:textColor="#000000"
android:hint="date"
android:textSize="#dimen/medium_m_size"
android:gravity="right|bottom"/>
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_below="#+id/idframe"
android:id="#+id/toolbarframelayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
>
<android.support.v4.widget.SwipeRefreshLayout
android:id="#+id/simpleSwipeRefreshLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<android.support.v7.widget.RecyclerView
android:id="#+id/e_helptoolrecycler"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:scrollbars="vertical"
app:stackFromEnd ="true">
</android.support.v7.widget.RecyclerView>
<!--</LinearLayout>-->
</android.support.v4.widget.SwipeRefreshLayout>
</LinearLayout>
</RelativeLayout>
</ScrollView>
</LinearLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_marginTop="-80dp"
android:background="#FFFFFF"
android:layout_alignParentBottom="true">
<LinearLayout
android:id="#+id/blow12"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:weightSum="100"
android:background="#FFFFFF"
android:gravity="center"
android:layout_gravity="bottom"
android:layout_margin="3dp">
<EditText
android:id="#+id/AddReplay"
android:background="#drawable/cardviewhelp"
android:layout_width="0dp"
android:layout_weight="84"
android:hint="Type a Message"
android:maxLength="200"
android:layout_height="match_parent"
android:layout_marginLeft="12dp"
android:focusable="true"
android:lines="3"
android:scrollbars="vertical"
android:scrollIndicators="start|end"
android:gravity="left|top"
android:inputType="textMultiLine|textFilter"
android:textColor="#000000"
android:digits="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890~`\n !##$%^*()_ -+=|\;;'.,/?"
tools:targetApi="m"/>
<LinearLayout
android:layout_width="0dp"
android:layout_weight="16"
android:layout_marginLeft="10dp"
android:layout_height="wrap_content">
<de.hdodenhof.circleimageview.CircleImageView
android:id="#+id/replaybutton"
android:layout_width="wrap_content"
android:src="#mipmap/send"
android:layout_height="wrap_content"
app:civ_border_color="#800080"
app:civ_border_width="2dp"/>
</LinearLayout>
</LinearLayout>
<TextView
android:layout_below="#+id/blow12"
android:id="#+id/textcount"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="15dp"
android:layout_marginBottom="5dp"
android:textColor="#color/helpdesk_color"
android:text="200 Character Remaining"/>
</RelativeLayout>
<!--<LinearLayout-->
<!--android:layout_width="match_parent"-->
<!--android:layout_height="wrap_content"-->
<!--android:orientation="horizontal"-->
<!--android:weightSum="100"-->
<!--android:layout_alignParentBottom="true"-->
<!--android:background="#FFFFFF"-->
<!--android:layout_gravity="bottom"-->
<!--android:layout_margin="3dp">-->
<!--<com.xw.repo.XEditText-->
<!--android:id="#+id/AddReplay"-->
<!--android:background="#drawable/cardviewhelp"-->
<!--android:layout_width="0dp"-->
<!--android:layout_weight="85"-->
<!--android:hint="Type a Message"-->
<!--android:maxLength="200"-->
<!--android:layout_height="wrap_content"-->
<!--android:padding="2dp"-->
<!--android:layout_alignParentBottom="true"-->
<!--android:layout_marginLeft="12dp"-->
<!--android:focusable="true"-->
<!--android:gravity="left|center"-->
<!--android:inputType="textMultiLine|textFilter"-->
<!--android:textColor="#000000"-->
<!--app:x_disableEmoji="true"/>-->
<!--<de.hdodenhof.circleimageview.CircleImageView-->
<!--android:id="#+id/replaybutton"-->
<!--android:layout_width="0dp"-->
<!--android:src="#mipmap/send"-->
<!--android:layout_height="match_parent"-->
<!--android:layout_weight="16"-->
<!--android:padding="2dp"-->
<!--app:civ_border_color="#800080"-->
<!--app:civ_border_width="2dp"/>-->
<!--</LinearLayout>-->
</RelativeLayout>
</LinearLayout>
<!--</android.support.v4.widget.NestedScrollView>-->
</RelativeLayout>
`
My problem : scrolling only this below layout.but not working whole scrolling in Relative Layout.
`
<LinearLayout
android:id="#+id/idframe"
android:layout_width="match_parent"
android:orientation="vertical"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:padding="2dp"
android:background="#drawable/cardviewhelp"
android:layout_height="wrap_content">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
><ImageView
android:layout_width="wrap_content"
app:srcCompat="#drawable/ic_ticket"
android:layout_height="wrap_content" />
<TextView
android:id="#+id/subject"
android:layout_width="match_parent"
android:paddingLeft="05dp"
android:paddingRight="05dp"
android:gravity="left|center"
android:textColor="#000000"
android:textSize="#dimen/large_size"
android:layout_height="match_parent" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<EditText
android:id="#+id/comment"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="70"
android:textSize="#dimen/medium_m_size"
android:paddingLeft="10dp"
android:editable="false"
android:hint="hint"
android:focusable="false"
android:scrollbars="vertical"
android:gravity="left|center"
android:textColorHint="#000000"
android:background="#00000000"
android:textColor="#000000"/>
<TextView
android:id="#+id/datetime"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="30"
android:textColor="#000000"
android:hint="date"
android:textSize="#dimen/medium_m_size"
android:gravity="right|bottom"/>
</LinearLayout>
</LinearLayout>
`
RecyclerView itself a ScrollView .
Solution
Call NestedScrollView instead of ScrollView .
STRUCTURE
<android.support.v4.widget.NestedScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content"
>
<android.support.v7.widget.RecyclerView
android:id="#+id/list"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
/>
</android.support.v4.widget.NestedScrollView>
FYI
You should add
recyclerViewOBJ.setNestedScrollingEnabled(false);
If this property is set to true the view will be permitted to initiate
nested scrolling operations with a compatible parent view in the
current hierarchy. If this view does not implement nested scrolling
this will have no effect. Disabling nested scrolling while a nested
scroll is in progress has the effect of stopping the nested scroll.
You should take a scrollview outside of Relative layout
Set your Scrollview to NestedScrollView
<android.support.v4.widget.NestedScrollView>
<android.support.v7.widget.RecyclerView>
</android.support.v7.widget.RecyclerView>
</android.support.v4.widget.NestedScrollView>
In your recyclerview
recyclerView.setNestedScrollingEnabled(false);
recyclerView.setHasFixedSize(false);
In our chat app new message start first. For see old message user scroll up. For this we set reverseLayout true.
Ex: LayoutManager reverse so 0 position is botttom. when user scroll for old message suppose position is 10 . so i want to hide toolbar.when user go below from 10 position to 9 position i want to show toolbar.
LinearLayoutManager linearLayoutManager = new WrapContentLinearLayoutManager(context);
linearLayoutManager.setOrientation(LinearLayoutManager.VERTICAL);
linearLayoutManager.setReverseLayout(true);
We want to hide collapsing toolbar when user scroll up for fetch old message and show collapsing toolbar when user scroll down.
Any hints on how to achieve this?
XML Code as below :
<?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:id="#+id/rlMain"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#color/whole_background_color"
android:orientation="vertical">
<ImageView
android:id="#+id/ivBackgroundWall"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scaleType="centerCrop" />
<android.support.design.widget.CoordinatorLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_above="#+id/rlChatMessageSendView">
<android.support.design.widget.AppBarLayout
android:id="#+id/app_bar_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#00000000"
app:elevation="0dp">
<android.support.design.widget.CollapsingToolbarLayout
android:id="#+id/collapsing_toolbar"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_scrollFlags="scroll|enterAlways">
<include
android:id="#+id/rlZoneDetail"
layout="#layout/include_layout_zone_option" />
</android.support.design.widget.CollapsingToolbarLayout>
</android.support.design.widget.AppBarLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
app:layout_behavior="com.gochat.uIUtil.FixScrollingFooterBehavior">
<RelativeLayout
android:id="#+id/rel_root_recyclerview"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_above="#+id/rlChat"
android:paddingBottom="#dimen/margin_five">
<android.support.v7.widget.RecyclerView
android:id="#+id/recyclerViewChat"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:overScrollMode="never"
android:scrollbars="none"
android:visibility="visible"
tools:listitem="#layout/chat_adapter_message_layout" />
<ProgressBar
android:id="#+id/progressBar"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:theme="#style/AppTheme.ProgressBarColor"
android:visibility="gone" />
<android.support.v7.widget.AppCompatTextView
android:id="#+id/tvFollow"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:layout_marginRight="#dimen/padding_five"
android:layout_marginTop="#dimen/padding_ten"
android:background="#drawable/background_login_signup_small_radius"
android:gravity="center"
android:maxLines="1"
android:paddingBottom="#dimen/padding_five"
android:paddingLeft="#dimen/padding_twenty"
android:paddingRight="#dimen/padding_twenty"
android:paddingTop="#dimen/padding_five"
android:singleLine="true"
android:text="#string/start_follow"
android:textAllCaps="false"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="#color/white"
android:textSize="#dimen/text_size_fifteen"
android:visibility="gone" />
<LinearLayout
android:id="#+id/llAnnounce"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="#+id/recyclerViewChat"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:layout_marginBottom="#dimen/padding_five"
android:layout_marginRight="#dimen/padding_five"
android:layout_marginTop="#dimen/padding_five"
android:background="#drawable/background_login_signup_small_radius"
android:gravity="center"
android:visibility="gone">
<ImageView
android:layout_width="#dimen/padding_thirteen"
android:layout_height="#dimen/padding_thirteen"
android:layout_marginLeft="#dimen/margin_seven"
android:layout_marginStart="#dimen/margin_seven"
android:src="#drawable/iv_white_shout" />
<android.support.v7.widget.AppCompatTextView
android:id="#+id/tvAnnouncement"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="#dimen/margin_twenty"
android:layout_marginLeft="#dimen/margin_ten"
android:layout_marginRight="#dimen/margin_twenty"
android:layout_marginStart="#dimen/margin_ten"
android:gravity="center"
android:maxLines="1"
android:paddingBottom="#dimen/padding_five"
android:paddingTop="#dimen/padding_five"
android:singleLine="true"
android:text="#string/announce_text"
android:textAllCaps="false"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="#color/white"
android:textSize="#dimen/text_size_thirteen"
android:visibility="visible" />
<ImageView
android:layout_width="#dimen/padding_thirteen"
android:layout_height="#dimen/padding_thirteen"
android:layout_marginEnd="#dimen/margin_seven"
android:layout_marginRight="#dimen/margin_seven"
android:src="#drawable/iv_white_send" />
</LinearLayout>
</RelativeLayout>
<LinearLayout
android:id="#+id/rlChat"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_gravity="bottom"
android:background="#color/bg_bottombar"
android:orientation="vertical"
android:visibility="visible"
app:layout_behavior="com.gochat.uIUtil.FixScrollingFooterBehavior">
<View
android:layout_width="match_parent"
android:layout_height="#dimen/onedp"
android:background="#color/create_zone_divider_color_whatsapp" />
<RelativeLayout
android:id="#+id/rl_send_message"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#color/bottom_tab"
android:padding="#dimen/padding_seven"
android:visibility="visible">
<RelativeLayout
android:id="#+id/rlAdd"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_centerVertical="true"
android:paddingBottom="#dimen/padding_ten"
android:paddingRight="#dimen/margin_eight"
android:paddingTop="#dimen/padding_ten">
<ImageView
android:id="#+id/ivAdd"
android:layout_width="#dimen/margin_twenty"
android:layout_height="#dimen/margin_twenty"
android:layout_centerVertical="true"
android:src="#drawable/iv_add_blue" />
</RelativeLayout>
<ImageView
android:id="#+id/ivFullscreen"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:src="#drawable/iv_add_blue"
android:visibility="gone" />
<ImageView
android:id="#+id/ivMenuOpen"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/rel_message"
android:layout_centerVertical="true"
android:layout_marginEnd="#dimen/margin_twenty"
android:layout_marginRight="#dimen/margin_twenty"
android:layout_toLeftOf="#+id/ivFullscreen"
android:layout_toStartOf="#+id/ivFullscreen"
android:src="#drawable/iv_menu_grid"
android:visibility="gone" />
<TextView
android:id="#+id/tv_Title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:gravity="center"
android:text="TITLE"
android:textStyle="bold"
android:visibility="gone" />
<RelativeLayout
android:id="#+id/rel_message"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_toEndOf="#+id/rlAdd"
android:layout_toLeftOf="#+id/iv_send"
android:layout_toRightOf="#+id/rlAdd"
android:layout_toStartOf="#+id/iv_send"
android:background="#drawable/chat_send_message_background"
android:visibility="visible">
<RelativeLayout
android:id="#+id/rl_chat_send_message"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:orientation="horizontal">
<EditText
android:id="#+id/et_chat"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginEnd="#dimen/margin_ten"
android:layout_marginLeft="#dimen/margin_ten"
android:layout_marginRight="#dimen/margin_ten"
android:layout_marginStart="#dimen/margin_ten"
android:background="#null"
android:hint="#string/type_messsage"
android:inputType="textMultiLine"
android:maxLines="4"
android:padding="#dimen/padding_eight"
android:textColorHint="#color/hint_text_color"
android:textSize="#dimen/text_size_fifteen"
tools:text="zxnihxkbdfcdaaa" />
</RelativeLayout>
</RelativeLayout>
<ImageView
android:id="#+id/iv_send"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:layout_margin="#dimen/margin_five"
android:src="#drawable/iv_send_message_light"
android:visibility="invisible" />
<ImageView
android:id="#+id/iv_record"
android:layout_width="30dp"
android:layout_height="30dp"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:layout_margin="#dimen/margin_five"
android:src="#drawable/iv_audio_record"
android:visibility="visible" />
</RelativeLayout>
<FrameLayout
android:id="#+id/frame_layout"
android:layout_width="match_parent"
android:layout_height="250dp"
android:background="#color/white"
android:padding="#dimen/padding_fifteen"
android:visibility="gone" />
</LinearLayout>
</RelativeLayout>
</android.support.design.widget.CoordinatorLayout>
<RelativeLayout
android:id="#+id/rlChatMessageSendView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true">
<LinearLayout
android:id="#+id/llSpectatorZone"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_marginTop="#dimen/margin_ten"
android:background="#color/white"
android:orientation="horizontal"
android:padding="#dimen/padding_ten"
android:visibility="gone">
<TextView
android:id="#+id/tvSpectatorZone"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:text="#string/you_can_only_view_this_zone"
android:textColor="#color/unselected_item_color"
android:textSize="#dimen/text_size_seventeen" />
</LinearLayout>
</RelativeLayout>
</RelativeLayout>
Please try below link. It may solve your problem.
http://xmodulo.com/hide-show-toolbar-scrolling-android.html
Thanks !
I'm trying to implement bottom sheet that will overlap exactly a view not a
whole screen. Desirable
.
But here is actual result
end position
.
What I'm doing wrong?
Here is the code. I want to overlap Textview with id content_to_overlap.
<TextView
android:id="#+id/btn1"
android:layout_width="match_parent"
android:layout_height="48dp"
android:background="#399"
android:layout_marginBottom="4dp"
android:clipChildren="false"
android:clipToPadding="false"
android:gravity="center"
android:text="Text1" />
<TextView
android:id="#+id/btn2"
android:layout_width="match_parent"
android:layout_height="48dp"
android:layout_below="#+id/btn1"
android:background="#399"
android:clipChildren="false"
android:layout_marginBottom="4dp"
android:clipToPadding="false"
android:gravity="center"
android:text="Text2Text2Text2Text2" />
<android.support.design.widget.CoordinatorLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="#+id/btn2"
android:clipChildren="false"
android:clipToPadding="false">
<TextView
android:id="#+id/content_to_overlap"
android:layout_width="match_parent"
android:layout_height="64dp"
android:background="#B44"
android:gravity="center"
android:text="Text3" />
<FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginLeft="24dp"
android:clipChildren="false"
android:clipToPadding="false"
app:behavior_peekHeight="48dp"
app:layout_behavior="android.support.design.widget.BottomSheetBehavior"
android:background="#8FF0"
>
<android.support.design.widget.FloatingActionButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginTop="-48dp" />
</FrameLayout>
</android.support.design.widget.CoordinatorLayout>
Code Below is not perfect but is provided to give you an idea
Use anchor for fab
<android.support.design.widget.CoordinatorLayout
android:layout_width="match_parent"
android:layout_height="match_parent"/>
<TextView
android:id="#+id/btn1"
android:layout_width="match_parent"
android:layout_height="48dp"
android:background="#399"
android:layout_marginBottom="4dp"
android:clipChildren="false"
android:clipToPadding="false"
android:gravity="center"
android:text="Text1" />
<TextView
android:id="#+id/btn2"
android:layout_width="match_parent"
android:layout_height="48dp"
android:layout_below="#+id/btn1"
android:background="#399"
android:clipChildren="false"
android:layout_marginBottom="4dp"
android:clipToPadding="false"
android:gravity="center"
android:text="Text2Text2Text2Text2" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="#+id/btn2"
android:clipChildren="false"
android:clipToPadding="false">
<TextView
android:id="#+id/content_to_overlap"
android:layout_width="match_parent"
android:layout_height="64dp"
android:background="#B44"
app:behavior_peekHeight="48dp"
app:layout_behavior="android.support.design.widget.BottomSheetBehavior"
android:background="#8FF0"
android:gravity="center"
android:text="Text3" />
<android.support.design.widget.FloatingActionButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:anchor="#id/content_to_overlap" />
</android.support.design.widget.CoordinatorLayout>