Scroll View Clickable - android

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);
}
});

Related

fill rest of the space using linearlayout

I have a FoodCardFragment that has a CardView at the bottom. I want the CardView to have a height of at least 120dp and fill the rest of the space (so I set its layout_weight to 1).
The FoodCardFragment is put in the RandomFragment (the first tab of MainAcitivity), and also has its layout_weight set to 1 as I want it to fill the rest of the space.
However, as you can tell from the image I posted below, the yellow CardView I mentioned above doesn't fill the rest of the space. How can I achieve my goal?
In case the links won't work:
Code for FoodCardFragment:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:padding="20dp"
android:background="#android:color/white">
<android.support.v7.widget.CardView
android:id="#+id/food_card"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:elevation="2dp">
<android.support.constraint.ConstraintLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<ImageView
android:id="#+id/food_image"
android:layout_width="320dp"
android:layout_height="320dp"
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" />
<ImageView
android:id="#+id/liked_image"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="4dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:srcCompat="#drawable/ic_undo_like" />
</android.support.constraint.ConstraintLayout>
</android.support.v7.widget.CardView>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_marginTop="10dp">
<TextView
android:id="#+id/food_name"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:textSize="24sp"
android:textStyle="bold"
android:layout_weight="1"
android:maxLines="1"
android:ellipsize="end"
android:layout_marginEnd="4dp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#id/food_card" />
<ImageButton
android:id="#+id/more_button"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:background="#android:color/transparent"
android:src="#drawable/ic_dropdown" />
</LinearLayout>
<FrameLayout
android:id="#+id/tags_frame"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginVertical="10dp" />
<android.support.v7.widget.CardView
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:minHeight="120dp">
<TextView
android:id="#+id/food_note_back"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#drawable/food_note_background"
android:scrollbars="vertical"
android:paddingTop="4dp"
android:paddingBottom="4dp"
android:paddingHorizontal="8dp" />
<TextView
android:id="#+id/food_note_front"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#drawable/food_note_background"
android:scrollbars="vertical"
android:paddingTop="4dp"
android:paddingBottom="4dp"
android:paddingHorizontal="8dp" />
</android.support.v7.widget.CardView>
</LinearLayout>
Code for RandomFragment:
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:background="#color/whiteSmoke">
<android.support.v7.widget.Toolbar
android:id="#+id/toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?android:attr/colorBackgroundFloating"
android:elevation="2dp">
<android.support.constraint.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:id="#+id/title_text_view"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/random"
android:textSize="20sp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<ImageButton
android:id="#+id/filter_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="15dp"
android:background="#android:color/transparent"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toStartOf="#id/menu_button"
app:layout_constraintTop_toTopOf="parent"
app:srcCompat="#drawable/ic_filter" />
<ImageButton
android:id="#+id/menu_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="10dp"
android:background="#android:color/transparent"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:srcCompat="#drawable/ic_menu" />
</android.support.constraint.ConstraintLayout>
</android.support.v7.widget.Toolbar>
<android.support.v7.widget.CardView
android:id="#+id/food_card_view"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_gravity="center"
android:layout_weight="1"
android:layout_marginHorizontal="20dp"
android:layout_marginTop="30dp"
android:background="#android:color/white"
app:cardCornerRadius="4dp"
app:cardElevation="4dp">
<FrameLayout
android:id="#+id/food_card_frame"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</android.support.v7.widget.CardView>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="10dp"
android:padding="10dp">
<ImageButton
android:id="#+id/check_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="#android:color/transparent"
android:padding="8dp"
app:srcCompat="#drawable/ic_check" />
<ImageButton
android:id="#+id/cross_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="#android:color/transparent"
android:padding="8dp"
app:srcCompat="#drawable/ic_cross" />
<ImageButton
android:id="#+id/refresh_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="#android:color/transparent"
android:padding="8dp"
app:srcCompat="#drawable/ic_refresh" />
</LinearLayout>
</LinearLayout>

The height of bottomNaviagtionview become minimal in the some item while navigating

