NestedScrollView dosent scroll all the way to the end of Fragment - android

I have an Activity open multiple Fragments using using ViewPager and TabLayout. When I try to implement scroll for the fragment using NestedScrollView, I am not able to scroll all the way to the end of the fragment. Is there something missing or incorrect with this layout?
Activity Layout:
<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:fresco="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="#string/appbar_scrolling_view_behavior">
<android.support.design.widget.AppBarLayout
android:id="#+id/detail_app_bar"
android:layout_width="match_parent"
android:layout_height="240dp"
android:theme="#style/ThemeOverlay.AppCompat.Dark.ActionBar"
app:layout_scrollFlags="scroll|exitUntilCollapsed">
<android.support.design.widget.CollapsingToolbarLayout
android:id="#+id/detail_collapsing_toolbar"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:contentScrim="#color/colorPrimary"
app:expandedTitleMargin="#dimen/horizontal_margin"
app:layout_scrollFlags="scroll|exitUntilCollapsed|snap">
<com.facebook.drawee.view.SimpleDraweeView
android:id="#+id/detail_photo"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
android:scaleType="centerCrop"
app:actualImageScaleType="focusCrop"
app:layout_collapseMode="parallax"
app:placeholderImageScaleType="centerInside"
app:viewAspectRatio="1.33"
fresco:placeholderImage="#drawable/empty_detail" />
<android.support.v7.widget.Toolbar
android:id="#+id/detail_toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
app:contentInsetStart="#dimen/horizontal_margin"
app:layout_collapseMode="pin"
app:popupTheme="#style/ThemeOverlay.AppCompat.Light" />
</android.support.design.widget.CollapsingToolbarLayout>
</android.support.design.widget.AppBarLayout>
<android.support.v4.view.ViewPager
android:id="#+id/detail_viewpager"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_behavior="#string/appbar_scrolling_view_behavior">
<android.support.design.widget.TabLayout
android:id="#+id/detail_tab_layout"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
app:tabGravity="fill"
app:tabMode="fixed"
app:tabSelectedTextColor="#color/colorAccent"
app:tabTextColor="#color/tertiaryText" />
</android.support.v4.view.ViewPager>
</android.support.design.widget.CoordinatorLayout>
Fragment Layout:
<android.support.v4.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:fillViewport="true"
android:background="#color/White"
android:clipToPadding="false"
android:padding="16dp"
app:layout_behavior="#string/appbar_scrolling_view_behavior"
tools:context=".UI.Details.DetailsActivity">
<android.support.constraint.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<android.support.constraint.Guideline
android:id="#+id/guideline"
android:layout_width="8dp"
android:layout_height="match_parent"
android:orientation="vertical"
app:layout_constraintGuide_percent="0.5" />
<TextView
android:id="#+id/current_temp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="8dp"
android:layout_marginLeft="8dp"
android:layout_marginRight="8dp"
android:layout_marginStart="8dp"
android:layout_marginTop="8dp"
android:text="TextView"
android:textSize="45sp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<ImageView
android:id="#+id/weather_condition_image"
android:layout_width="140dp"
android:layout_height="144dp"
android:layout_marginEnd="8dp"
android:layout_marginLeft="8dp"
android:layout_marginRight="8dp"
android:layout_marginStart="8dp"
android:layout_marginTop="8dp"
android:src="#drawable/ic_thunderstrom"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.498"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/current_temp" />
<TextView
android:id="#+id/weather_condition_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="8dp"
android:layout_marginLeft="8dp"
android:layout_marginRight="8dp"
android:layout_marginStart="8dp"
android:layout_marginTop="24dp"
android:text="TextView"
android:textSize="20sp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/weather_condition_image" />
<LinearLayout
android:id="#+id/linearLayout1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="48dp"
android:layout_marginStart="48dp"
android:layout_marginTop="16dp"
android:orientation="vertical"
app:layout_constraintBottom_toTopOf="#+id/linearLayout3"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/weather_condition_text">
<TextView
android:id="#+id/sunrise"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/sunrise" />
<TextView
android:id="#+id/sunrise_time"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="5:00am"
android:textColor="#color/Black"
android:textSize="20sp" />
</LinearLayout>
<LinearLayout
android:id="#+id/linearLayout2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="8dp"
android:layout_marginStart="8dp"
android:layout_marginTop="16dp"
android:orientation="vertical"
app:layout_constraintBottom_toTopOf="#+id/linearLayout4"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.300"
app:layout_constraintStart_toStartOf="#+id/guideline"
app:layout_constraintTop_toBottomOf="#+id/weather_condition_text">
<TextView
android:id="#+id/sunset"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/sunset" />
<TextView
android:id="#+id/sunset_time"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="6:00pm"
android:textColor="#color/Black"
android:textSize="20sp" />
</LinearLayout>
<LinearLayout
android:id="#+id/linearLayout3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="48dp"
android:layout_marginStart="48dp"
android:layout_marginTop="16dp"
android:orientation="vertical"
app:layout_constraintBottom_toTopOf="#+id/linearLayout5"
app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/linearLayout1">
<TextView
android:id="#+id/humidity"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/humidity" />
<TextView
android:id="#+id/humidity_percent"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="83%"
android:textColor="#color/Black"
android:textSize="20sp" />
</LinearLayout>
<LinearLayout
android:id="#+id/linearLayout4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="8dp"
android:layout_marginStart="8dp"
android:layout_marginTop="16dp"
android:orientation="vertical"
app:layout_constraintBottom_toTopOf="#+id/linearLayout6"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.300"
app:layout_constraintStart_toStartOf="#+id/guideline"
app:layout_constraintTop_toBottomOf="#+id/linearLayout2">
<TextView
android:id="#+id/wind"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/wind" />
<TextView
android:id="#+id/wind_speed"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="5.1mph"
android:textColor="#color/Black"
android:textSize="20sp" />
</LinearLayout>
<LinearLayout
android:id="#+id/linearLayout5"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="48dp"
android:layout_marginStart="48dp"
android:layout_marginTop="16dp"
android:orientation="vertical"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/linearLayout3">
<TextView
android:id="#+id/min_temp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/temp_min" />
<TextView
android:id="#+id/min_temp_value"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="72"
android:textColor="#color/Black"
android:textSize="20sp" />
</LinearLayout>
<LinearLayout
android:id="#+id/linearLayout6"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:orientation="vertical"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.340"
app:layout_constraintStart_toStartOf="#+id/guideline"
app:layout_constraintTop_toBottomOf="#+id/linearLayout4">
<TextView
android:id="#+id/max_temp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/temp_max" />
<TextView
android:id="#+id/max_temp_value"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="80"
android:textColor="#color/Black"
android:textSize="20sp" />
</LinearLayout>
</android.support.constraint.ConstraintLayout>
</android.support.v4.widget.NestedScrollView>

