How to put TextView below RecyclerView in NestedScrollView in android - android

I want to create a layout in which cart price and the total price will be displayed below the recycler view but when text view is placed below recycler view it gets invisible
I have searched on the internet about this but didn't find any solution
when text view is below the recycler view it gets invisible
Thanks in advance
<androidx.core.widget.NestedScrollView
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:background="#android:color/white">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:weightSum="10">
<androidx.recyclerview.widget.RecyclerView
android:id="#+id/cartRecyclerView"
android:layout_weight = "8.5"
android:layout_width="match_parent"
android:layout_height="wrap_content"
tools:context=".ShoppingCartActivity" />
<RelativeLayout
android:layout_weight = "1.5"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginRight="10dp">
<TextView
android:id="#+id/cartFragmentTextTotal"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:text="Total"
android:textSize="20sp"
android:textStyle="bold|italic" />
<TextView
android:id="#+id/cartFragmentTotal"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:layout_alignTop="#+id/total_tv"
android:textSize="20sp"
android:text="Total Right"
android:textStyle="bold|italic" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/total_amount_tv"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:onClick="onClickSendOrder"
android:text="Button"
android:textColor="#android:color/white"
android:textSize="20sp" />
</RelativeLayout>
</RelativeLayout>
</androidx.core.widget.NestedScrollView>

Try this
<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">
<androidx.core.widget.NestedScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#android:color/white">
<androidx.recyclerview.widget.RecyclerView
android:id="#+id/cartRecyclerView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="8.5"
tools:context=".ShoppingCartActivity" />
</androidx.core.widget.NestedScrollView>
<RelativeLayout
android:id="#+id/footer"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true">
<TextView
android:id="#+id/cartFragmentTextTotal"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentStart="true"
android:layout_alignParentLeft="true"
android:text="Total"
android:textSize="20sp"
android:textStyle="bold|italic" />
<TextView
android:id="#+id/cartFragmentTotal"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:text="Total Right"
android:textSize="20sp"
android:textStyle="bold|italic" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:onClick="onClickSendOrder"
android:text="Button"
android:textColor="#android:color/white"
android:textSize="20sp" />
</RelativeLayout>
</RelativeLayout>

Can you try this?
<LinearLayout 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:layout_margin="8dp"
android:orientation="vertical">
<androidx.recyclerview.widget.RecyclerView
android:id="#+id/cartRecyclerView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="8"
tools:listitem="#layout/tek_satir_playlist" />
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="2"
android:orientation="vertical"
>
<TextView
android:id="#+id/cartFragmentTextTotal"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentStart="true"
android:layout_alignParentLeft="true"
android:text="Total"
android:textSize="20sp"
android:textStyle="bold|italic" />
<TextView
android:id="#+id/cartFragmentTotal"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:layout_marginEnd="224dp"
android:layout_marginRight="224dp"
android:text="Total Right"
android:textSize="20sp"
android:textStyle="bold|italic" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:onClick="onClickSendOrder"
android:text="Button"
android:textColor="#android:color/white"
android:textSize="20sp" />
</RelativeLayout>
</LinearLayout>

First of all, you can not use weight and weightSum attributes for relative layout.
As I understand from your code You do not need to use the nested scroll, try this
<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:background="#android:color/white">
<androidx.recyclerview.widget.RecyclerView
android:id="#+id/cartRecyclerView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_above="#id/bottom_container"
tools:context=".ShoppingCartActivity" />
<RelativeLayout
android:id="#+id/bottom_container"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_marginRight="10dp">
<TextView
android:id="#+id/cartFragmentTextTotal"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentStart="true"
android:layout_alignParentLeft="true"
android:text="Total"
android:textSize="20sp"
android:textStyle="bold|italic" />
<TextView
android:id="#+id/cartFragmentTotal"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:text="Total Right"
android:textSize="20sp"
android:textStyle="bold|italic" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:onClick="onClickSendOrder"
android:text="Button"
android:textColor="#android:color/white"
android:textSize="20sp" />
</RelativeLayout>

I change the first sub Layout in androidx.core.widget.NestedScrollView to ConstraintLayout too easily position your RelativeLayout in it.
bellow is the completed code, I hope it would help...
<androidx.core.widget.NestedScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#android:color/white">
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<androidx.recyclerview.widget.RecyclerView
android:id="#+id/cartRecyclerView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toTopOf="#+id/footer"
tools:context=".ShoppingCartActivity" />
<RelativeLayout
android:id="#+id/footer"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginRight="10dp"
android:layout_weight="1.5"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toBottomOf="#+id/cartRecyclerView">
<TextView
android:id="#+id/cartFragmentTextTotal"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentStart="true"
android:layout_alignParentLeft="true"
android:text="Total"
android:textSize="20sp"
android:textStyle="bold|italic" />
<TextView
android:id="#+id/cartFragmentTotal"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignTop="#+id/total_tv"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:text="Total Right"
android:textSize="20sp"
android:textStyle="bold|italic" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/total_amount_tv"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:onClick="onClickSendOrder"
android:text="Button"
android:textColor="#android:color/white"
android:textSize="20sp" />
</RelativeLayout>
</androidx.constraintlayout.widget.ConstraintLayout>