I have a bottomNavigationView in the MainActivity. When I click to second (SearchFragment) and last (AccountFragment) item,the height of bottomNavigationView become small and when again click on same menu item, the height of bottomNavigationView become normal.This happens only when I'm in home item(HomeFragment) and from there I navigate to second or last item.There isn't this problem in the third menu item (MyCourseFragment).
It is screenshot of normal state:
This is layout of MainActivity:
<android.support.design.widget.CoordinatorLayout
android:id="#+id/coordinatorLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<FrameLayout
android:id="#+id/flContent"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="56dp"
app:layout_behavior="#string/appbar_scrolling_view_behavior">
<ProgressBar
android:id="#+id/progressBar"
style="?android:attr/progressBarStyle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:visibility="visible"/>
</FrameLayout>
<android.support.design.widget.BottomNavigationView
android:id="#+id/bottom_nav"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
app:menu="#menu/bottom_nav_menu"
app:itemBackground="#color/colorBackgroundNav"
android:theme="#style/bottomNav"
app:labelVisibilityMode="labeled"
android:layout_gravity="bottom"
/>
</android.support.design.widget.CoordinatorLayout>
It is layout of MyCourseFragment:
<RelativeLayout xmlns:tools="http://schemas.android.com/tools"
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:app="http://schemas.android.com/apk/res-auto"
tools:context=".view.MyCourseFragment">
<android.support.v7.widget.Toolbar
android:id="#+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
app:popupTheme="#style/ThemeOverlay.AppCompat.Light"
app:layout_collapseMode="pin"
android:background="#color/colorPrimary">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="دوره های من"
android:layout_gravity="end"
android:id="#+id/toolbar_title"
android:layout_marginEnd="20dp"
android:textColor="#fff"
android:textStyle="bold"
android:textSize="17sp"/>
</android.support.v7.widget.Toolbar>
<android.support.v7.widget.RecyclerView
android:id="#+id/courseRcy"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/toolbar"
android:layout_marginTop="30dp"
android:visibility="gone"/>
<android.support.v7.widget.RecyclerView
android:id="#+id/categoryRcy"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/toolbar"
android:layout_marginTop="30dp"/>
</RelativeLayout>
It is layout of `SearchFragment`:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".view.SearchFragment">
<android.support.v7.widget.Toolbar
android:id="#+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="#color/colorPrimary"
app:popupTheme="#style/ThemeOverlay.AppCompat.Light"/>
<SearchView
android:id="#+id/searchbox"
android:layout_width="match_parent"
android:layout_height="40dp"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:layout_alignParentRight="true"
android:layout_centerInParent="true"
android:layout_margin="10dp"
android:background="#FFF"></SearchView>
<android.support.v7.widget.RecyclerView
android:id="#+id/CategoryRcy"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/searchbox"
android:layout_marginTop="10dp" />
</RelativeLayout>
It is layout 'AccountFragment':
<ScrollView android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:android="http://schemas.android.com/apk/res/android">
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:app="http://schemas.android.com/apk/res-auto"
tools:context=".view.AccountFragment">
<android.support.v7.widget.Toolbar
android:id="#+id/toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?attr/colorPrimary"
android:fitsSystemWindows="true"
android:minHeight="?attr/actionBarSize"
app:theme="#style/ThemeOverlay.AppCompat.Dark.ActionBar">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="حساب کاربری"
android:layout_gravity="end"
android:id="#+id/toolbar_title"
android:layout_marginEnd="20dp"
android:textColor="#fff"
android:textStyle="bold"
android:textSize="17sp"/>
</android.support.v7.widget.Toolbar>
<android.support.v7.widget.CardView
android:id="#+id/cardViewProfile"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:layout_marginStart="10dp"
android:layout_marginEnd="10dp"
app:cardCornerRadius="15dp"
android:layout_below="#+id/toolbar"
android:visibility="gone">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
android:id="#+id/imgAvatar"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/ic_avatar"
android:layout_centerHorizontal="true"
android:layout_marginTop="20dp"/>
<TextView
android:id="#+id/txtName"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="مریم کاظمی"
android:layout_below="#id/imgAvatar"
android:layout_centerHorizontal="true"
android:layout_marginTop="10dp"
/>
</RelativeLayout>
</android.support.v7.widget.CardView>
<android.support.v7.widget.CardView
android:id="#+id/cardViewInstructor"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/cardViewProfile"
android:layout_marginTop="20dp"
android:layout_marginStart="10dp"
android:layout_marginEnd="10dp"
app:cardCornerRadius="15dp"
android:padding="10dp"
android:visibility="gone">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:id="#+id/txtBeInstructor"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="یک مدرس شو"
android:layout_centerInParent="true"
android:textColor="#color/colorPrimary"
android:textStyle="bold"
android:textSize="20sp"
/>
</RelativeLayout>
</android.support.v7.widget.CardView>
<android.support.v7.widget.CardView
android:id="#+id/cardViewSetting"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/cardViewInstructor"
android:layout_marginTop="20dp"
android:layout_marginStart="10dp"
android:layout_marginEnd="10dp"
app:cardCornerRadius="15dp"
android:visibility="gone">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:id="#+id/txtPreferences"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_marginTop="20dp"
android:layout_marginEnd="10dp"
android:text="تنظیمات"/>
<TextView
android:id="#+id/txtLecturePlayBack"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_marginTop="20dp"
android:layout_marginEnd="10dp"
android:text="پخش دوره"
android:layout_below="#+id/txtPreferences"/>
<TextView
android:id="#+id/txtContinueBackground"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_marginTop="10dp"
android:layout_marginEnd="10dp"
android:text="پخش پیوسته در بک گراند"
android:layout_below="#+id/txtLecturePlayBack"/>
<Switch
android:id="#+id/switchCB"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentStart="true"
android:layout_below="#+id/txtLecturePlayBack"
android:layout_marginTop="10dp"
android:layout_marginStart="20dp"/>
<TextView
android:id="#+id/txtDownloadOption"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_marginTop="20dp"
android:layout_marginEnd="10dp"
android:text="گزینه های دانلود ویدیو"
android:layout_below="#+id/txtContinueBackground"/>
<TextView
android:id="#+id/txtDWiFi"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_marginTop="10dp"
android:layout_marginEnd="10dp"
android:text="دانلود فقط از طریق Wi-Fi"
android:layout_below="#+id/txtDownloadOption"/>
<Switch
android:id="#+id/switchDWifi"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentStart="true"
android:layout_below="#+id/txtDownloadOption"
android:layout_marginTop="10dp"
android:layout_marginStart="20dp"/>
<TextView
android:id="#+id/txtDSD"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_marginTop="20dp"
android:layout_marginEnd="10dp"
android:text="دانلود داخل کارت حافظه"
android:layout_below="#+id/txtDWiFi"/>
<Switch
android:id="#+id/switchDSD"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentStart="true"
android:layout_below="#+id/txtDWiFi"
android:layout_marginTop="20dp"
android:layout_marginStart="20dp"/>
<TextView
android:id="#+id/txtQualityVideo"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_marginTop="20dp"
android:layout_marginEnd="10dp"
android:text="کیفیت دانلود ویدیو"
android:layout_below="#+id/txtDSD"/>
<TextView
android:id="#+id/txtQuality"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/txtQualityVideo"
android:layout_alignParentEnd="true"
android:text="360p"
android:layout_marginTop="5dp"
android:layout_marginEnd="10dp"/>
<TextView
android:id="#+id/txtTitleEditNotf"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_marginTop="20dp"
android:layout_marginEnd="10dp"
android:text="تنظیمات نوتیفیکیشن"
android:layout_below="#+id/txtQuality"/>
<TextView
android:id="#+id/txtEditNotf"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/txtTitleEditNotf"
android:layout_alignParentEnd="true"
android:text="ویرایش تنظیمات نوتیفیکیشن ها"
android:layout_marginTop="10dp"
android:layout_marginEnd="10dp"
android:layout_marginBottom="20dp"/>
</RelativeLayout>
</android.support.v7.widget.CardView>
<android.support.v7.widget.CardView
android:id="#+id/cardViewPolicy"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:layout_marginStart="10dp"
android:layout_marginEnd="10dp"
app:cardCornerRadius="15dp"
android:layout_below="#+id/cardViewSetting"
android:visibility="visible"
android:layout_marginBottom="10dp">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:id="#+id/txtShareApp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="پارس کلاس را به اشتراک بگذار"
android:layout_alignParentEnd="true"
android:layout_marginTop="20dp"
android:layout_marginEnd="10dp"
/>
<TextView
android:id="#+id/txtPrivacy"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="مشاهده سیاست های حریم خصوصی"
android:layout_below="#+id/txtShareApp"
android:layout_alignParentEnd="true"
android:layout_marginTop="20dp"
android:layout_marginEnd="10dp"
/>
<TextView
android:id="#+id/txtTermOfUse"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="مقررات استفاده"
android:layout_below="#+id/txtPrivacy"
android:layout_alignParentEnd="true"
android:layout_marginTop="20dp"
android:layout_marginEnd="10dp"
/>
<TextView
android:id="#+id/txtIntellectual"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="مشاهده سیاست مالکیت معنوی"
android:layout_below="#+id/txtTermOfUse"
android:layout_alignParentEnd="true"
android:layout_marginTop="20dp"
android:layout_marginEnd="10dp"
/>
<TextView
android:id="#+id/txtSign"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="ورود/ثبت نام"
android:layout_below="#+id/txtIntellectual"
android:layout_centerInParent="true"
android:layout_marginTop="10dp"/>
<TextView
android:id="#+id/txtVersion"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="ParsClass v1.1"
android:layout_below="#+id/txtSign"
android:layout_centerInParent="true"
android:layout_marginTop="10dp"
android:paddingBottom="10dp"/>
</RelativeLayout>
</android.support.v7.widget.CardView>
</RelativeLayout>
</ScrollView>
Finally i find the solution.I just needed to add this line of code to onCreateView method of Account fragment.
((AppCompatActivity)getActivity()).setSupportActionBar(toolbar);