Related

Scroll View Clickable

enter image description here
<androidx.coordinatorlayout.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">
<com.google.android.material.appbar.AppBarLayout
android:id="#+id/appBarLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<androidx.appcompat.widget.Toolbar
android:id="#+id/myToolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?attr/colorPrimary"
android:minHeight="?attr/actionBarSize"
android:theme="?attr/actionBarTheme"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:title="Doctor Appointment"
app:titleTextColor="#fff"
tools:ignore="MissingConstraints" />
<Button
android:id="#+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="16dp"
android:layout_marginBottom="4dp"
android:background="#color/blue"
android:drawableLeft="#drawable/ic_action_logout"
android:text="Logout"
android:textColor="#color/white"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="#+id/myToolbar"
tools:ignore="MissingConstraints" />
</androidx.constraintlayout.widget.ConstraintLayout>
</com.google.android.material.appbar.AppBarLayout>
<androidx.viewpager.widget.ViewPager
android:id="#+id/view_pager"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="#string/appbar_scrolling_view_behavior">
<com.google.android.material.tabs.TabLayout
android:id="#+id/tabs"
android:layout_width="match_parent"
android:layout_height="wrap_content"
tools:ignore="SpeakableTextPresentCheck,SpeakableTextPresentCheck" />
</androidx.viewpager.widget.ViewPager>
<RelativeLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:gravity="center"
android:layout_height="match_parent">
<ScrollView
android:id="#+id/scrollView"
android:layout_width="411dp"
android:layout_height="712dp"
tools:ignore="MissingConstraints">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
tools:ignore="MissingConstraints">
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<Button
android:id="#+id/button"
android:layout_width="140dp"
android:layout_height="wrap_content"
android:layout_marginLeft="60dp"
android:layout_marginTop="70dp"
android:background="#drawable/my_border"
android:text="save"
android:textColor="#color/blue"
tools:ignore="MissingConstraints" />
<Button
android:id="#+id/button2"
android:layout_width="140dp"
android:layout_height="wrap_content"
android:layout_marginLeft="230dp"
android:layout_marginTop="70dp"
android:background="#drawable/my_border"
android:text="close"
android:textColor="#color/blue" />
</RelativeLayout>
<RadioGroup
android:id="#+id/G1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:paddingTop="10dp">
<RadioButton
android:id="#+id/R1"
android:layout_width="120dp"
android:layout_height="wrap_content"
android:text="By Speciality" />
<RadioButton
android:id="#+id/R2"
android:layout_width="120dp"
android:layout_height="wrap_content"
android:text="By Doctor"/>
</RadioGroup>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<ImageView
android:id="#+id/img2"
android:layout_width="80dp"
android:layout_height="80dp"
android:layout_marginStart="10dp"
android:layout_marginTop="25dp"
android:layout_marginEnd="25dp"
android:layout_marginBottom="25dp"
android:src="#drawable/female_doctor" />
<TextView
android:id="#+id/Name1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="30dp"
android:layout_toEndOf="#+id/img2"
android:text="Dr. J. Anitha Ponmalar"
android:textColor="#000000"
android:textSize="14sp"
android:textStyle="bold" />
<TextView
android:id="#+id/degree1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/Name1"
android:layout_marginTop="15dp"
android:layout_toEndOf="#+id/img2"
android:text="M.B.B.S., DCH, MD physiology"
android:textColor="#000000"
android:textSize="14sp" />
<TextView
android:id="#+id/branch1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/degree1"
android:layout_marginTop="15dp"
android:layout_toEndOf="#+id/img2"
android:text="Dermatology"
android:textColor="#000000"
android:textSize="14sp" />
<TextView
android:id="#+id/time1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="190dp"
android:layout_marginTop="99dp"
android:layout_toEndOf="#+id/img2"
android:text="Fee : 309" />
</RelativeLayout>
</LinearLayout>
</ScrollView>
</RelativeLayout>
</androidx.coordinatorlayout.widget.CoordinatorLayout>
How to implement Scroll View clickable and while clicking the Scroll View I need to navigate to another activity.Here I have attached the image ,I have used an image and text in Scroll View.In java file I have used radio button click.Can you help me to make Scroll View clickable with java code? I have tried implementing the scroll view as clickable using on click Listener but it doesn't work.
Add an id in the linearlayout like in the code below:
<androidx.coordinatorlayout.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" tools:context=".MainActivity">
<com.google.android.material.appbar.AppBarLayout
android:id="#+id/appBarLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<androidx.appcompat.widget.Toolbar
android:id="#+id/myToolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?attr/colorPrimary"
android:minHeight="?attr/actionBarSize"
android:theme="?attr/actionBarTheme"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:title="Doctor Appointment"
app:titleTextColor="#fff"
tools:ignore="MissingConstraints" />
<Button
android:id="#+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="16dp"
android:layout_marginBottom="4dp"
android:background="#color/blue"
android:drawableLeft="#drawable/ic_action_logout"
android:text="Logout"
android:textColor="#color/white"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="#+id/myToolbar"
tools:ignore="MissingConstraints" />
</androidx.constraintlayout.widget.ConstraintLayout>
</com.google.android.material.appbar.AppBarLayout>
<androidx.viewpager.widget.ViewPager
android:id="#+id/view_pager"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="#string/appbar_scrolling_view_behavior">
<com.google.android.material.tabs.TabLayout
android:id="#+id/tabs"
android:layout_width="match_parent"
android:layout_height="wrap_content"
tools:ignore="SpeakableTextPresentCheck,SpeakableTextPresentCheck" />
</androidx.viewpager.widget.ViewPager>
<RelativeLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:gravity="center"
android:layout_height="match_parent">
<ScrollView
android:id="#+id/scrollView"
android:layout_width="411dp"
android:layout_height="712dp"
tools:ignore="MissingConstraints">
<LinearLayout
android:id="#+id/llMyScrollView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
tools:ignore="MissingConstraints">
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<Button
android:id="#+id/button"
android:layout_width="140dp"
android:layout_height="wrap_content"
android:layout_marginLeft="60dp"
android:layout_marginTop="70dp"
android:background="#drawable/my_border"
android:text="save"
android:textColor="#color/blue"
tools:ignore="MissingConstraints" />
<Button
android:id="#+id/button2"
android:layout_width="140dp"
android:layout_height="wrap_content"
android:layout_marginLeft="230dp"
android:layout_marginTop="70dp"
android:background="#drawable/my_border"
android:text="close"
android:textColor="#color/blue" />
</RelativeLayout>
<RadioGroup
android:id="#+id/G1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:paddingTop="10dp">
<RadioButton
android:id="#+id/R1"
android:layout_width="120dp"
android:layout_height="wrap_content"
android:text="By Speciality" />
<RadioButton
android:id="#+id/R2"
android:layout_width="120dp"
android:layout_height="wrap_content"
android:text="By Doctor"/>
</RadioGroup>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<ImageView
android:id="#+id/img2"
android:layout_width="80dp"
android:layout_height="80dp"
android:layout_marginStart="10dp"
android:layout_marginTop="25dp"
android:layout_marginEnd="25dp"
android:layout_marginBottom="25dp"
android:src="#drawable/female_doctor" />
<TextView
android:id="#+id/Name1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="30dp"
android:layout_toEndOf="#+id/img2"
android:text="Dr. J. Anitha Ponmalar"
android:textColor="#000000"
android:textSize="14sp"
android:textStyle="bold" />
<TextView
android:id="#+id/degree1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/Name1"
android:layout_marginTop="15dp"
android:layout_toEndOf="#+id/img2"
android:text="M.B.B.S., DCH, MD physiology"
android:textColor="#000000"
android:textSize="14sp" />
<TextView
android:id="#+id/branch1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/degree1"
android:layout_marginTop="15dp"
android:layout_toEndOf="#+id/img2"
android:text="Dermatology"
android:textColor="#000000"
android:textSize="14sp" />
<TextView
android:id="#+id/time1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="190dp"
android:layout_marginTop="99dp"
android:layout_toEndOf="#+id/img2"
android:text="Fee : 309" />
</RelativeLayout>
</LinearLayout>
</ScrollView>
</RelativeLayout>
</androidx.coordinatorlayout.widget.CoordinatorLayout>
And change your onclick listener to this:
LinearLayout llayout = findViewById(R.id.llMyScrollView);
llayout.setOnClickListener(new View.OnClickListener() {
#Override public void onClick(View v) {
Intent intent = new Intent(Dermatology.this,Spec_Derm.class);
startActivity(intent);
}
});

