I have copied layout file from one project to another. In original project it looks like:
But in the project I've copied the file to the layout looks like:
These two XML are absolutely identical. Here is the code of them:
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout 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/constraintLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:alpha="1"
android:clickable="true"
android:background="#color/white"
>
<LinearLayout
android:id="#+id/linearlayout_filter"
android:layout_width="80dp"
android:layout_height="match_parent"
android:background="#color/black_80"
android:clickable="true"
android:focusable="true"
android:orientation="horizontal"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<android.support.constraint.ConstraintLayout
android:id="#+id/constraintLayout4"
android:layout_width="0dp"
android:layout_height="match_parent"
android:background="#color/white"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="#+id/linearlayout_filter"
app:layout_constraintTop_toTopOf="parent">
<TextView
android:id="#+id/textview_filters_heading"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="12dp"
android:layout_marginTop="12dp"
android:fontFamily="sans-serif"
android:lineSpacingExtra="6sp"
android:text="Filters"
android:textColor="#color/greyish_brown_two"
android:textSize="16sp"
android:textStyle="normal"
android:drawableLeft="#drawable/menu_filter_blue"
android:drawablePadding="10dp"
app:layout_constraintBottom_toBottomOf="#+id/button_reset"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<TextView
android:id="#+id/button_reset"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="12dp"
android:layout_marginEnd="12dp"
android:background="#color/white"
android:fontFamily="sans-serif"
android:lineSpacingExtra="5sp"
android:paddingStart="20dp"
android:paddingTop="5dp"
android:paddingEnd="20dp"
android:paddingBottom="5dp"
android:text="Reset"
android:textAllCaps="false"
android:textColor="#color/water_blue"
android:textSize="16sp"
android:textStyle="bold"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<View
android:id="#+id/filter_view"
android:layout_width="match_parent"
android:layout_marginTop="8dp"
android:layout_height="2dp"
android:background="#color/theme_bg"
app:layout_constraintTop_toBottomOf="#+id/textview_filters_heading" />
<ExpandableListView
android:id="#+id/expandablelistview_filter"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_marginTop="8dp"
android:layout_marginBottom="2dp"
android:layoutDirection="rtl"
app:layout_constraintTop_toBottomOf="#+id/button_reset"
app:layout_constraintBottom_toTopOf="#+id/cardview_apply"
/>
<android.support.v7.widget.CardView
android:id="#+id/cardview_apply"
android:layout_width="match_parent"
android:layout_height="0dp"
android:elevation="5dp"
app:cardElevation="10dp"
android:background="#color/white"
android:layout_marginTop="5dp"
app:layout_constraintBottom_toBottomOf="parent">
<Button
android:id="#+id/applyFiltersBtn"
style="#style/button_blue"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="16dp"
android:text="Apply" />
</android.support.v7.widget.CardView>
</android.support.constraint.ConstraintLayout>
</android.support.constraint.ConstraintLayout>
What can cause the problem? How to make the layout in the second project look like the layout from the first one?
you use wrong constraints import androidx library if you have not then use this code.
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout
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/constraintLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:alpha="1"
android:clickable="true"
android:background="#color/white"
>
<LinearLayout
android:id="#+id/linearlayout_filter"
android:layout_width="80dp"
android:layout_height="match_parent"
android:background="#color/black"
android:clickable="true"
android:focusable="true"
android:orientation="vertical"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<androidx.constraintlayout.widget.ConstraintLayout
android:id="#+id/constraintLayout4"
android:layout_width="0dp"
android:layout_height="match_parent"
android:background="#color/white"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="#+id/linearlayout_filter"
app:layout_constraintTop_toTopOf="parent">
<TextView
android:id="#+id/textview_filters_heading"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="12dp"
android:layout_marginTop="12dp"
android:fontFamily="sans-serif"
android:lineSpacingExtra="6sp"
android:text="Filters"
android:textColor="#color/greyish_brown_two"
android:textSize="16sp"
android:textStyle="normal"
android:drawableLeft="#drawable/menu_filter_blue"
android:drawablePadding="10dp"
app:layout_constraintBottom_toBottomOf="#+id/button_reset"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<TextView
android:id="#+id/button_reset"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="12dp"
android:layout_marginEnd="12dp"
android:background="#color/white"
android:fontFamily="sans-serif"
android:lineSpacingExtra="5sp"
android:paddingStart="20dp"
android:paddingTop="5dp"
android:paddingEnd="20dp"
android:paddingBottom="5dp"
android:text="Reset"
android:textAllCaps="false"
android:textColor="#color/water_blue"
android:textSize="16sp"
android:textStyle="bold"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<View
android:id="#+id/filter_view"
android:layout_width="match_parent"
android:layout_marginTop="8dp"
android:layout_height="2dp"
android:background="#color/theme_bg"
app:layout_constraintTop_toBottomOf="#+id/textview_filters_heading" />
<ExpandableListView
android:id="#+id/expandablelistview_filter"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_marginTop="8dp"
android:layout_marginBottom="2dp"
android:layoutDirection="rtl"
app:layout_constraintTop_toBottomOf="#+id/button_reset"
app:layout_constraintBottom_toTopOf="#+id/cardview_apply"
/>
<androidx.cardview.widget.CardView
android:id="#+id/cardview_apply"
android:layout_width="match_parent"
android:layout_height="0dp"
android:elevation="5dp"
app:cardElevation="10dp"
android:background="#color/white"
android:layout_marginTop="5dp"
app:layout_constraintBottom_toBottomOf="parent">
<Button
android:id="#+id/applyFiltersBtn"
style="#style/button_blue"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="16dp"
android:text="Apply" />
</androidx.cardview.widget.CardView>
</androidx.constraintlayout.widget.ConstraintLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
i hope it works for it.
Related
IMG Of output
How to remove the marked portion in the image given LINK
here is my XML code for the required
activity_all_transaction.xml Output of activity_all_transaction.xml
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout 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:fadingEdge="horizontal|vertical"
tools:context=".allTransaction"
android:background="#807D7D"
>
<androidx.recyclerview.widget.RecyclerView
android:id="#+id/recyclerview"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingTop="55dp"
android:paddingBottom="0dp"
android:background="#807D7D"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.0" />
<TextView
android:id="#+id/displayTotalallTransac"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="#drawable/lower_rounded"
android:elevation="20dp"
android:translationZ="5dp"
android:ellipsize="start"
android:fadingEdge="horizontal|vertical"
android:gravity="right"
android:paddingRight="5dp"
android:textColor="#color/black"
android:paddingBottom="5dp"
android:textSize="28sp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.54"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<Spinner
android:id="#+id/dropdownoption"
android:layout_width="31dp"
android:layout_height="36dp"
android:layout_marginTop="8dp"
android:elevation="30dp"
android:translationZ="7dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.042"
app:layout_constraintStart_toStartOf="#+id/displayTotalallTransac"
app:layout_constraintTop_toTopOf="parent"
android:background="#drawable/menu"/>
</androidx.constraintlayout.widget.ConstraintLayout>
my_row.xml Output of my_row.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#drawable/full_rounded">
<androidx.cardview.widget.CardView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#drawable/full_rounded"
>
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#drawable/full_rounded"
android:elevation="100dp"
android:layout_gravity="center"
>
<TextView
android:id="#+id/tid"
android:layout_width="wrap_content"
android:layout_height="39dp"
android:text="1"
android:textColor="#000000"
android:textSize="24sp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<TextView
android:id="#+id/ttime"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:layout_marginLeft="8dp"
android:layout_marginTop="8dp"
android:text="TextView"
android:textColor="#000000"
android:textSize="24sp"
app:layout_constraintStart_toEndOf="#+id/tid"
app:layout_constraintTop_toBottomOf="#+id/toperation" />
<TextView
android:id="#+id/tdate"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="TextView"
android:textColor="#000000"
android:textSize="12sp"
app:layout_constraintEnd_toEndOf="#+id/ttime"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintStart_toStartOf="#+id/ttime"
app:layout_constraintTop_toBottomOf="#+id/ttime" />
<TextView
android:id="#+id/toperation"
android:layout_width="151dp"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:layout_marginLeft="8dp"
android:gravity="left"
android:text="TextView"
android:textColor="#000000"
android:textSize="24sp"
app:layout_constraintStart_toEndOf="#+id/tid"
app:layout_constraintTop_toTopOf="#+id/tid" />
<TextView
android:id="#+id/tamount"
android:layout_width="206dp"
android:layout_height="match_parent"
android:layout_marginStart="188dp"
android:layout_marginLeft="188dp"
android:gravity="center"
android:text="TextView"
android:textColor="#000000"
android:textSize="24sp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
</androidx.cardview.widget.CardView>
</LinearLayout>
According to me, there is some padding or margin issue but I am not able to find it.
THANKS FOR THE HELP.
So the problem is this. At first it looks good:
But when I open my keyboard the first two items in the way of the keyboard shrink a little bit
This is the XML code of the layout:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout 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="wrap_content"
android:orientation="vertical">
<androidx.cardview.widget.CardView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="5dp"
card_view:cardBackgroundColor="#EFE8E8"
card_view:cardCornerRadius="8dp"
card_view:cardElevation="10dp"
card_view:cardUseCompatPadding="false">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="100dp"
android:orientation="horizontal">
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginLeft="10dp"
android:layout_weight="1"
android:text="TextView"
android:textSize="20sp"
android:textStyle="bold"></TextView>
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:orientation="vertical">
<TextView
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_marginLeft="10dp"
android:layout_weight="1"
android:gravity="center_vertical"
android:text="TextView" />
<TextView
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_marginLeft="10dp"
android:layout_weight="1"
android:gravity="center_vertical"
android:text="Difficulty" />
</LinearLayout>
</LinearLayout>
</androidx.cardview.widget.CardView>
</LinearLayout>
And this is the XML code of my activity where the recyclerview is displayed:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context=".subActivities.CreateWorkoutActivity">
<androidx.appcompat.widget.Toolbar
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?attr/colorPrimary"
android:minHeight="?attr/actionBarSize"
android:theme="?attr/actionBarTheme" />
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="10dp"
android:layout_marginTop="48dp"
android:textSize="18sp"
android:textStyle="bold"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.075"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<EditText
android:id="#+id/editText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="36dp"
android:ems="10"
android:inputType="textPersonName"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="#+id/textView10"
app:layout_constraintTop_toTopOf="parent" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="68dp"
android:text="TextView"
android:textSize="18sp"
android:textStyle="bold"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/editText" />
<ScrollView
android:id="#+id/scrollView3"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:maxHeight="220dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/textView">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<androidx.recyclerview.widget.RecyclerView
android:id="#+id/exerciseRecyclerView"
android:layout_width="match_parent"
android:layout_height="200dp"
android:layout_marginLeft="20dp"
android:layout_marginRight="20dp" />
</LinearLayout>
</ScrollView>
<Button
android:id="#+id/button"
android:layout_width="150dp"
android:layout_height="wrap_content"
android:layout_marginBottom="16dp"
android:background="#color/colorAccent"
android:text="Add"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.938"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/floatingActionButton"
app:layout_constraintVertical_bias="0.737" />
<com.google.android.material.floatingactionbutton.FloatingActionButton
android:id="#+id/floatingActionButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:clickable="true"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.498"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/scrollView3"
app:srcCompat="#drawable/add" />
</androidx.constraintlayout.widget.ConstraintLayout>
</LinearLayout>
Is there a way to prevent this?
Thanks for your help
Try this in your activity tag in manifest, add this line:
android:name=".SettingsActivity"
Like:
<activity
android:windowSoftInputMode="adjustPan"
android:name=".MyActivity"/>
I am using constraint layout for my page and it is working good if it in portrait but views are overlapping when it is landscape mode. I have added scroll view also , but still it is overlapping only.I need the card view should be present in the bottom and in landscape mode it should be visible while scrolling... I know the issue is because of that card view (cv_items).I don't know how to fix this issue.
Here is my xml,
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout
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:fillViewport="true"
android:background="#000000"
android:layout_height="match_parent">
<ScrollView
android:layout_width="0dp"
android:layout_height="0dp"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent"
android:layout_marginBottom="0dp"
app:layout_constraintBottom_toTopOf="#+id/cv_item">
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
>
<androidx.appcompat.widget.AppCompatTextView
android:id="#+id/tv_title"
style="#style/semiBoldTextInput"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginTop="#dimen/_20sdp"
android:text="#string/you_got_req"
android:textColor="#color/light3"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<androidx.cardview.widget.CardView
android:id="#+id/cv_center"
android:layout_width="#dimen/_150sdp"
android:layout_height="#dimen/_150sdp"
android:layout_gravity="center"
android:layout_marginTop="#dimen/_30sdp"
android:orientation="vertical"
app:cardBackgroundColor="#color/light3"
app:cardCornerRadius="#dimen/_150sdp"
app:cardElevation="#dimen/_10sdp"
app:contentPadding="#dimen/_2sdp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/tv_title">
<androidx.cardview.widget.CardView
android:id="#+id/cv_accept"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="#dimen/_10sdp"
app:cardBackgroundColor="#555555"
app:cardCornerRadius="#dimen/_150sdp">
<androidx.appcompat.widget.AppCompatTextView
style="#style/semiBoldTextInput"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="#string/accept"
android:textColor="#color/white"
android:textSize="#dimen/_15ssp" />
</androidx.cardview.widget.CardView>
</androidx.cardview.widget.CardView>
</androidx.constraintlayout.widget.ConstraintLayout>
</ScrollView>
<androidx.cardview.widget.CardView
android:id="#+id/cv_item"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_gravity="bottom"
android:layout_marginBottom="-25dp"
app:cardCornerRadius="#dimen/_15sdp"
app:layout_constrainedHeight="true"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintHeight_max="#dimen/_200sdp">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<androidx.appcompat.widget.AppCompatTextView
android:id="#+id/tv_order_number"
style="#style/semiBoldTextInput"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="#dimen/_20sdp"
android:layout_marginTop="#dimen/_20sdp"
android:gravity="center_vertical"
android:textColor="#color/black"
android:textSize="16sp"
tools:text="#123456789" />
<androidx.appcompat.widget.AppCompatTextView
android:id="#+id/tv_no_of_items"
style="#style/regularTextInput"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/tv_order_number"
android:layout_marginStart="#dimen/_20sdp"
android:layout_marginTop="#dimen/_5sdp"
android:gravity="center_vertical"
android:textColor="#color/gray"
tools:text="6" />
<androidx.appcompat.widget.AppCompatTextView
android:id="#+id/tv_items"
style="#style/regularTextInput"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/tv_order_number"
android:layout_alignBaseline="#+id/tv_no_of_items"
android:layout_marginStart="5dp"
android:layout_marginTop="#dimen/_5sdp"
android:layout_toEndOf="#+id/tv_no_of_items"
android:gravity="center_vertical"
android:text="#string/items"
android:textColor="#color/gray"
/>
<androidx.cardview.widget.CardView
android:id="#+id/cv_price"
android:layout_width="#dimen/_50sdp"
android:layout_height="#dimen/_30sdp"
android:layout_alignParentEnd="true"
android:layout_marginTop="#dimen/_10sdp"
android:layout_marginEnd="20dp"
android:gravity="center"
app:cardBackgroundColor="#color/colorPrimaryDark"
app:cardCornerRadius="#dimen/_15sdp">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center">
<androidx.appcompat.widget.AppCompatTextView
android:id="#+id/tv_amount"
style="#style/semiBoldTextInput"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:textColor="#color/white"
android:textSize="#dimen/_10ssp"
tools:text="1233 RS" />
</RelativeLayout>
</androidx.cardview.widget.CardView>
<View
android:id="#+id/divider1"
android:layout_width="match_parent"
android:layout_height="#dimen/dp_half"
android:layout_below="#id/tv_items"
android:layout_margin="#dimen/_10sdp"
android:background="#color/light4" />
<androidx.recyclerview.widget.RecyclerView
android:id="#+id/rv_items"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="#+id/divider1"
android:layout_marginStart="#dimen/_10sdp"
android:layout_marginEnd="#dimen/_10sdp"
android:layout_marginBottom="#dimen/_20sdp"
tools:itemCount="20"
tools:listitem="#layout/recycler_test_details" />
</RelativeLayout>
</androidx.cardview.widget.CardView>
</androidx.constraintlayout.widget.ConstraintLayout>
Please refer the screenshots.
Try to put everything inside ScrollView. Check below:
<?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"
xmlns:tools="http://schemas.android.com/tools"
android:background="#000000"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_gravity="bottom"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="20dp"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toTopOf="#+id/cv_item">
<androidx.appcompat.widget.AppCompatTextView
android:id="#+id/tv_title"
style="#style/semiBoldTextInput"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginTop="#dimen/_20sdp"
android:text="#string/you_got_req"
android:textColor="#color/light3"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<androidx.cardview.widget.CardView
android:id="#+id/cv_center"
android:layout_width="#dimen/_150sdp"
android:layout_height="#dimen/_150sdp"
android:layout_gravity="center"
android:layout_marginTop="#dimen/_30sdp"
android:orientation="vertical"
app:cardBackgroundColor="#color/light3"
app:cardCornerRadius="#dimen/_150sdp"
app:cardElevation="#dimen/_10sdp"
app:contentPadding="#dimen/_2sdp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/tv_title">
<androidx.cardview.widget.CardView
android:id="#+id/cv_accept"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="#dimen/_10sdp"
app:cardBackgroundColor="#555555"
app:cardCornerRadius="#dimen/_150sdp">
<androidx.appcompat.widget.AppCompatTextView
style="#style/semiBoldTextInput"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="#string/accept"
android:textColor="#color/white"
android:textSize="#dimen/_15ssp" />
</androidx.cardview.widget.CardView>
</androidx.cardview.widget.CardView>
</androidx.constraintlayout.widget.ConstraintLayout>
<androidx.cardview.widget.CardView
android:id="#+id/cv_item"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_gravity="bottom"
android:layout_marginBottom="-25dp"
app:cardCornerRadius="#dimen/_15sdp"
app:layout_constrainedHeight="true"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintHeight_max="#dimen/_200sdp">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<androidx.appcompat.widget.AppCompatTextView
android:id="#+id/tv_order_number"
style="#style/semiBoldTextInput"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="#dimen/_20sdp"
android:layout_marginTop="#dimen/_20sdp"
android:gravity="center_vertical"
android:textColor="#color/black"
android:textSize="16sp"
tools:text="#123456789" />
<androidx.appcompat.widget.AppCompatTextView
android:id="#+id/tv_no_of_items"
style="#style/regularTextInput"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/tv_order_number"
android:layout_marginStart="#dimen/_20sdp"
android:layout_marginTop="#dimen/_5sdp"
android:gravity="center_vertical"
android:textColor="#color/gray"
tools:text="6" />
<androidx.appcompat.widget.AppCompatTextView
android:id="#+id/tv_items"
style="#style/regularTextInput"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/tv_order_number"
android:layout_alignBaseline="#+id/tv_no_of_items"
android:layout_marginStart="5dp"
android:layout_marginTop="#dimen/_5sdp"
android:layout_toEndOf="#+id/tv_no_of_items"
android:gravity="center_vertical"
android:text="#string/items"
android:textColor="#color/gray"
/>
<androidx.cardview.widget.CardView
android:id="#+id/cv_price"
android:layout_width="#dimen/_50sdp"
android:layout_height="#dimen/_30sdp"
android:layout_alignParentEnd="true"
android:layout_marginTop="#dimen/_10sdp"
android:layout_marginEnd="20dp"
android:gravity="center"
app:cardBackgroundColor="#color/colorPrimaryDark"
app:cardCornerRadius="#dimen/_15sdp">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center">
<androidx.appcompat.widget.AppCompatTextView
android:id="#+id/tv_amount"
style="#style/semiBoldTextInput"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:textColor="#color/white"
android:textSize="#dimen/_10ssp"
tools:text="1233 RS" />
</RelativeLayout>
</androidx.cardview.widget.CardView>
<View
android:id="#+id/divider1"
android:layout_width="match_parent"
android:layout_height="#dimen/dp_half"
android:layout_below="#id/tv_items"
android:layout_margin="#dimen/_10sdp"
android:background="#color/light4" />
<androidx.recyclerview.widget.RecyclerView
android:id="#+id/rv_items"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="#+id/divider1"
android:layout_marginStart="#dimen/_10sdp"
android:layout_marginEnd="#dimen/_10sdp"
android:layout_marginBottom="#dimen/_20sdp"
tools:itemCount="20"
tools:listitem="#layout/recycler_test_details" />
</RelativeLayout>
</androidx.cardview.widget.CardView>
</androidx.constraintlayout.widget.ConstraintLayout>
</ScrollView>
This is the what my activity currently looks like.
I am able to elevate the first two CardView but for the bottom one it is not elevated. I have tried both app:cardElevation and android:elevation but none of the elevates the last card. (by the way what's the difference of these two?)
How can I elevate it?
<?xml version="1.0" encoding="utf-8"?>
<ScrollView
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
xmlns:app="http://schemas.android.com/apk/res-auto">
<android.support.constraint.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<android.support.v7.widget.Toolbar
android:id="#+id/ef_toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?android:attr/colorBackgroundFloating"
android:elevation="2dp"
app:contentInsetStart="0dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
<android.support.constraint.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<ImageButton
android:id="#+id/cancel_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
android:background="#android:color/transparent"
android:src="#drawable/ic_cancel"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<ImageButton
android:id="#+id/confirm_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="16dp"
android:background="#android:color/transparent"
android:src="#drawable/ic_confirm"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent" />
</android.support.constraint.ConstraintLayout>
</android.support.v7.widget.Toolbar>
<android.support.v7.widget.CardView
android:id="#+id/food_image_card"
android:layout_width="180dp"
android:layout_height="180dp"
android:layout_marginStart="20dp"
android:layout_marginTop="20dp"
android:layout_marginEnd="20dp"
app:cardElevation="2dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/ef_toolbar">
<android.support.constraint.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
android:id="#+id/food_image"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scaleType="centerCrop"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:srcCompat="#drawable/food_image_place_holder" />
<ImageButton
android:id="#+id/camera_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:srcCompat="#drawable/ic_camera" />
</android.support.constraint.ConstraintLayout>
</android.support.v7.widget.CardView>
<android.support.v7.widget.CardView
android:id="#+id/food_name_card_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="24dp"
app:cardElevation="2dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/food_image_card">
<EditText
android:id="#+id/edit_food_name"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="15dp"
android:ems="10"
android:hint="Food Name"
android:background="#null"
android:maxLength="50"
android:maxLines="1"
android:inputType="textPersonName"
android:importantForAutofill="no" />
</android.support.v7.widget.CardView>
<TextView
android:id="#+id/tags_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:layout_marginTop="16dp"
android:text="Tags"
android:textSize="16sp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/food_name_card_view" />
<ImageButton
android:id="#+id/add_tag_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="8dp"
android:background="#android:color/transparent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="#+id/tags_text"
app:srcCompat="#drawable/ic_add_dark" />
<android.support.v7.widget.CardView
android:id="#+id/tag_card_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:minHeight="120dp"
app:cardElevation="2dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/tags_text">
<FrameLayout
android:id="#+id/tags_frame"
android:layout_margin="4dp"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</android.support.v7.widget.CardView>
<TextView
android:id="#+id/food_note"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:layout_marginTop="16dp"
android:text="Note"
android:textSize="16sp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/tag_card_view" />
<android.support.v7.widget.CardView
android:id="#+id/food_note_card_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
app:cardElevation="2dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/food_note">
<EditText
android:id="#+id/edit_note"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="10dp"
android:ems="10"
android:textSize="16sp"
android:background="#null"
android:minHeight="200dp"
android:gravity="start|top"
android:inputType="textMultiLine"
android:singleLine="false" />
</android.support.v7.widget.CardView>
</android.support.constraint.ConstraintLayout>
</ScrollView>
add
Margin bottom = 10dp to this cardview
android:id="#+id/food_note_card_view"
This can be helpful
app:cardUseCompatPadding="true"
See the Below example
<androidx.cardview.widget.CardView
app:cardBackgroundColor="#FF0000"
app:cardElevation="2dp"
app:cardUseCompatPadding="true"
android:layout_width="match_parent"
android:layout_height="200dp"/>
Cardview not working properly inside Cardview.
Please try to place your cardview into another layout such as FrameLayout or RelativeLayout.
I have a XML layout as follows:
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout
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"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#color/accounts_details_page_background_color">
<android.support.v7.widget.CardView
android:id="#+id/overview_cardview"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:background="#color/white"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.0"
card_view:cardElevation="2dp"
card_view:ignore="PrivateResource">
<android.support.constraint.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="16dp"
android:layout_marginLeft="16dp"
android:layout_marginStart="16dp">
<TextView
android:id="#+id/fragment_compliance_details_overview"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:text="#string/compliance_details_fragment_overview"
android:textColor="#color/compliance_overview_title_color"
android:textSize="#dimen/text_size_small"
android:textStyle="bold"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<TextView
android:id="#+id/policy_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="32dp"
android:textColor="#color/black"
android:textSize="#dimen/text_size_large"
android:textStyle="bold"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#id/fragment_compliance_details_overview" />
<TextView
android:id="#+id/last_check_time_only"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="#dimen/text_size_small"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#id/policy_name" />
<View
android:id="#+id/horizontal_line_compliance"
android:layout_width="match_parent"
android:layout_height="2dp"
android:layout_marginTop="16dp"
android:background="?android:attr/listDivider"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#id/last_check_time_only" />
<TextView
android:id="#+id/compliance_policy_status_explanation"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:textSize="#dimen/text_size_small"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#id/horizontal_line_compliance" />
<TextView
android:id="#+id/last_check_time"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="4dp"
android:text="#string/last_compliance_check_time"
android:textSize="#dimen/text_size_small"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#id/compliance_policy_status_explanation" />
<TextView
android:id="#+id/compliance_user_action_advice"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="4dp"
android:text="#string/compliance_user_advice"
android:textSize="#dimen/text_size_small"
android:visibility="gone"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#id/last_check_time" />
</android.support.constraint.ConstraintLayout>
</android.support.v7.widget.CardView>
<android.support.v7.widget.CardView
android:id="#+id/details_cardview"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:background="#color/white"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#id/overview_cardview"
app:layout_constraintVertical_bias="0.0"
card_view:cardElevation="2dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="16dp"
android:layout_marginStart="16dp"
android:orientation="vertical">
<TextView
android:id="#+id/policy_details_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:text="#string/policy_details_title"
android:textColor="#color/compliance_overview_title_color"
android:textSize="14sp"
android:textStyle="bold"
android:visibility="gone" />
<ListView
android:id="#+id/compliance_rules_listview"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:visibility="gone" />
</LinearLayout>
</android.support.v7.widget.CardView>
</android.support.constraint.ConstraintLayout>
When the ListView has more than 3-4 rows the page does not scroll. The ListView does not scroll either.
I tried wrapping the whole thing in a NestedScrollView but that just gets the ListView scrolling and not even entirely.
I want the entire page to scroll and end scrolling when the ListView ends. Any ideas would help.
You don't need constraint layout for what you are doing.
Read about view weights.
Try this. (replace androix.* for your components)
<LinearLayout 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:layout_margin="16dp"
android:orientation="vertical">
<androidx.cardview.widget.CardView
android:id="#+id/overview_cardview"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:background="#color/white"
app:cardUseCompatPadding="true"
app:contentPadding="4dp"
card_view:cardElevation="2dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView
android:id="#+id/fragment_compliance_details_overview"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="test"
android:textStyle="bold"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<TextView
android:id="#+id/policy_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="test"
android:textColor="#color/black"
android:textStyle="bold"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#id/fragment_compliance_details_overview" />
<TextView
android:id="#+id/last_check_time_only"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="test"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#id/policy_name" />
<View
android:id="#+id/horizontal_line_compliance"
android:layout_width="match_parent"
android:layout_height="2dp"
android:layout_marginTop="16dp"
android:background="?android:attr/listDivider" />
<TextView
android:id="#+id/compliance_policy_status_explanation"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:text="test"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#id/horizontal_line_compliance" />
<TextView
android:id="#+id/last_check_time"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="4dp"
android:text="test"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#id/compliance_policy_status_explanation" />
<TextView
android:id="#+id/compliance_user_action_advice"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="4dp"
android:text="#string/has_accepted_your_invitation_to_fynd"
android:visibility="gone"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#id/last_check_time" />
</LinearLayout>
</androidx.cardview.widget.CardView>
<androidx.cardview.widget.CardView
android:id="#+id/details_cardview"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:background="#color/white"
app:cardUseCompatPadding="true"
app:contentPadding="4dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#id/overview_cardview"
app:layout_constraintVertical_bias="0.0"
card_view:cardElevation="2dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<TextView
android:id="#+id/policy_details_title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:text="test"
android:textSize="14sp"
android:textStyle="bold" />
<ListView
android:id="#+id/compliance_rules_listview"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</LinearLayout>
</androidx.cardview.widget.CardView>
</LinearLayout>