NestedScrollView dosent scroll all the way to the end of Fragment

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>

How to align horizontal line in layout exactly to image

So I have this activity What I want to do is to align the separator line and background image. What i do so far is just margin the whole layout with specific height but that is definitely not a solution since on new device they aren't aligned anymore. The whole problem is that the separator line is in layout. To avoid misunderstandings here is the line and image i want to align here. And here is the code
<FrameLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<ImageView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:scaleType="fitStart"
android:src="#drawable/main_background" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<LinearLayout
android:layout_marginTop="110dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginEnd="8dp"
android:layout_marginLeft="8dp"
android:layout_marginRight="8dp"
android:layout_marginStart="8dp"
android:background="#drawable/mainborder"
android:orientation="vertical"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
<TextView
android:id="#+id/user_name"
style="#style/HeaderText"
android:layout_width="match_parent"
android:layout_height="50dp"
android:paddingLeft="15dp"
android:paddingTop="15dp"
android:text="#string/welcome" />
<include layout="#layout/separator_line_smaller_margin" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="15dp"
android:layout_marginRight="15dp">
<include layout="#layout/slider" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="100dp"
android:layout_gravity="bottom"
android:orientation="horizontal"
android:paddingBottom="10dp"
android:paddingLeft="15dp">
<LinearLayout
android:layout_width="203dp"
android:layout_height="match_parent"
android:orientation="vertical">
<TextView
style="#style/Text"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingLeft="4dp"
android:text="#string/profileInfo" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dip"
android:layout_weight="1"
android:gravity="bottom">
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#android:color/transparent"
android:fontFamily="sans-serif-medium"
android:gravity="start"
android:lineSpacingExtra="6sp"
android:onClick="goToProfile"
android:text="#string/myProfile"
android:textAlignment="textStart"
android:textColor="#4ED1AD"
android:textSize="14sp"
android:textStyle="normal" />
</LinearLayout>
</LinearLayout>
<de.hdodenhof.circleimageview.CircleImageView
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="start"
android:src="#drawable/face" />
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
android:layout_marginEnd="8dp"
android:layout_marginLeft="8dp"
android:layout_marginRight="8dp"
android:layout_marginStart="8dp"
android:layout_marginTop="8dp"
android:background="#drawable/mainborder"
android:orientation="vertical"
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.105">
<TextView
style="#style/HeaderText"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingLeft="15dp"
android:paddingTop="15dp"
android:text="#string/comingViews"
android:textSize="25sp" />
<include layout="#layout/separator_line_smaller_margin" />
<LinearLayout
style="#style/DoctorsLayouts"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="10dp">
<de.hdodenhof.circleimageview.CircleImageView
android:layout_width="49dp"
android:layout_height="match_parent"
android:src="#drawable/face" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:orientation="horizontal">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#mipmap/ic_data_range" />
<TextView
style="#style/Text"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center|left"
android:paddingLeft="5dp"
android:text="22.01.2018г. 9:00 часа"
tools:layout_editor_absoluteX="65dp"
tools:layout_editor_absoluteY="261dp" />
</LinearLayout>
<TextView
style="#style/Doctors"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:paddingLeft="3dp"
android:text="Др. Хаус"
android:textSize="15sp" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
<LinearLayout
style="#style/LayoutPadding"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
android:layout_marginEnd="8dp"
android:layout_marginLeft="8dp"
android:layout_marginRight="8dp"
android:layout_marginStart="8dp"
android:orientation="vertical">
<TextView
style="#style/SecondHeaderText"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="15dp"
android:text="#string/HowDoesItWork" />
<TextView
style="#style/Text"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="#string/dummyText" />
</LinearLayout>
<LinearLayout
style="#style/LayoutPadding"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#android:color/transparent"
android:text="#string/Help"
android:textColor="#4ED1AD"
android:textSize="17sp" />
</LinearLayout>
</LinearLayout>
</FrameLayout>