ScrollView in a fragment inside ViewPager is not scrolling

I have a tablayout and a viewpager in an activity, inside viewpager I'm displaying a fragment with a scrollview as it's root layout, and for some reason it's not scrolling. I've been trying to make it work for hours, but nothing worked so far, please help.
This is my activity:
<?xml version="1.0" encoding="utf-8"?>
<androidx.coordinatorlayout.widget.CoordinatorLayout 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/parent_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".PreferencesActivity">
<com.google.android.material.appbar.AppBarLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<com.google.android.material.appbar.MaterialToolbar
android:id="#+id/toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#drawable/bg_toolbar_preferences"
android:textAlignment="center"
app:theme="#style/ThemeOverlay.AppCompat.Dark.ActionBar">
<TextView
android:id="#+id/toolbar_title"
style="#style/TextAppearance.AppCompat.Widget.ActionBar.Title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="#string/prefs_title"
android:textColor="#android:color/white"
android:textStyle="bold" />
</com.google.android.material.appbar.MaterialToolbar>
<androidx.viewpager.widget.ViewPager
android:id="#+id/view_pager"
android:layout_width="match_parent"
android:layout_height="match_parent">
<com.google.android.material.tabs.TabLayout
android:id="#+id/tabs"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#color/white"
android:elevation="5dp" />
</androidx.viewpager.widget.ViewPager>
</com.google.android.material.appbar.AppBarLayout>
</androidx.coordinatorlayout.widget.CoordinatorLayout>
And this is my fragment with scroll view:
<?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:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".fragmentsPrefsActivity.FragmentAppPrefs">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:paddingLeft="32dp"
android:paddingRight="32dp">
<androidx.cardview.widget.CardView
android:id="#+id/cardView_alerts"
style="#style/app_prefs_cardView">
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:id="#+id/textView"
style="#style/app_prefs_text_header"
android:text="Alerts"
android:textSize="18sp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<com.suke.widget.SwitchButton
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginEnd="16dp"
app:layout_constraintBottom_toBottomOf="#+id/textView3"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="#+id/textView3"
app:sb_checked="true"
app:sb_checked_color="#color/colorPrefsDark"
app:sb_show_indicator="false" />
<TextView
android:id="#+id/textView3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:layout_marginTop="16dp"
android:layout_marginBottom="16dp"
android:text="Sound"
android:textColor="#color/textColor"
android:textSize="18sp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="#+id/textView"
app:layout_constraintTop_toBottomOf="#+id/textView" />
</androidx.constraintlayout.widget.ConstraintLayout>
</androidx.cardview.widget.CardView>
<TextView
android:id="#+id/text_men"
style="#style/app_prefs_description_text"
android:text="#string/prefs_alerts_description" />
<androidx.cardview.widget.CardView
android:id="#+id/cardView_matchMakerOnlyMode"
style="#style/app_prefs_cardView">
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<com.suke.widget.SwitchButton
android:id="#+id/switchButton"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginEnd="16dp"
app:layout_constraintBottom_toBottomOf="#+id/textView21"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="#+id/textView21"
app:sb_checked_color="#color/colorPrefsDark"
app:sb_show_indicator="false" />
<TextView
android:id="#+id/textView10"
style="#style/app_prefs_text_header"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
android:layout_marginTop="16dp"
android:text="Matchmaker-Only Mode"
android:textSize="18sp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<TextView
android:id="#+id/textView21"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:layout_marginTop="16dp"
android:layout_marginBottom="16dp"
android:text="Hide My Profile"
android:textColor="#color/textColor"
android:textSize="18sp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="#+id/textView10"
app:layout_constraintTop_toBottomOf="#+id/textView10" />
</androidx.constraintlayout.widget.ConstraintLayout>
</androidx.cardview.widget.CardView>
<TextView
android:id="#+id/textView11"
style="#style/app_prefs_description_text"
android:text="#string/prefs_match_maker_only_mode_description" />
<androidx.cardview.widget.CardView
android:id="#+id/cardView3"
style="#style/app_prefs_cardView">
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:id="#+id/cardView_selectLanguage"
style="#style/app_prefs_text_header"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
android:layout_marginTop="16dp"
android:text="Select Language"
android:textSize="18sp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<Spinner
android:id="#+id/language_spinner"
style="#style/app_prefs_text"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
android:layout_marginTop="16dp"
android:layout_marginEnd="16dp"
android:layout_marginBottom="16dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/cardView_selectLanguage" />
</androidx.constraintlayout.widget.ConstraintLayout>
</androidx.cardview.widget.CardView>
<TextView
android:id="#+id/textView17"
style="#style/app_prefs_description_text"
android:text="#string/prefs_select_language_description" />
<androidx.cardview.widget.CardView
android:id="#+id/cardView_enableNotifications"
style="#style/app_prefs_cardView">
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:id="#+id/textView18"
style="#style/app_prefs_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
android:text="Enable notifications from GoGaga"
android:textColor="#151515"
android:textSize="16sp"
app:layout_constraintBottom_toBottomOf="#+id/btn_go"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="#+id/btn_go" />
<Button
android:id="#+id/btn_go"
style="?attr/borderlessButtonStyle"
android:layout_width="50dp"
android:layout_height="50dp"
android:layout_marginTop="16dp"
android:layout_marginEnd="16dp"
android:layout_marginBottom="16dp"
android:background="#drawable/ripple_btn_go"
android:text="Go"
android:textColor="#color/white"
android:textSize="18sp"
android:textStyle="bold"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintDimensionRatio=""
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
</androidx.cardview.widget.CardView>
<TextView
android:id="#+id/textView19"
style="#style/app_prefs_description_text"
android:text="#string/prefs_enable_notification_description" />
</LinearLayout>
</ScrollView>
Could you try to get your ViewPager tag outside AppBarLayout
So your activity xml should be like:
<CoordinatorLayout>
<AppBarLayout>
//...
</AppBarLayout>
<ViewPager>
//...
</ViewPager>
</CoordinatorLayout>
and don't forget to add this attribute to your view pager:
app:layout_behavior="com.google.android.material.appbar.AppBarLayout$ScrollingViewBehavior"

