Collapsing Toolbar hide when scroll up and show when scroll Down - android

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 !

Related

Element LinearLayout is not allowed here - inside RelativeLayout

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.).

CardView size issue on View Recycle

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>

Android layout with fixed button on bottom

I have the following xml which is supposed to be something similar to the following
The activity shows mostly ok, but i cant get the two down buttons to get fixed to the bottom of the screen without messing the top views.
I've tried to use a FrameLayout with two RelativeLayouts, alignment_bottom, an empty view with weight 1 between components and even still havent being able to accomplish my goal. Any help will be really appreciated, thank you in advance.
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout android:layout_width="match_parent"
android:orientation="vertical"
android:layout_height="match_parent"
xmlns:android="http://schemas.android.com/apk/res/android">
<ScrollView android:layout_width="match_parent" android:layout_height="match_parent"
xmlns:android="http://schemas.android.com/apk/res/android">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/RelativeLayout1">
<ImageView
android:id="#+id/group_info_image"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:scaleType="fitStart"
android:adjustViewBounds="true"
android:layout_alignParentTop="true"
/>
<TextView
android:id="#+id/description_text"
android:layout_below="#id/group_info_image"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textColor="#color/mainColor"
android:textSize="20sp"
android:text="#string/descripcion"
android:layout_marginStart="10dp"
android:layout_marginTop="10dp"
android:fontFamily="sans-serif"
/>
<TextView
android:layout_below="#id/description_text"
android:gravity="start"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/group_info_description"
android:layout_marginTop="5dp"
android:layout_marginBottom="10dp"
android:layout_marginStart="10dp"
android:textSize="15sp"/>
<TextView
android:layout_below="#id/group_info_description"
android:scrollbars="vertical"
android:gravity="center"
android:textColor="#android:color/black"
android:layout_marginTop="10dp"
android:layout_marginStart="5dp"
android:layout_marginBottom="2dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/group_info_user_number"
android:textSize="15sp"
/>
<es.tretornesp.clickerchat.NonScrollableListView
android:layout_below="#id/group_info_user_number"
android:id="#+id/group_info_user_list"
android:layout_height="match_parent"
android:divider="#drawable/list_divider"
android:dividerHeight="1px"
android:layout_width="match_parent"/>
</RelativeLayout>
</ScrollView>
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<Button
android:id="#+id/delete_group"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="#string/borrar_grupo"
android:background="#color/mainColor" />
<View
android:id="#+id/divisor"
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="#color/grey"/>
<Button
android:id="#+id/exit_group"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textColor="#android:color/white"
android:text="#string/salir"
android:background="#color/mainColor"
/>
</LinearLayout>
</LinearLayout>
Change your layout file as below,
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_above="#+id/exit_group">
<RelativeLayout
android:id="#+id/RelativeLayout1"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<ImageView
android:id="#+id/group_info_image"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:adjustViewBounds="true"
android:scaleType="fitStart" />
<TextView
android:id="#+id/description_text"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#id/group_info_image"
android:layout_marginStart="10dp"
android:layout_marginTop="10dp"
android:fontFamily="sans-serif"
android:text="#string/descripcion"
android:textColor="#color/mainColor"
android:textSize="20sp" />
<TextView
android:id="#+id/group_info_description"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#id/description_text"
android:layout_marginBottom="10dp"
android:layout_marginStart="10dp"
android:layout_marginTop="5dp"
android:gravity="start"
android:textSize="15sp" />
<TextView
android:id="#+id/group_info_user_number"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#id/group_info_description"
android:layout_marginBottom="2dp"
android:layout_marginStart="5dp"
android:layout_marginTop="10dp"
android:gravity="center"
android:scrollbars="vertical"
android:textColor="#android:color/black"
android:textSize="15sp" />
<es.tretornesp.clickerchat.NonScrollableListView
android:id="#+id/group_info_user_list"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="#id/group_info_user_number"
android:divider="#drawable/list_divider"
android:dividerHeight="1px" />
<Button
android:id="#+id/delete_group"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/group_info_user_list"
android:background="#color/mainColor"
android:text="#string/borrar_grupo" />
<View
android:id="#+id/divisor"
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_below="#id/delete_group"
android:background="#color/grey" />
</RelativeLayout>
</ScrollView>
<Button
android:id="#+id/exit_group"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:background="#color/mainColor"
android:text="#string/salir"
android:textColor="#android:color/white" />
</RelativeLayout>
Use Coordinator Layout as a parent layout. like 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:card_view="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="false">
// your code
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:orientation="horizontal">
<TextView
android:id="#+id/txt_contact_laksha_group"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="demo"
/>
</LinearLayout>
</android.support.design.widget.CoordinatorLayout>