Try this code
<androidx.core.widget.NestedScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport="true"
android:background="#android:color/white">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<androidx.recyclerview.widget.RecyclerView
android:id="#+id/cartRecyclerView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:nestedScrollingEnabled="false"/>
<TextView
android:id="#+id/cartFragmentTotal"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:margin_top="30dp"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:text="Total Cost"
android:textSize="20sp"
android:textStyle="bold|italic" />
<LinearLayout>
</androidx.core.widget.NestedScrollView>

Related

Format issue placing two views side by side in RelativeLayout

I have two views side by side inside a relative layout. I want the format of both views to be like the one on the left ("Today's Special"). I've assigned both views the same attributes though they are different.
here is my 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"
android:orientation="vertical"
tools:ignore="ExtraText">
<RelativeLayout
android:id="#+id/view_background"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#color/bg_row_background">
<ImageView
android:id="#+id/delete_icon"
android:layout_width="#dimen/ic_delete"
android:layout_height="#dimen/ic_delete"
android:layout_alignParentEnd="true"
android:layout_centerVertical="true"
android:layout_marginEnd="#dimen/padd_10"
android:contentDescription="#string/deleteIcon"
android:src="#drawable/ic_delete_white_24dp" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_marginEnd="#dimen/padd_10"
android:layout_toStartOf="#id/delete_icon"
android:text="#string/delete"
android:textColor="#fff"
android:textSize="12sp" />
</RelativeLayout>
<RelativeLayout
android:id="#+id/view_foreground"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#android:color/white"
android:padding="#dimen/padd_5">
<TextView
android:id="#+id/name"
android:layout_width="wrap_content"
android:layout_height="#dimen/ic_delete"
android:background="#color/description"
android:textColor="#color/item_name"
android:textSize="12sp" />
<TextView
android:id="#+id/namecat"
android:layout_width="wrap_content"
android:layout_height="#dimen/ic_delete"
android:layout_alignParentEnd="true"
android:layout_toEndOf="#id/name"
android:background="#color/description"
android:paddingStart="#dimen/padd_10"
android:textColor="#color/item_name"
android:textSize="12sp" />
</RelativeLayout>
</FrameLayout>
Thanks for your help.
Replace FrameLayout with LinearLayout and weightsum property
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:weightSum="2"
tools:ignore="ExtraText">
<RelativeLayout
android:id="#+id/view_background"
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="wrap_content"
android:background="#978c8c">
<ImageView
android:id="#+id/delete_icon"
android:layout_width="50dp"
android:layout_height="50dp"
android:layout_alignParentEnd="true"
android:layout_centerVertical="true"
android:src="#drawable/ic_lock" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_toStartOf="#id/delete_icon"
android:text="#string/dummy_button"
android:textColor="#fff"
android:textSize="12sp" />
</RelativeLayout>
<RelativeLayout
android:id="#+id/view_foreground"
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="wrap_content"
android:background="#android:color/white">
<TextView
android:id="#+id/name"
android:layout_width="wrap_content"
android:layout_height="50dp"
android:background="#color/colorAccent"
android:textColor="#color/colorPrimary"
android:textSize="12sp" />
<TextView
android:id="#+id/namecat"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_toEndOf="#id/name"
android:background="#color/colorAccent"
android:textColor="#color/colorPrimaryDark"
android:textSize="12sp" />
</RelativeLayout>
</LinearLayout>

Scroll view is not scrolling smoothly when tab layout and viewpager is placed inside scroll view?