ConstrainLayout Not scrolling inside NestedScrollview

I am trying to make my layout scrollable with constrainlayout but it's not scrolling at all i also tried with scrollview and nestedscrollview also tried by making constrain root layout but still not getting scrollable layout. Here is my XML layout. Can you please tell me what i am doing wrong here
<?xml version="1.0" encoding="utf-8"?>
<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:colorBackground"
android:clickable="true"
android:fillViewport="true"
android:focusable="true">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<androidx.constraintlayout.widget.ConstraintLayout
android:id="#+id/coverProfileImage"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?android:colorBackground">
<ImageView
android:id="#+id/coverPhoto"
android:layout_width="match_parent"
android:layout_height="500dp"
android:src="#color/custom_transparent_colorBlack"
android:scaleType="centerCrop"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
tools:srcCompat="#tools:sample/backgrounds/scenic" />
<de.hdodenhof.circleimageview.CircleImageView
android:id="#+id/profilePic"
android:layout_width="128dp"
android:layout_height="128dp"
app:layout_constraintBottom_toBottomOf="#+id/coverPhoto"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="#+id/coverPhoto"
app:layout_constraintVertical_bias="0.44"
tools:srcCompat="#tools:sample/avatars" />
<ImageButton
android:id="#+id/addFriendButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#drawable/round_shape_only"
android:padding="10dp"
app:layout_constraintBottom_toBottomOf="#+id/profilePic"
app:layout_constraintEnd_toStartOf="#+id/profilePic"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="#+id/profilePic"
app:srcCompat="#drawable/ic_add_friend" />
<ImageButton
android:id="#+id/messageButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#drawable/round_shape_only"
android:padding="10dp"
app:layout_constraintBottom_toBottomOf="#+id/profilePic"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="#+id/profilePic"
app:layout_constraintTop_toTopOf="#+id/profilePic"
app:srcCompat="#drawable/ic_message" />
<TextView
android:id="#+id/name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="TextView"
android:textSize="18sp"
android:textStyle="bold"
app:layout_constraintBottom_toBottomOf="#+id/coverPhoto"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/profilePic"
app:layout_constraintVertical_bias="0.100000024" />
<TextView
android:id="#+id/cityCountry"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:text="TextView"
app:layout_constraintBottom_toBottomOf="#+id/coverPhoto"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/name"
app:layout_constraintVertical_bias="0.0" />
<TextView
android:id="#+id/followerCount"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="410dp"
android:text="TextView"
app:layout_constraintEnd_toStartOf="#+id/followingCount"
app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintStart_toEndOf="#+id/coverPhoto"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<TextView
android:id="#+id/followingCount"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="TextView"
app:layout_constraintBottom_toBottomOf="#+id/followerCount"
app:layout_constraintEnd_toStartOf="#+id/friendsCount"
app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintStart_toEndOf="#+id/followerCount"
app:layout_constraintTop_toTopOf="#+id/followerCount" />
<TextView
android:id="#+id/friendsCount"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="TextView"
app:layout_constraintBottom_toBottomOf="#+id/followingCount"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintStart_toEndOf="#+id/followingCount"
app:layout_constraintTop_toTopOf="#+id/followingCount" />
<TextView
android:id="#+id/followersTag"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="460dp"
android:text="TextView"
app:layout_constraintEnd_toEndOf="#+id/followerCount"
app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintStart_toStartOf="#+id/followerCount"
app:layout_constraintTop_toTopOf="parent" />
<TextView
android:id="#+id/followingTag"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="TextView"
app:layout_constraintBaseline_toBaselineOf="#+id/followersTag"
app:layout_constraintEnd_toEndOf="#+id/followingCount"
app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintStart_toStartOf="#+id/followingCount" />
<TextView
android:id="#+id/friendsTag"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="TextView"
app:layout_constraintBaseline_toBaselineOf="#+id/followingTag"
app:layout_constraintEnd_toEndOf="#+id/friendsCount"
app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintStart_toStartOf="#+id/friendsCount" />
</androidx.constraintlayout.widget.ConstraintLayout>
<androidx.core.widget.NestedScrollView
android:id="#+id/up_NestedScrollView"
android:layout_width="match_parent"
android:layout_height="match_parent"
>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingLeft="5dp"
android:paddingRight="5dp"
>
<com.google.android.material.tabs.TabLayout
android:id="#+id/tabItemes"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<com.google.android.material.tabs.TabItem
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Monday" />
<com.google.android.material.tabs.TabItem
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Tuesday" />
<com.google.android.material.tabs.TabItem
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Wednesday" />
</com.google.android.material.tabs.TabLayout>
<androidx.viewpager.widget.ViewPager
android:id="#+id/profileViewPager"
android:layout_below="#id/tabItemes"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</RelativeLayout>
</androidx.core.widget.NestedScrollView>
</RelativeLayout>
</androidx.core.widget.NestedScrollView>
Add a CoordinatorLayout at the top of the nestedScrollView and set app:layout_behavior="#string/appbar_scrolling_view_behavior" for NestedScrollView
<androidx.coordinatorlayout.widget.CoordinatorLayout
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:isScrollContainer="true"
android:measureAllChildren="true"
app:layout_behavior="#string/appbar_scrolling_view_behavior"
android:background="#color/colorPrimary">
<androidx.constraintlayout.widget.ConstraintLayout
android:id="#+id/home_constraint"
android:layout_width="match_parent"
android:layout_height="match_parent">
</androidx.constraintlayout.widget.ConstraintLayout>
</androidx.core.widget.NestedScrollView>
</androidx.coordinatorlayout.widget.CoordinatorLayout>
you need to add
android:isScrollContainer="true"
In your nestedScrollView