Collapse Header View without Toolbar

I'm trying to collapse my header view in my fragment. I've tried using Collapsing Toolbar layout but it's not working. My toolbar is in my activity and my header and everything else is in a fragment. Any tips on how to achieve this? I'll post the codes of each page
fragment_post.xml
<?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"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#color/white">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<android.support.design.widget.CollapsingToolbarLayout
android:layout_height="match_parent"
android:layout_width="match_parent"
app:layout_scrollFlags="scroll|exitUntilCollapsed">
<LinearLayout
android:id="#+id/mainImageContainer"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#color/purple"
android:minHeight="80dp"
android:orientation="horizontal"
android:weightSum="3"
app:layout_collapseMode="parallax">
<RelativeLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="19dp"
android:layout_weight="0.5">
<TextView
android:id="#+id/numPosts"
android:layout_width="36dp"
android:layout_height="40dp"
android:layout_gravity="center"
android:layout_marginStart="15dp"
android:background="#drawable/ic_comments_bubble"
android:fontFamily="sans-serif-condensed"
android:gravity="center_horizontal"
android:paddingTop="5dp"
android:textColor="#color/purple"
android:textSize="14sp"
android:textStyle="bold" />
</RelativeLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:layout_weight="2.4"
android:orientation="vertical"
android:padding="10dp">
<TextView
android:id="#+id/threadTopic"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="5dp"
android:layout_marginTop="5dp"
android:alpha="0.5"
android:fontFamily="sans-serif-condensed"
android:textColor="#android:color/white"
android:textSize="14sp" />
<TextView
android:id="#+id/threadText"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginBottom="15dp"
android:layout_marginTop="13dp"
android:textColor="#android:color/white"
android:textSize="16sp" />
</LinearLayout>
<ImageButton
android:id="#+id/moreOptions"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:alpha="0.5"
android:background="#drawable/ic_more_vert_white_24dp" />
</LinearLayout>
</android.support.design.widget.CollapsingToolbarLayout>
<android.support.v7.widget.RecyclerView
android:id="#+id/postsRecyclerView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="5dp"
app:layout_behavior="#string/appbar_scrolling_view_behavior"/>
</LinearLayout>
<View
android:id="#+id/scrimColorView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#color/black_semi_transparent"
android:visibility="invisible"/>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom|end"
android:orientation="vertical">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:id="#+id/flipText"
android:layout_width="60dp"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:gravity="center"
android:paddingTop="5dp"
android:paddingBottom="5dp"
android:paddingStart="10dp"
android:paddingEnd="10dp"
android:visibility="invisible"
android:layout_marginEnd="10dp"
android:background="#color/white"
android:text="#string/flipText"
android:textColor="#android:color/black"/>
<android.support.design.widget.FloatingActionButton
android:id="#+id/flipFab"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/ic_flip"
android:visibility="invisible"
app:backgroundTint="#color/mnBlue"
android:layout_marginStart="10dp"
app:elevation="6dp"
app:pressedTranslationZ="12dp" />
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:id="#+id/shareText"
android:layout_width="60dp"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:gravity="center"
android:paddingTop="5dp"
android:paddingBottom="5dp"
android:paddingStart="10dp"
android:paddingEnd="10dp"
android:layout_marginEnd="20dp"
android:visibility="invisible"
android:background="#color/white"
android:text="#string/shareText"
android:textColor="#android:color/black"/>
<android.support.design.widget.FloatingActionButton
android:id="#+id/shareFab"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="16dp"
android:src="#drawable/ic_share_white"
android:visibility="invisible"
app:backgroundTint="#color/mnBlue"
app:elevation="6dp"
app:pressedTranslationZ="12dp" />
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:id="#+id/replyText"
android:layout_width="60dp"
android:layout_height="wrap_content"
android:gravity="center"
android:layout_gravity="center"
android:paddingTop="5dp"
android:paddingBottom="5dp"
android:paddingStart="10dp"
android:paddingEnd="10dp"
android:layout_marginEnd="19dp"
android:layout_marginTop="-46dp"
android:visibility="invisible"
android:background="#color/white"
android:text="#string/replyText"
android:textColor="#android:color/black"/>
<android.support.design.widget.FloatingActionButton
android:id="#+id/replyFab"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="90dp"
android:layout_marginEnd="16dp"
android:layout_marginStart="1dp"
android:src="#drawable/ic_reply"
android:visibility="invisible"
app:backgroundTint="#color/mnBlue"
app:elevation="6dp"
app:pressedTranslationZ="12dp" />
</LinearLayout>
</LinearLayout>
<android.support.design.widget.FloatingActionButton
android:id="#+id/fabMenu"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom|end"
android:layout_margin="16dp"
android:src="#drawable/ic_add"
app:backgroundTint="#color/mnBlue"
app:elevation="6dp"
app:pressedTranslationZ="12dp" />
</android.support.design.widget.CoordinatorLayout>
activity_post_pager.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:orientation="vertical">
<android.support.design.widget.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<android.support.v7.widget.Toolbar
android:id="#+id/toolbarForPosts"
android:layout_width="match_parent"
android:background="#android:color/white"
android:minHeight="?android:attr/actionBarSize"
android:layout_height="wrap_content"
app:contentInsetStart="67dp">
<ImageButton
android:id="#+id/search_button"
android:layout_width="24dp"
android:layout_height="24dp"
android:layout_gravity="end"
android:layout_marginEnd="20dp"
android:background="#drawable/ic_search"
android:src="#android:color/transparent"/>
</android.support.v7.widget.Toolbar>
</android.support.design.widget.AppBarLayout>
<android.support.v4.view.ViewPager
android:id="#+id/postPager"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
</LinearLayout>
Thanks in advance

Categories

Resources