I am facing the issue in scroll view is not scrolling smoothly when the tab navigation is placed inside the scroll view .
The below code is the xml file in which the tab navigation is placed inside the scroll view. I don't know the reason why this issue is occurring.Please help me how to solve this.
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="#+id/activity_interview_scam"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context="com.zcodia.scamlookup.Activities.ScamDetailsActivity">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
>
<ImageView
android:layout_width="match_parent"
android:layout_height="180dp"
android:foregroundGravity="center"
android:layout_alignParentStart="true"
android:layout_alignParentLeft="true"
android:id="#+id/profile_image"
android:background="#mipmap/bg_splash_cut"
android:src="#drawable/icon1"
/>
<TextView
android:text=""
android:textSize="20dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="16dp"
android:layout_marginBottom="8dp"
android:id="#+id/subCategoryTitle"
android:layout_above="#+id/textView11"
android:layout_alignParentStart="true"
android:layout_alignParentLeft="true"
android:textColor="#000000"/>
<TextView
android:text="Item ID:"
android:textSize="15dp"
android:textColor="#000000"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/textView11"
android:layout_alignBottom="#+id/profile_image"
android:layout_marginLeft="15dp"
android:layout_marginBottom="13dp" />
<TextView
android:text=""
android:textSize="15dp"
android:textColor="#000000"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/scamId"
android:layout_alignBottom="#+id/profile_image"
android:layout_marginLeft="75dp"
android:layout_marginBottom="13dp" />
<TextView
android:text="#string/arrow"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_alignParentStart="true"
android:layout_alignParentLeft="true"
android:layout_marginTop="19dp"
android:layout_marginLeft="10dp"
android:id="#+id/arrow_id"
android:textColor="#FFFFFF"
android:textSize="20dp"/>
</RelativeLayout>
<ScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:background="#FAFAFA"
android:focusableInTouchMode="true">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:id="#+id/linearLayout4"
android:layout_below="#+id/profile_image"
android:layout_alignParentStart="true"
android:layout_alignParentLeft="true"
>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/relative_layout_1"
android:background="#FFFFFF">
<TextView
android:layout_width="wrap_content"
android:layout_height="40dp"
android:text="No Of Cases Reported"
android:layout_marginLeft="15dp"
android:textSize="14dp"
android:id="#+id/report_cases_id"
android:gravity="center"/>
<TextView
android:textSize="14dp"
android:textColor="#EF5350"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/scam_report_count"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:layout_marginRight="10dp"
android:layout_marginTop="12dp"
/>
</RelativeLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#FAFAFA">
<TextView
android:layout_width="wrap_content"
android:layout_height="40dp"
android:text="Report Loss"
android:textSize="14dp"
android:paddingLeft="15dp"
android:layout_alignParentStart="true"
android:layout_alignParentLeft="true"
android:id="#+id/report_loss_id"
android:gravity="center"
/>
<TextView
android:textSize="14dp"
android:textColor="#EF5350"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/loos_id"
android:layout_marginRight="10dp"
android:paddingTop="12dp"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"/>
</RelativeLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#FFFFFF"
>
<TextView
android:layout_width="wrap_content"
android:layout_height="40dp"
android:text="Possible Scammer Location"
android:textSize="14dp"
android:paddingLeft="15dp"
android:gravity="center"
android:id="#+id/possible_scammer_location_id" />
<TextView
android:layout_width="150dp"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:textSize="14dp"
android:textColor="#EF5350"
android:paddingTop="12dp"
android:layout_marginRight="10dp"
android:id="#+id/scam_location"
android:ellipsize="end"/>
</RelativeLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="40dp"
android:background="#FAFAFA"
android:orientation="horizontal"
>
<TextView
android:layout_width="0dp"
android:layout_height="40dp"
android:text="Target Medium"
android:textSize="14dp"
android:paddingTop="10dp"
android:layout_weight="1"
android:layout_marginLeft="10dp"
/>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:orientation="horizontal"
android:layout_marginRight="0dp"
android:id="#+id/scam_medium_linear">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/scam_medium_icon"
android:textSize="20dp"
android:layout_gravity="center"
android:layout_alignParentRight="true"
android:layout_marginRight="10dp"
android:layout_marginTop="3dp"
android:textColor="#EF5350"
/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text=""
android:id="#+id/scam_medium_text"
android:textColor="#EF5350"
android:layout_marginTop="10dp"
android:layout_marginLeft="0dp"
android:layout_alignParentRight="true"
android:textSize="14dp"
android:gravity="center"
android:layout_marginRight="10dp"
/>
</LinearLayout>
</LinearLayout>
</LinearLayout>
<TextView
android:layout_width="wrap_content"
android:layout_height="30dp"
android:text="Tactic"
android:layout_marginLeft="15dp"
android:textSize="14dp"
android:gravity="center"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/tactic_linear_layout"
android:background="#drawable/margin_color"
android:orientation="horizontal"
android:layout_marginLeft="20dp"
android:layout_marginTop="0dp"
android:paddingBottom="10dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/add_new_tactics"
android:orientation="vertical">
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
>
<android.support.design.widget.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#drawable/rectangele_width"
>
<android.support.design.widget.TabLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="#+id/tab_layout"
app:tabMode="fixed"
app:tabTextColor="#ccc"
app:tabPaddingStart="12dp"
app:tabSelectedTextColor="#D32F2F"
app:tabIndicatorColor="#D32F2F"
app:tabGravity="fill"
></android.support.design.widget.TabLayout>
</android.support.design.widget.AppBarLayout>
</LinearLayout>
<android.support.v4.view.ViewPager
android:layout_width="match_parent"
android:layout_height="420dp"
android:id="#+id/viewPager2"
android:background="#FAFAFA">
</android.support.v4.view.ViewPager>
</LinearLayout>
</ScrollView>
</LinearLayout>
Replace android.support.v4.widget.NestedScrollView instead of scroll view. It works for me try this....

Scrollview not scrolling

