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>
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
<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>
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>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.