how can i remove space between constraintlayout and include layers?

I want to remove white space that I show in picture
Picure
I draw red circle around white space on picture
and I want remove it
I search in stackoverflow but in that case i can not find any anwswer.
My main layout is -->
toolbar_normal.xml:
<?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:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">
<include layout="#layout/city_detail_act"
android:id="#+id/content"/>
<android.support.v7.widget.Toolbar
android:id="#+id/tolbar_storyButton"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#66cc66"
android:minHeight="?attr/actionBarSize"
android:theme="?attr/actionBarTheme"
app:contentInsetLeft="0dp"
app:contentInsetStart="0dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
>
<android.support.constraint.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:gravity="center"
android:orientation="horizontal"
tools:layout_editor_absoluteX="16dp">
<ImageView
android:id="#+id/imgSetting"
android:layout_width="40dp"
android:layout_height="40dp"
android:layout_marginStart="16dp"
android:layout_marginLeft="16dp"
android:layout_marginTop="8dp"
android:layout_marginBottom="8dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:srcCompat="#drawable/setting" />
<ImageView
android:id="#+id/imgChoiceCity"
android:layout_width="80dp"
android:layout_height="50dp"
android:layout_marginStart="181dp"
android:layout_marginLeft="181dp"
android:layout_marginTop="3dp"
android:layout_marginEnd="180dp"
android:layout_marginRight="180dp"
android:layout_marginBottom="3dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:srcCompat="#drawable/choicecity" />
<ImageView
android:id="#+id/imageViewButton"
android:layout_width="40dp"
android:layout_height="40dp"
android:layout_marginTop="8dp"
android:layout_marginEnd="16dp"
android:layout_marginRight="16dp"
android:layout_marginBottom="8dp"
android:adjustViewBounds="false"
android:scaleType="centerInside"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:srcCompat="#drawable/home" />
</android.support.constraint.ConstraintLayout>
</android.support.v7.widget.Toolbar>
</android.support.constraint.ConstraintLayout>
My second layout is -->
city_detail_act.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="match_parent"
android:orientation="vertical"
android:gravity="top"
android:paddingBottom="65dp"
>
<android.support.v7.widget.Toolbar
android:id="#+id/tolbar_story"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#66cc66"
android:minHeight="?attr/actionBarSize"
android:theme="?attr/actionBarTheme"
app:contentInsetLeft="0dp"
app:contentInsetStart="0dp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
<android.support.constraint.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:gravity="center"
android:orientation="horizontal"
tools:layout_editor_absoluteX="16dp">
<ImageView
android:id="#+id/imgTooTitlelbarMainActf"
android:layout_width="40dp"
android:layout_height="40dp"
android:layout_marginStart="16dp"
android:layout_marginLeft="16dp"
android:layout_marginTop="8dp"
android:layout_marginBottom="8dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:srcCompat="#drawable/adamak" />
<ImageView
android:id="#+id/imgTooTitlelbarMainAct"
android:layout_width="50dp"
android:layout_height="50dp"
android:layout_marginStart="180dp"
android:layout_marginLeft="180dp"
android:layout_marginTop="3dp"
android:layout_marginEnd="181dp"
android:layout_marginRight="181dp"
android:layout_marginBottom="3dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:srcCompat="#drawable/title" />
<ImageView
android:id="#+id/imgNavigationView"
android:layout_width="wrap_content"
android:layout_height="30dp"
android:layout_marginTop="8dp"
android:layout_marginEnd="16dp"
android:layout_marginRight="16dp"
android:layout_marginBottom="8dp"
android:adjustViewBounds="false"
android:scaleType="centerInside"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:srcCompat="#drawable/dot" />
</android.support.constraint.ConstraintLayout>
</android.support.v7.widget.Toolbar>
<android.support.v4.widget.NestedScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport="true">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<TextView
android:id="#+id/tx_state6"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text=" "
android:textSize="15sp"
android:fontFamily="#font/adobearabicregular"
/>
<ImageView
android:id="#+id/imv_refresh2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#id/tx_state6"
android:layout_centerHorizontal="true"
android:layout_gravity="center"
android:layout_marginTop="40dp"
android:padding="10px"
android:src="#drawable/refresh"
/>
<WebView
android:id="#+id/web2"
android:layout_width="76dp"
android:layout_height="76dp"
android:layout_below="#+id/imv_refresh2"
android:layout_centerHorizontal="true"
android:layout_gravity="center"
>
</WebView>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="26dp"
android:layout_marginLeft="13dp"
android:layout_marginRight="13dp"
android:layout_marginBottom="12dp"
android:gravity="right"
android:orientation="horizontal">
<TextView
android:id="#+id/txMore"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:fontFamily="#font/adobearabicbold"
android:text="مشاهده همه..."
android:textSize="12sp"
/>
<TextView
android:id="#+id/txYHinCityDetail"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="3dp"
android:fontFamily="#font/adobearabicbold"
android:text="هر آنچه درمورد قم باید بدانید"
android:textSize="24sp" />
</LinearLayout>
<android.support.v7.widget.RecyclerView
android:id="#+id/rvListYH"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<android.support.v7.widget.RecyclerView
android:id="#+id/rvListBazar"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<ProgressBar
android:id="#+id/progressBar66"
style="#android:style/Widget.Holo.ProgressBar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_above="#+id/rv_listcity"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:indeterminate="true"
android:visibility="gone" />
</LinearLayout>
</android.support.v4.widget.NestedScrollView>
</LinearLayout>
How can i do it work?
Thank you
Removing the following line parent tag in file city_detail_act.xml should fix it
android:paddingBottom="65dp"
And add these to your include tag
android:layout_width="match_parent"
android:layout_height="match_parent"
Also, consider using Bottom Nav layout for UI like this.
First remove this:
android:paddingBottom="65dp"
Then your include should be like this:
<include
android:id="#+id/content"
layout="#layout/city_detail_act"
android:layout_width="match_parent"
android:layout_height="0dp"
app:layout_constraintBottom_toTopOf="#id/tolbar_storyButton"
app:layout_constraintTop_toTopOf="parent" />