I'm using a scroll view which is having only one child linearlayout.
Linearlayout contains listview and some other items also, but only listview is scrolling. what should i do ?
Here is my layout
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:fresco="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#color/beco_white"
android:orientation="vertical">
<include layout="#layout/toolbar" />
<ScrollView
android:layout_width="match_parent"
android:layout_height="fill_parent"
android:fillViewport="true">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<ViewSwitcher
android:id="#+id/view_switcher"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="125dp"
android:background="#android:color/white"
android:orientation="horizontal">
<Button
android:id="#+id/button_sign_in"
android:layout_width="150dp"
android:layout_height="40dp"
android:layout_gravity="center"
android:layout_marginLeft="#dimen/dp20"
android:background="#drawable/dark_blue_round_corner"
android:fontFamily="sans-serif-normal"
android:text="Login to beCo"
android:textAllCaps="false"
android:textColor="#android:color/white"
android:textSize="14sp" />
<Button
android:id="#+id/button_sign_up"
android:layout_width="150dp"
android:layout_height="40dp"
android:layout_gravity="center"
android:layout_marginLeft="20dp"
android:layout_marginRight="#dimen/dp20"
android:background="#drawable/customborder"
android:fontFamily="sans-serif-normal"
android:text="Create New Account"
android:textAllCaps="false"
android:textColor="#color/colorAccent"
android:textSize="14sp" />
</LinearLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="125dp"
android:background="#android:color/white">
<com.facebook.drawee.view.SimpleDraweeView
android:id="#+id/image_profile"
android:layout_width="#dimen/dp88"
android:layout_height="#dimen/dp88"
android:layout_gravity="left"
android:layout_marginBottom="#dimen/dp10"
android:layout_marginLeft="#dimen/dp10"
android:layout_marginTop="#dimen/dp10"
fresco:actualImageScaleType="centerCrop"
fresco:placeholderImage="#drawable/no_profile_pic"
fresco:roundAsCircle="true"
fresco:roundingBorderColor="#color/white"
fresco:roundingBorderWidth="#dimen/dp2" />
<TextView
android:id="#+id/user_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginLeft="#dimen/dp10"
android:layout_toRightOf="#+id/image_profile"
android:fontFamily="sans-serif-normal"
android:text="John Doe"
android:textColor="#android:color/black"
android:textSize="25sp" />
<TextView
android:id="#+id/email"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/user_name"
android:layout_marginLeft="#dimen/dp10"
android:layout_toEndOf="#+id/image_profile"
android:layout_toRightOf="#+id/image_profile"
android:fontFamily="sans-serif-normal"
android:text="johndoe#mail.com"
android:textColor="#android:color/black"
android:textSize="14sp" />
<Button
android:id="#+id/button_edit"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:layout_alignTop="#+id/image_profile"
android:background="#drawable/customborder"
android:text="Edit Profile"
android:textAllCaps="false"
android:textColor="#color/colorAccent" />
</RelativeLayout>
</ViewSwitcher>
<View
android:layout_width="wrap_content"
android:layout_height="1dp"
android:background="#color/grey_200" />
<ListView
android:id="#+id/list"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</LinearLayout>
</ScrollView>
</LinearLayout>
Any one please help me?
Never put A ListView inside a ScrollView. It is a bad practice and it defeats the purpose of having a ListView. Who wants two scrollable areas on a screen anyway?
Instead add a header or footer view on your listView depending on what you need.
If you look at the documentation https://developer.android.com/reference/android/widget/ScrollView.html it states that scrollview should never be used with listview there may be a conflict between them.
Try this layout:
changes:
Make your inner linearlayout wrap into Scrollview
Apply android:layout_height="wrap_content" for scrollview
End the scrollview before Listview as both can not be applied together
<?xml version="1.0" encoding="utf-8"?>
<include layout="#layout/toolbar" />
<ScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:fillViewport="false">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<ViewSwitcher
android:id="#+id/view_switcher"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="125dp"
android:background="#android:color/white"
android:orientation="horizontal">
<Button
android:id="#+id/button_sign_in"
android:layout_width="150dp"
android:layout_height="40dp"
android:layout_gravity="center"
android:layout_marginLeft="#dimen/dp20"
android:background="#drawable/dark_blue_round_corner"
android:fontFamily="sans-serif-normal"
android:text="Login to beCo"
android:textAllCaps="false"
android:textColor="#android:color/white"
android:textSize="14sp" />
<Button
android:id="#+id/button_sign_up"
android:layout_width="150dp"
android:layout_height="40dp"
android:layout_gravity="center"
android:layout_marginLeft="20dp"
android:layout_marginRight="#dimen/dp20"
android:background="#drawable/customborder"
android:fontFamily="sans-serif-normal"
android:text="Create New Account"
android:textAllCaps="false"
android:textColor="#color/colorAccent"
android:textSize="14sp" />
</LinearLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="125dp"
android:background="#android:color/white">
<com.facebook.drawee.view.SimpleDraweeView
android:id="#+id/image_profile"
android:layout_width="#dimen/dp88"
android:layout_height="#dimen/dp88"
android:layout_gravity="left"
android:layout_marginBottom="#dimen/dp10"
android:layout_marginLeft="#dimen/dp10"
android:layout_marginTop="#dimen/dp10"
fresco:actualImageScaleType="centerCrop"
fresco:placeholderImage="#drawable/no_profile_pic"
fresco:roundAsCircle="true"
fresco:roundingBorderColor="#color/white"
fresco:roundingBorderWidth="#dimen/dp2" />
<TextView
android:id="#+id/user_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginLeft="#dimen/dp10"
android:layout_toRightOf="#+id/image_profile"
android:fontFamily="sans-serif-normal"
android:text="John Doe"
android:textColor="#android:color/black"
android:textSize="25sp" />
<TextView
android:id="#+id/email"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/user_name"
android:layout_marginLeft="#dimen/dp10"
android:layout_toEndOf="#+id/image_profile"
android:layout_toRightOf="#+id/image_profile"
android:fontFamily="sans-serif-normal"
android:text="johndoe#mail.com"
android:textColor="#android:color/black"
android:textSize="14sp" />
<Button
android:id="#+id/button_edit"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:layout_alignTop="#+id/image_profile"
android:background="#drawable/customborder"
android:text="Edit Profile"
android:textAllCaps="false"
android:textColor="#color/colorAccent" />
</RelativeLayout>
</ViewSwitcher>
</LinearLayout>
</ScrollView>
<View
android:layout_width="wrap_content"
android:layout_height="1dp"
android:background="#color/grey_200" />
<ListView
android:id="#+id/list"
android:layout_width="match_parent"
android:layout_height="match_parent" />
Use NestedScrollView instead of ScrollView.
NestedScrollView is just like ScrollView, but it supports acting
as both a nested scrolling parent and child on both new and old
versions of Android.
See the Documentation
Update your XML as below:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:fresco="http://schemas.android.com/apk/res-auto"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#color/beco_white"
android:orientation="vertical">
<include layout="#layout/toolbar" />
<android.support.v4.widget.NestedScrollView
android:id="#+id/layout_scorll"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="#string/appbar_scrolling_view_behavior">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:descendantFocusability="blocksDescendants">
<ViewSwitcher
android:id="#+id/view_switcher"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="125dp"
android:background="#android:color/white"
android:orientation="horizontal">
<Button
android:id="#+id/button_sign_in"
android:layout_width="150dp"
android:layout_height="40dp"
android:layout_gravity="center"
android:layout_marginLeft="#dimen/dp20"
android:background="#drawable/dark_blue_round_corner"
android:fontFamily="sans-serif-normal"
android:text="Login to beCo"
android:textAllCaps="false"
android:textColor="#android:color/white"
android:textSize="14sp" />
<Button
android:id="#+id/button_sign_up"
android:layout_width="150dp"
android:layout_height="40dp"
android:layout_gravity="center"
android:layout_marginLeft="20dp"
android:layout_marginRight="#dimen/dp20"
android:background="#drawable/customborder"
android:fontFamily="sans-serif-normal"
android:text="Create New Account"
android:textAllCaps="false"
android:textColor="#color/colorAccent"
android:textSize="14sp" />
</LinearLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="125dp"
android:background="#android:color/white">
<com.facebook.drawee.view.SimpleDraweeView
android:id="#+id/image_profile"
android:layout_width="#dimen/dp88"
android:layout_height="#dimen/dp88"
android:layout_gravity="left"
android:layout_marginBottom="#dimen/dp10"
android:layout_marginLeft="#dimen/dp10"
android:layout_marginTop="#dimen/dp10"
fresco:actualImageScaleType="centerCrop"
fresco:placeholderImage="#drawable/no_profile_pic"
fresco:roundAsCircle="true"
fresco:roundingBorderColor="#color/white"
fresco:roundingBorderWidth="#dimen/dp2" />
<TextView
android:id="#+id/user_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginLeft="#dimen/dp10"
android:layout_toRightOf="#+id/image_profile"
android:fontFamily="sans-serif-normal"
android:text="John Doe"
android:textColor="#android:color/black"
android:textSize="25sp" />
<TextView
android:id="#+id/email"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/user_name"
android:layout_marginLeft="#dimen/dp10"
android:layout_toEndOf="#+id/image_profile"
android:layout_toRightOf="#+id/image_profile"
android:fontFamily="sans-serif-normal"
android:text="johndoe#mail.com"
android:textColor="#android:color/black"
android:textSize="14sp" />
<Button
android:id="#+id/button_edit"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:layout_alignTop="#+id/image_profile"
android:background="#drawable/customborder"
android:text="Edit Profile"
android:textAllCaps="false"
android:textColor="#color/colorAccent" />
</RelativeLayout>
</ViewSwitcher>
<View
android:layout_width="wrap_content"
android:layout_height="1dp"
android:background="#color/grey_200" />
<ListView
android:id="#+id/list"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</LinearLayout>
</android.support.v4.widget.NestedScrollView>
</LinearLayout>
I found the solution by using only with the listview. ie., removing scrollview, and by using headerview for the listview
Xml code for listview
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#color/beco_white"
android:orientation="vertical">
<include layout="#layout/toolbar" />
<View
android:layout_width="wrap_content"
android:layout_height="1dp"
android:background="#color/grey_200" />
<ListView
android:id="#+id/list"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:divider="#drawable/list_divider"
android:dividerHeight="#dimen/dp1"
android:headerDividersEnabled="false"
android:footerDividersEnabled="false" />
</LinearLayout>
xml code for headerview of listview
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:fresco="http://schemas.android.com/apk/res-auto"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ViewSwitcher
android:id="#+id/view_switcher"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="150dp"
android:background="#drawable/profile_background"
android:orientation="vertical">
<Button
android:id="#+id/button_sign_in"
android:layout_width="wrap_content"
android:layout_height="36dp"
android:layout_gravity="center_horizontal"
android:layout_marginTop="#dimen/dp40"
android:background="#drawable/dark_blue_round_corner"
android:fontFamily="sans-serif-medium"
android:text="Sign in"
android:textAllCaps="true"
android:textColor="#android:color/white"
android:textSize="14sp" />
<LinearLayout
android:id="#+id/button_sign_up"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginTop="#dimen/dp16">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:fontFamily="sans-serif-normal"
android:text="#string/new_to_beco"
android:textColor="#color/beco_white"
android:textSize="14sp" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginLeft="7dp"
android:fontFamily="sans-serif-normal"
android:text="#string/action_sign_up"
android:textAllCaps="true"
android:textColor="#color/beco_primary"
android:textSize="14sp" />
</LinearLayout>
</LinearLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="150dp"
android:background="#drawable/profile_background">
<com.facebook.drawee.view.SimpleDraweeView
android:id="#+id/image_profile"
android:layout_width="100dp"
android:layout_height="100dp"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_centerVertical="true"
android:layout_gravity="left"
android:layout_marginLeft="15dp"
android:layout_marginStart="15dp"
fresco:actualImageScaleType="centerCrop"
fresco:placeholderImage="#drawable/no_profile_pic"
fresco:roundAsCircle="true"
fresco:roundingBorderColor="#color/white"
fresco:roundingBorderWidth="#dimen/dp2" />
<TextView
android:id="#+id/user_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignTop="#+id/image_profile"
android:layout_gravity="center_horizontal"
android:layout_marginLeft="15dp"
android:layout_marginStart="15dp"
android:layout_marginTop="25dp"
android:layout_toEndOf="#+id/image_profile"
android:layout_toRightOf="#+id/image_profile"
android:fontFamily="sans-serif-medium"
android:text="John Doe"
android:textColor="#android:color/black"
android:textSize="18sp" />
<TextView
android:id="#+id/email"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/user_name"
android:layout_alignStart="#+id/user_name"
android:layout_below="#+id/user_name"
android:layout_marginTop="8dp"
android:fontFamily="sans-serif-normal"
android:text="johndoe#mail.com"
android:textColor="#android:color/black"
android:textSize="13sp" />
<ImageView
android:id="#+id/action_edit"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="#+id/email"
android:layout_alignTop="#+id/user_name"
android:layout_marginLeft="11dp"
android:layout_marginStart="11dp"
android:layout_toEndOf="#+id/user_name"
android:layout_toRightOf="#+id/user_name"
android:src="#drawable/ic_edit" />
</RelativeLayout>
</ViewSwitcher>