Layout_height doesn't want to gradually wrap contents when fragment are being used

What i want to accomplish is to create rating section like Google Play Store, i managed to display all the stars and review(for user to comment) but whenever the user type on it, the layout height of the RelativeLayout on my activity doesn't wrap the layout of the fragment within a fragment. I tried changing the height in any means, but still nothing solve the problem. The thing is when i make my TabLayout visible, it follows the height, but not my custom ViewPager.
I do not know whether i did it right or wrong or entirely impossible, please show me the right way. Thank you.
activity_view_item.xml
<?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"
tools:context="com.hybridelements.recyclerview.ViewItem">
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentTop="true"
android:layout_alignParentStart="true"
android:layout_alignParentLeft="true">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<ImageView
android:id="#+id/singleImageView"
android:layout_width="150dp"
android:layout_height="150dp"
android:layout_centerHorizontal="true"
android:layout_marginTop="29dp"
app:srcCompat="#drawable/android" />
<TextView
android:id="#+id/lblTitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/lblTitle"
android:layout_alignBottom="#+id/itemName"
android:textSize="16sp"
android:layout_marginLeft="25dp"
android:textStyle="bold"/>
<TextView
android:id="#+id/itemName"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:text="#string/itemName"
android:textSize="16sp"
android:layout_below="#+id/singleImageView"
android:layout_alignStart="#+id/singleImageView"/>
<TextView
android:id="#+id/lblCategory"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/lblCategory"
android:layout_alignTop="#+id/itemCategory"
android:layout_alignStart="#+id/lblTitle"
android:layout_marginRight="30dp"
android:textSize="16sp"
android:textStyle="bold"/>
<TextView
android:id="#+id/itemCategory"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/itemCategory"
android:textSize="16sp"
android:layout_below="#+id/itemName"
android:layout_alignStart="#+id/singleImageView"
android:layout_marginTop="14dp" />
<TextView
android:id="#+id/lblRating"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignStart="#+id/lblCategory"
android:layout_below="#+id/lblCategory"
android:layout_marginTop="13dp"
android:text="#string/lblRating"
android:textSize="16sp"
android:textStyle="bold" />
<TextView
android:id="#+id/itemRating"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="#+id/lblRating"
android:layout_alignStart="#+id/singleImageView"
android:text="#string/itemRating"
android:textSize="16sp" />
<ImageView
android:id="#+id/imageRating"
android:layout_width="17dp"
android:layout_height="17dp"
android:layout_alignBottom="#+id/itemRating"
android:layout_alignTop="#+id/itemRating"
android:layout_gravity="center"
android:layout_toEndOf="#+id/itemRating"
android:layout_marginLeft="5dp"
app:srcCompat="#drawable/star" />
<TextView
android:id="#+id/lblDesc"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="13dp"
android:text="#string/lblDesc"
android:textSize="16sp"
android:textStyle="bold"
android:layout_alignStart="#+id/itemDesc"
android:layout_below="#+id/itemRating"/>
<TextView
android:id="#+id/itemDesc"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/lblDesc"
android:layout_centerHorizontal="true"
android:layout_marginLeft="25dp"
android:layout_marginRight="25dp"
android:layout_marginTop="13dp"
android:text="#string/itemDesc"
android:textSize="16sp" />
<RelativeLayout
android:id="#+id/ratingSection"
android:layout_width="match_parent"
android:layout_height="130dp"
android:layout_marginTop="13dp"
android:layout_below="#+id/itemDesc"
android:background="#color/ratingSection">
<!-- Get section from fragment -->
</RelativeLayout>
<RelativeLayout
android:id="#+id/subTab"
android:layout_width="match_parent"
android:layout_height="511.84dp"
android:layout_marginTop="13dp"
android:layout_below="#+id/ratingSection">
<!-- Get section from fragment -->
</RelativeLayout>
</RelativeLayout>
</ScrollView>
fragment_sub_section_rating.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="wrap_content"
tools:context="com.hybridelements.openchef.fragment_activities.fragment_subs.SubSectionFragment_ReviewAndInstructions">
<RelativeLayout
android:id="#+id/main_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"
android:layout_width="match_parent"
android:layout_height="wrap_content"
tools:context=".MainActivity">
<android.support.design.widget.TabLayout
android:id="#+id/tab_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?attr/colorPrimary"
android:elevation="6dp"
android:minHeight="?attr/actionBarSize"
android:theme="#style/ThemeOverlay.AppCompat.Dark.ActionBar"
android:visibility="gone"/>
<com.hybridelements.openchef.fragment_activities.fragment_subs.CustomSubViewPager
android:id="#+id/pager"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="#id/tab_layout"/>
<com.pixelcan.inkpageindicator.InkPageIndicator
android:id="#+id/fragRating_dotIndicator"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:dotDiameter="8dp"
app:dotGap="8dp"
app:animationDuration="320"
app:pageIndicatorColor="#android:color/darker_gray"
app:currentPageIndicatorColor="#android:color/black"
android:layout_alignBottom="#+id/pager"
android:layout_marginBottom="20dp"
android:visibility="gone" />
</RelativeLayout>
fragment_rating_review.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="wrap_content"
tools:context="com.hybridelements.openchef.fragment_activities.fragment_subs.RatingFragment_Star">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:id="#+id/ratingReview"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="#string/fragmentRating_reviewHeader"
android:textAlignment="center"
android:layout_marginTop="13dp"
android:textSize="16dp"
android:textStyle="bold" />
<RelativeLayout
android:id="#+id/ratingStar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/ratingReview"
android:gravity="center_horizontal">
<EditText
android:id="#+id/userRateReview"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="25dp"
android:layout_marginRight="25dp"/>
</RelativeLayout>
<Button
android:id="#+id/ratingBtnSubmit"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/ratingStar"
android:layout_alignParentEnd="true"
android:text="#string/ratingFrag_BtnSubmit"
style="#style/Widget.AppCompat.Button.Borderless"
android:enabled="false"/>
</RelativeLayout>
The RelativeLayout with id "ratingSection" in ratingSactivity_view_item.xml should follow the height of FrameLayout in fragment_rating_review.xml
This shouldn't happen.
This is before any typing (seems normal)
After typing, the submit button going off the screen
Try with this layout.
<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="wrap_content">
<LinearLayout
android:layout_width="match_parent"
android:orientation="vertical"
android:layout_height="wrap_content">
<TextView
android:id="#+id/ratingReview"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="fragmentRating_reviewHeader"
android:textAlignment="center"
android:layout_marginTop="13dp"
android:textSize="16dp"
android:textStyle="bold" />
<RelativeLayout
android:id="#+id/ratingStar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_above="#+id/ratingStar"
android:layout_below="#+id/ratingReview"
android:gravity="center_horizontal">
<EditText
android:id="#+id/userRateReview"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="25dp"
android:layout_marginRight="25dp"/>
</RelativeLayout>
<Button
android:id="#+id/ratingBtnSubmit"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="right"
android:layout_alignParentRight="true"
android:layout_below="#+id/ratingStar"
android:text="ratingFrag_BtnSubmit"
style="#style/Widget.AppCompat.Button.Borderless"
android:enabled="false"/>
</LinearLayout>
</FrameLayout>