How do I overlap the Cardview on Image view?

My run time view is not matching with my design view.
my targeted is design .
but when I run on an android device. I got this
How do I overlap the Cardview on Image view?
Does it possible to accomplish. at first, I use FrameLayout then use Relative Layout Now I am out of my option.
Here is my design Code
<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout 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:fitsSystemWindows="true"
android:background="#color/grey_10"
android:clipChildren="false"
tools:context="com.kurtihouse.nirzonpop.detailspage.view.ProductDetailsActivity">
<android.support.design.widget.AppBarLayout
android:id="#+id/app_bar_layout"
android:layout_width="match_parent"
android:layout_height="256dp"
android:fitsSystemWindows="true"
android:theme="#style/ThemeOverlay.AppCompat.Dark.ActionBar">
<android.support.design.widget.CollapsingToolbarLayout
android:id="#+id/collapsing_toolbar"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
app:contentScrim="?attr/colorPrimary"
app:expandedTitleTextAppearance="#style/TextAppearance.AppCompat.Title"
app:layout_scrollFlags="scroll"
app:titleEnabled="false">
<ImageView
android:id="#+id/ivProductImage"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
android:scaleType="fitXY"
android:src="#drawable/image_8"
app:layout_collapseMode="pin" />
<!--<android.support.v7.widget.RecyclerView
android:id="#+id/rvProductImage"
android:layout_width="match_parent"
android:layout_height="#dimen/product_image_height"
android:layout_marginEnd="1dp"
android:contentDescription="#string/image_description"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.4"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:srcCompat="#mipmap/ic_launcher" />-->
<View
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#color/overlay_dark_40" />
<FrameLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<android.support.v7.widget.Toolbar
android:id="#+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
app:contentInsetStartWithNavigation="0dp"
app:popupTheme="#style/ThemeOverlay.AppCompat.Light" />
</FrameLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:gravity="center"
android:orientation="vertical">
<ImageView
android:layout_width="80dp"
android:layout_height="80dp"
android:tint="#android:color/white"
app:srcCompat="#drawable/img_wizard_1" />
<!-- <View
android:layout_width="#dimen/spacing_middle"
android:layout_height="0dp" />
<TextView
android:id="#+id/textView9"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Nature Park"
android:textAppearance="#style/Base.TextAppearance.AppCompat.Title"
android:textColor="#android:color/white" />-->
</LinearLayout>
</android.support.design.widget.CollapsingToolbarLayout>
</android.support.design.widget.AppBarLayout>
<android.support.v4.widget.NestedScrollView
android:id="#+id/nested_content"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="-50dp"
android:clipToPadding="false"
android:scrollbars="vertical"
android:scrollingCache="true"
app:layout_behavior="#string/appbar_scrolling_view_behavior">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<android.support.v7.widget.CardView
android:id="#+id/cardView"
style="#style/CardViewTheme"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_anchorGravity=""
app:layout_constraintTop_toBottomOf="#+id/rvProductImage">
<android.support.constraint.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingTop="10dp"
android:paddingBottom="10dp">
<ImageView
android:id="#+id/imageView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:layout_marginEnd="8dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:srcCompat="#drawable/ic_share_gray" />
<ImageView
android:id="#+id/ivFavorite"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:layout_marginEnd="8dp"
app:layout_constraintEnd_toStartOf="#+id/imageView2"
app:layout_constraintTop_toTopOf="parent"
app:srcCompat="#drawable/ic_favorite_off" />
<LinearLayout
android:id="#+id/llDirectContract"
android:layout_width="wrap_content"
android:layout_height="36dp"
android:layout_marginStart="16dp"
android:layout_marginTop="16dp"
android:background="#color/colorBgSuccess"
android:orientation="horizontal"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/tvProductCode">
<ImageView
android:id="#+id/ivCall111"
android:layout_width="#dimen/iv_call_width"
android:layout_height="#dimen/iv_call_height"
android:paddingTop="5dp"
app:srcCompat="#drawable/ic_phone" />
<TextView
android:id="#+id/tvDirectContractNot"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="#dimen/padding_10"
android:text="#string/direct_buy"
android:textColor="#color/colorWhite"
android:textStyle="bold"
app:layout_constraintVertical_bias="0.0" />
</LinearLayout>
<TextView
android:id="#+id/tvPrice"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
android:text=""
android:textColor="#color/colorBlack"
android:textSize="24sp"
android:textStyle="bold"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="#+id/imageView2" />
<TextView
android:id="#+id/tvProductName"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
android:layout_marginEnd="16dp"
android:text=""
android:textColor="#color/colorBlack"
android:textSize="18sp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/tvPrice" />
<TextView
android:id="#+id/tvProductCode"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
android:layout_marginTop="8dp"
android:text="swewewe"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/tvProductName" />
<TextView
android:id="#+id/tvAvailability"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="32dp"
android:background="#drawable/border_toast_success"
android:paddingStart="10dp"
android:paddingTop="3dp"
android:paddingEnd="10dp"
android:paddingBottom="3dp"
android:text="TextView"
android:textColor="#color/colorWhite"
android:visibility="visible"
app:layout_constraintBottom_toBottomOf="#+id/llDirectContract"
app:layout_constraintStart_toEndOf="#+id/llDirectContract"
app:layout_constraintTop_toTopOf="#+id/llDirectContract" />
</android.support.constraint.ConstraintLayout>
</android.support.v7.widget.CardView>
<View
android:layout_width="match_parent"
android:layout_height="#dimen/spacing_large" />
<android.support.v7.widget.CardView
android:id="#+id/sizeCardView"
style="#style/CardViewTheme"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/cardView">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:paddingBottom="10dp">
<TextView
android:id="#+id/tvSize"
style="#style/Text.SizeSection"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
android:layout_marginTop="16dp"
android:text="#string/lbl_size" />
<TextView
android:id="#+id/tv_sizeList"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
android:layout_marginTop="16dp"
android:text="dlkfjldsfjkldsjf" />
</LinearLayout>
</android.support.v7.widget.CardView>
<View
android:layout_width="match_parent"
android:layout_height="#dimen/spacing_large" />
<android.support.v7.widget.CardView
android:id="#+id/detailsCardView"
style="#style/CardViewTheme"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
android:paddingBottom="150dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/sizeCardView">
<android.support.constraint.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:id="#+id/descriptionLabel"
style="#style/Text.Description"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:layout_marginTop="8dp"
android:text="Description"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<TextView
android:id="#+id/tvDescription"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:layout_marginTop="16dp"
android:layout_marginEnd="8dp"
android:text="deesadefdsfdasfdsaf"
android:textSize="13sp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/descriptionLabel" />
</android.support.constraint.ConstraintLayout>
</android.support.v7.widget.CardView>
<View
android:layout_width="match_parent"
android:layout_height="#dimen/spacing_large" />
<Button
android:id="#+id/btnAddCart"
android:layout_width="#dimen/btn_add_cart_width"
android:layout_height="40dp"
android:layout_marginStart="8dp"
android:layout_marginEnd="8dp"
android:layout_marginBottom="8dp"
android:background="#drawable/round_button"
android:drawableStart="#drawable/ic_shopping_cart_white"
android:paddingStart="16dp"
android:text="#string/add_to_cart_label"
android:textAllCaps="false"
android:textColor="#color/colorWhite"
android:textSize="22sp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent" />
</LinearLayout>
</android.support.v4.widget.NestedScrollView>
</android.support.design.widget.CoordinatorLayout>
This is happening because your appbarLayout have some elevation above the card view ! So use :-
app:elevation="0dp"
to your appBarLayout

Categories

Resources