After fragment replace fragment view not scrollable

In the first fragmentA there is a RecyclerView. If clicked RecyclerView item, fragmentA replaced with fragmentB. For the first time when the open fragmentA it's work correctly. So when I click RecyclerView item, fragmentA replaced with fragmentB, but fragmentB not scrolling. Then when I back (by BackStack) to fragmentA, I found it also not scrollable, although it's was a scrollable before replacing with fragmentB. fragmentB also has RecyclerView's in horizontal stage. I can't understand what is the problem. Any idea,advice, help will be important for me. Thanks
MainActivity where I do replacing of fragments by listener
#Override
public void onObjectItemClicked(Fragment fragment) {
FragmentManager fragmentManager = getSupportFragmentManager();
fragmentManager.beginTransaction().setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN).replace(R.id.flContent, fragment).addToBackStack(null).commit();
fragmentManager.executePendingTransactions();
}
MainActivity layout
<RelativeLayout
android:layout_marginTop="?android:attr/actionBarSize"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<FrameLayout
android:id="#+id/flContent"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
</RelativeLayout>
FragmentA layout
<?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">
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:visibility="gone"
android:id="#+id/mapFragmentContainer"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
</LinearLayout>
<android.support.v7.widget.RecyclerView
android:id="#+id/objects_recyclerview"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
</RelativeLayout>
FragmentB layout
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#color/colorWhite">
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_alignParentTop="true">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<RelativeLayout
android:id="#+id/object_img_rl"
android:layout_width="match_parent"
android:layout_height="220dp"
>
<com.android.volley.toolbox.NetworkImageView
android:id="#+id/object_img"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_alignParentTop="true"
android:scaleType="centerCrop" />
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#drawable/dark_gradient"
/>
<RelativeLayout
android:visibility="gone"
android:id="#+id/aksia_img"
android:layout_width="80dp"
android:layout_height="80dp"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_alignParentTop="true">
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
app:srcCompat="#drawable/image_aksia" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_marginTop="20dp"
android:rotation="270"
android:text="#string/aksia"
android:textColor="#color/colorWhite" />
</RelativeLayout>
<ImageView
android:visibility="gone"
android:id="#+id/imgHalal"
android:layout_width="50dp"
android:layout_height="50dp"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:layout_marginEnd="20dp"
android:layout_marginRight="20dp"
app:srcCompat="#drawable/halal" />
<TextView
android:id="#+id/title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:ellipsize="end"
android:maxLines="1"
android:text="Ағайын"
android:textColor="#color/colorWhite"
android:textSize="19sp" />
<LinearLayout
android:id="#+id/time_ll"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/title"
android:layout_centerInParent="true"
android:layout_marginTop="8dp"
android:orientation="horizontal">
<ImageView
android:layout_width="10dp"
android:layout_height="10dp"
android:layout_gravity="center"
android:src="#drawable/ic_green_circle" />
<TextView
android:id="#+id/work_time"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginLeft="5dp"
android:ellipsize="end"
android:maxLines="1"
android:text="мкр Айнабулак 4, дом 1"
android:textColor="#color/colorWhite"
android:textSize="12sp" />
</LinearLayout>
<TextView
android:id="#+id/price"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/time_ll"
android:layout_centerInParent="true"
android:layout_gravity="end"
android:layout_marginTop="5dp"
android:maxLines="1"
android:text="мкр Айнабулак 4, дом 1"
android:textColor="#color/colorWhite"
android:textSize="12sp" />
<TextView
android:layout_marginTop="30dp"
android:id="#+id/object_type"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#color/colorWhite"
android:textSize="15sp"
android:layout_alignParentTop="true"
android:layout_centerInParent="true" />
</RelativeLayout>
<RelativeLayout
android:visibility="gone"
android:id="#+id/conOval"
android:layout_width="65dp"
android:layout_height="65dp"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_marginTop="180dp"
android:background="#drawable/oval_fragment_detail">
<TextView
android:id="#+id/rating"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:layout_gravity="center"
android:gravity="center"
android:text="5/5"
android:textColor="#color/colorAccent"
android:textSize="25sp" />
</RelativeLayout>
<LinearLayout
android:id="#+id/blok_one"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/object_img_rl"
android:layout_marginEnd="15dp"
android:layout_marginLeft="15dp"
android:layout_marginRight="15dp"
android:layout_marginStart="15dp"
android:layout_marginTop="35dp"
android:orientation="vertical">
<TextView
android:id="#+id/description"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#color/fragment_detail_text_color"
android:textSize="15sp" />
<android.support.v7.widget.RecyclerView
android:visibility="gone"
android:layout_gravity="center_horizontal"
android:id="#+id/kitchen_recycler_view"
android:layout_width="wrap_content"
android:layout_height="30dp"
android:layout_marginTop="20dp"
android:background="#fff" />
<android.support.v7.widget.RecyclerView
android:visibility="gone"
android:layout_gravity="center_horizontal"
android:id="#+id/service_recycler_view"
android:layout_width="wrap_content"
android:layout_height="70dp"
android:layout_marginTop="20dp"
android:background="#fff" />
<LinearLayout
android:visibility="gone"
android:id="#+id/con_aksia"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:background="#drawable/lynear_layout_border"
android:orientation="vertical"
android:padding="10dp">
<TextView
android:id="#+id/aksia"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/aksia"
android:textColor="#color/fragment_detail_text_color"
android:textSize="13sp" />
<TextView
android:id="#+id/aksia_content"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:text="Акция контент"
android:textColor="#color/fragment_detail_text_color"
android:textSize="12sp" />
</LinearLayout>
<Button
android:id="#+id/use_aksia"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginTop="15dp"
android:background="#color/colorAccent"
android:paddingLeft="5dp"
android:paddingRight="5dp"
android:text="#string/use_aksia"
android:textColor="#color/colorWhite"
android:textSize="14sp" />
</LinearLayout>
<TextView
android:id="#+id/phone1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="15dp"
android:textColor="#4A90E2"
android:textSize="14sp" />
<TextView
android:id="#+id/phone2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="15dp"
android:textColor="#4A90E2"
android:textSize="14sp" />
<TextView
android:id="#+id/email"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="15dp"
android:textColor="#4A90E2"
android:textSize="14sp" />
<TextView
android:id="#+id/address"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="15dp"
android:textColor="#color/fragment_detail_text_color"
android:textSize="14sp" />
<TextView
android:id="#+id/work_day"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="15dp"
android:textColor="#color/fragment_detail_text_color"
android:textSize="14sp" />
</LinearLayout>
<LinearLayout
android:id="#+id/blok_two"
android:layout_width="match_parent"
android:layout_height="60dp"
android:layout_below="#+id/blok_one"
android:layout_marginTop="25dp"
android:orientation="horizontal">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="#color/colorWhite">
<Button
android:id="#+id/btnMenu"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#drawable/button_border"
android:text="#string/menu"
android:textAllCaps="false"
android:textColor="#000000"
android:textSize="18sp" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="#color/colorWhite">
<Button
android:id="#+id/btnBron"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#drawable/button_border"
android:text="#string/bron"
android:textAllCaps="false"
android:textColor="#000000"
android:textSize="18sp" />
</LinearLayout>
</LinearLayout>
<LinearLayout
android:id="#+id/blok_three"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/blok_two"
android:background="#F5F4F4"
android:gravity="center"
android:orientation="horizontal"
android:padding="10dp">
<ImageButton
android:id="#+id/imgInsta"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="#F5F4F4"
/>
<ImageButton
android:id="#+id/imgWapp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="#F5F4F4"
/>
<ImageButton
android:id="#+id/imgFb"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="#F5F4F4"
/>
<ImageButton
android:id="#+id/imgVk"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="#F5F4F4"
/>
</LinearLayout>
<LinearLayout
android:id="#+id/blok_four"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/blok_three"
android:layout_margin="25dp"
android:orientation="vertical">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/gallery"
android:textColor="#color/fragment_detail_text_color"
android:textSize="14sp" />
<android.support.v7.widget.RecyclerView
android:clickable="true"
android:focusable="true"
android:background="?android:attr/selectableItemBackground"
android:layout_marginTop="10dp"
android:id="#+id/gallery_recycler_view"
android:layout_width="match_parent"
android:layout_height="160dp" />
</LinearLayout>
<LinearLayout
android:id="#+id/map"
android:layout_width="match_parent"
android:layout_height="170dp"
android:orientation="vertical"
android:layout_below="#+id/blok_four"
android:layout_marginBottom="25dp">
</LinearLayout>
<LinearLayout
android:background="#FFFFFF"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/comment_block"
android:orientation="vertical"
android:padding="25dp"
android:layout_below="#+id/map"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/comments"
android:textColor="#color/fragment_detail_text_color"
android:textSize="14sp" />
<android.support.v7.widget.RecyclerView
android:layout_marginTop="10dp"
android:id="#+id/comment_recycler_view"
android:layout_width="match_parent"
android:layout_height="match_parent" />
<Button
android:id="#+id/btnShowAllComments"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/show_all_comments"
android:textAllCaps="false"
android:layout_gravity="center_horizontal"
android:textColor="#4A90E2"
android:paddingLeft="40dp"
android:paddingRight="40dp"
android:theme="#style/buttonTransparentStyle"
style="?android:attr/borderlessButtonStyle"
/>
<Button
android:id="#+id/btnAddComment"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#drawable/button_selector_custom"
android:theme="#style/buttonTransparentStyle"
android:text="#string/add_comments"
android:textAllCaps="false"
android:textSize="16sp"
android:textColor="#4A90E2"
android:layout_gravity="center_horizontal"
android:paddingLeft="40dp"
android:paddingRight="40dp"
android:layout_marginTop="10dp"
/>
</LinearLayout>
</RelativeLayout>
</ScrollView>
</RelativeLayout>
In second fragment you are using recycler view inside scroll view which can cause scrolling issue. Replace scrollview by nestedscrollview which is avaiable in support.v4.widget library. and call this on recylerview recyclerView.setNestedScrollingEnabled(false);. Then recyler view will work properly inside nested scrollview