How to remove the shadow

I am using this lib and when I open the menu it makes the shadow like i am using blur in the background. And loading the songs from the memory(in the main thread). The shadow appears some times. . I dont know why it is happening .In the following layout the background is transparent but the following menu is strong color. what can i do to fix this .I made the images in multiple size also ex hdpi , xhdpi etc. what is the mistake i am doing . The shadow appears when I open and close the menu.
the xml code
<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"
xmlns:app="http://schemas.android.com/apk/res-auto"
tools:context="beatbox.Fragment.Songs">
<!-- TODO: Update blank fragment layout -->
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="110dp">
<com.github.florent37.arclayout.ArcLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:rotation="180"
app:arc_cropDirection="cropInside"
app:arc_height="40dp"
app:theme="#style/Theme.AppCompat.Light">
<View
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#7c2c3940" />
</com.github.florent37.arclayout.ArcLayout>
</RelativeLayout>
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport="true"
android:layout_gravity="fill_vertical"
>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<ListView
android:id="#+id/song_listview"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="175dp"
android:divider="#null"
android:cacheColorHint="#00000000"
android:fadingEdgeLength="48dp"
android:requiresFadingEdge="vertical"
android:fadingEdge="horizontal"
android:overScrollMode="never" />
</LinearLayout>
</ScrollView>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="120dp">
<ImageButton
android:layout_width="70dp"
android:layout_height="70dp"
android:layout_marginRight="21dp"
android:layout_marginEnd="21dp"
android:id="#+id/imageButton"
android:background="#00000000"
android:scaleType="fitXY"
android:layout_alignParentTop="true"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true"
android:layout_marginTop="30dp" />
<TextView
android:id="#+id/textView16"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/textView15"
android:layout_alignStart="#+id/textView15"
android:layout_below="#+id/textView15"
android:maxLines="1"
android:layout_marginEnd="140dp"
android:layout_marginRight="140dp"
android:singleLine="true"
android:textSize="12sp"
android:textStyle="bold" />
<TextView
android:id="#+id/textView15"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_width="wrap_content"
android:layout_alignParentStart="true"
android:layout_alignParentTop="true"
android:layout_marginEnd="120dp"
android:layout_marginLeft="24dp"
android:layout_marginRight="120dp"
android:layout_marginStart="24dp"
android:layout_marginTop="31dp"
android:maxLines="1"
android:singleLine="true"
android:text="#string/total_songs"
android:textSize="26sp" />
</RelativeLayout>
</RelativeLayout>
<FrameLayout
android:id="#+id/edittextview"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:visibility="invisible">
<com.github.stephenvinouze.shapeview.shapes.HalfCircleEdgeShapeView
android:layout_width="match_parent"
android:layout_height="66dp"
android:layout_marginLeft="16.5dp"
android:layout_marginRight="16.5dp"
android:layout_marginTop="105dp"
android:elevation="0dp"
app:shapeColor="#color/colorAccent">
<ImageButton
android:id="#+id/close_edittext"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_centerInParent="true"
android:layout_marginLeft="17dp"
android:layout_marginStart="17dp"
android:background="#00000000"
app:srcCompat="#drawable/ic_clear_white_48dp"
/>
<EditText
android:id="#+id/editText"
style="#android:style/Theme.Holo"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_marginEnd="20dp"
android:layout_marginRight="20dp"
android:layout_toEndOf="#+id/close_edittext"
android:layout_toRightOf="#+id/close_edittext"
android:hint="Search"
android:inputType="textPersonName"
android:paddingEnd="20dp"
android:paddingRight="20dp"
android:textSize="18sp"
tools:ignore="HardcodedText" />
</com.github.stephenvinouze.shapeview.shapes.HalfCircleEdgeShapeView>
</FrameLayout>
<FrameLayout
android:id="#+id/menu"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_alignParentTop="true">
<com.srx.widget.TabBarView
android:id="#+id/tabBarView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="105dp"
android:elevation="0dp" >
</com.srx.widget.TabBarView>
</FrameLayout>

Categories

Resources