Add RelativeLayout with buttons below RecyclerView

I need to add a RelativeLayout below my RecyclerView and was able to do so, except that the button under TOTAL(R.id.total_amount_tv) does not show:
I can easily scroll through the items and it doesn't affect my RelativeLayout. I just need the button to be visible.
<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="wrap_content"
android:background="#android:color/white"
android:weightSum="1">
<android.support.v7.widget.RecyclerView
android:id="#+id/order_recycler"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="40dp"
tools:context=".ShoppingCartActivity" />
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginBottom="10dp"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp">
<TextView
android:id="#+id/total_tv"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:text="#string/total"
android:textSize="20sp"
android:textStyle="bold|italic" />
<TextView
android:id="#+id/total_amount_tv"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:layout_alignTop="#+id/total_tv"
android:textSize="20sp"
android:textStyle="bold|italic" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_below="#+id/total_amount_tv"
android:layout_marginTop="51dp"
android:background="#color/accent"
android:onClick="onClickSendOrder"
android:text="#string/order_btn"
android:textColor="#android:color/white"
android:textSize="20sp" />
</RelativeLayout>
</RelativeLayout>
You need to divide the screen in to two Parts one for showing the Recyclerview and other for RelativeLayout
<LinearLayout
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:background="#android:color/white"
android:orientation="vertical"
android:weightSum="10">
<android.support.v7.widget.RecyclerView
android:id="#+id/order_recycler"
android:layout_weight = "8.5"
android:layout_width="match_parent"
tools:context=".ShoppingCartActivity" />
<RelativeLayout
android:layout_weight = "1.5"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_marginRight="10dp">
<TextView
android:id="#+id/total_tv"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:text="Total"
android:textSize="20sp"
android:textStyle="bold|italic" />
<TextView
android:id="#+id/total_amount_tv"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:layout_alignTop="#+id/total_tv"
android:textSize="20sp"
android:text="Total Right"
android:textStyle="bold|italic" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/total_amount_tv"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:onClick="onClickSendOrder"
android:text="Button"
android:textColor="#android:color/white"
android:textSize="20sp" />
</RelativeLayout>
</LinearLayout>
This will produce the following results
android:layout_alignParentBottom="true"
This is the likely culprit. Both TextViews are aligned at the bottom of their parent RelativeLayout. This doesn't leave room for the Button.
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.v7.widget.RecyclerView
android:id="#+id/downline_listview"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_above="#+id/lin_result"
android:layout_marginTop="5dp" />
<LinearLayout
android:id="#+id/lin_result"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:background="#f8ffffff"
android:orientation="vertical"
android:paddingBottom="10dp">
<View
android:layout_width="match_parent"
android:layout_height="0.5dp"
android:layout_marginBottom="5dp"
android:background="#999898" />
<TextView
android:id="#+id/text_total_rupees"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_weight="1"
android:paddingLeft="10dp"
android:text="100"
android:textAppearance="#style/TextAppearance.AppCompat.Medium" />
</LinearLayout>
</RelativeLayout>

Categories

Resources