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);
Related
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);
}
});
I want to design a layout like this:
I have use from AppBarLayout and I tried this code:
<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">
<!--tools:layout_marginTop="-200dp">-->
<android.support.design.widget.AppBarLayout
android:id="#+id/appbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
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="#android:color/transparent"
app:expandedTitleMarginEnd="64dp"
app:expandedTitleMarginStart="48dp"
app:layout_scrollFlags="scroll|exitUntilCollapsed"
app:titleEnabled="false">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#drawable/banner_detail_course_img"
android:visibility="visible">
<!--<ImageView-->
<!--android:layout_width="match_parent"-->
<!--android:layout_height="match_parent"-->
<!--android:src="#drawable/banner_detail_course_img"-->
<!--android:scaleType="centerCrop"/>-->
<TextView
android:id="#+id/header_txtTitleCourse"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_marginTop="60dp"
android:layout_marginEnd="10dp"
android:text="#{courseItem.title}"
android:textColor="#fff"
android:textSize="30sp" />
<TextView
android:id="#+id/header_txtShortDescCourse"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/header_txtTitleCourse"
android:layout_alignParentEnd="true"
android:layout_marginTop="10dp"
android:layout_marginEnd="10dp"
android:text="#{courseItem.shortDescription}"
android:textColor="#fff"
android:textSize="15sp" />
<TextView
android:id="#+id/header_txtRate"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/header_txtShortDescCourse"
android:layout_alignParentEnd="true"
android:layout_marginTop="10dp"
android:layout_marginEnd="10dp"
android:background="#drawable/rounded_background_textview"
android:drawableEnd="#drawable/ic_star"
android:drawablePadding="5dp"
android:text="#{String.valueOf(courseItem.ratingAvg)}"
android:textColor="#fff"
android:textSize="15sp" />
<TextView
android:id="#+id/header_txtEnrolled"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/header_txtShortDescCourse"
android:layout_marginTop="10dp"
android:layout_marginEnd="10dp"
android:layout_toStartOf="#+id/header_txtRate"
android:background="#drawable/rounded_background_textview"
android:drawableEnd="#drawable/ic_user_enrolled"
android:drawablePadding="5dp"
android:text="#{courseItem.numberEnroll.concat(#string/space).concat(#string/number_enroll)}"
android:textColor="#fff"
android:textSize="15sp" />
<TextView
android:id="#+id/header_txtDuration"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/header_txtRate"
android:layout_alignParentEnd="true"
android:layout_marginTop="10dp"
android:layout_marginEnd="10dp"
android:background="#drawable/rounded_background_textview"
android:drawableEnd="#drawable/ic_play_icon"
android:drawablePadding="5dp"
android:text="#{courseItem.duration.concat(#string/space).concat(#string/label_hour)}"
android:textColor="#fff"
android:textSize="15sp" />
<TextView
android:id="#+id/header_txtInstructor"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/header_txtRate"
android:layout_marginTop="10dp"
android:layout_marginEnd="10dp"
android:layout_toStartOf="#+id/header_txtDuration"
android:background="#drawable/rounded_background_textview"
android:text="#{#string/txt_label_instructor.concat(#string/space).concat(courseItem.instructorName)}"
android:textColor="#fff"
android:textSize="15sp" />
<TextView
android:id="#+id/header_txtUpdate"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/header_txtInstructor"
android:layout_alignParentEnd="true"
android:layout_marginTop="10dp"
android:layout_marginEnd="10dp"
android:background="#drawable/rounded_background_textview"
android:text="#{#string/last_update_course.concat(#string/space).concat(courseItem.updateDate)}"
android:textColor="#FFF"
android:textSize="15sp" />
<FrameLayout
android:id="#+id/flPreview"
android:layout_width="260dp"
android:layout_height="220dp"
android:layout_below="#+id/header_txtUpdate"
android:layout_centerHorizontal="true"
android:layout_marginTop="20dp">
<ImageView
android:id="#+id/imgPreview"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scaleType="centerCrop"
android:src="#drawable/preview_video_view"
app:imageUrl="#{courseItem.imagePreview}" />
<ImageView
android:id="#+id/imgPlayButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:src="#drawable/ic_play_video" />
<TextView
android:id="#+id/header_txtPreview"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal|bottom"
android:layout_marginBottom="20dp"
android:text="#string/txt_show_preview_video"
android:textColor="#FFF"
android:textSize="20sp"
android:textStyle="bold" />
</FrameLayout>
</RelativeLayout>
<android.support.v7.widget.Toolbar
android:id="#+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
app:layout_collapseMode="pin"
app:popupTheme="#style/ThemeOverlay.AppCompat.Light">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
android:id="#+id/imgBack"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_marginTop="10dp"
android:layout_marginEnd="20dp"
android:src="#drawable/ic_back_press" />
<ImageView
android:id="#+id/imgFavorit"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="10dp"
android:layout_marginTop="10dp"
android:layout_toEndOf="#+id/imgShare"
android:src="#drawable/ic_favorite_toolbar" />
<ImageView
android:id="#+id/imgShare"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentStart="true"
android:layout_marginTop="10dp"
android:layout_marginEnd="20dp"
android:src="#drawable/ic_share" />
</RelativeLayout>
</android.support.v7.widget.Toolbar>
</android.support.design.widget.CollapsingToolbarLayout>
</android.support.design.widget.AppBarLayout>
<android.support.v4.widget.NestedScrollView 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:layout_gravity="fill_vertical"
app:layout_behavior="#string/appbar_scrolling_view_behavior">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:id="#+id/txtCurrentPrice"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_marginTop="30dp"
android:layout_marginEnd="20dp"
android:text="#{courseItem.price}"
android:textSize="30sp"
android:textStyle="bold" />
</RelativeLayout>
</android.support.v4.widget.NestedScrollView>
</android.support.design.widget.CoordinatorLayout>
And my output layout is :
I want to be half of FrameLayout preview with id flPreview in the AppBarLayout.
please check this code. this may help you
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="500dp">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#color/colorPrimary"
android:layout_marginBottom="100dp"> <!--just set the half of the size of the frame layout-->
<!--your content here-->
</RelativeLayout>
<FrameLayout
android:layout_width="200dp"
android:layout_height="200dp"
android:layout_centerHorizontal="true"
android:layout_alignParentBottom="true"
android:background="#color/colorPrimaryDark">
<!--your frame layout content here-->
</FrameLayout>
</RelativeLayout>
</RelativeLayout>
try this on your 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">
<!--tools:layout_marginTop="-200dp">-->
<android.support.design.widget.AppBarLayout
android:id="#+id/appbar"
android:layout_width="match_parent"
android:layout_height="500dp"
android:background="#fff"
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="#android:color/transparent"
app:expandedTitleMarginEnd="64dp"
app:expandedTitleMarginStart="48dp"
app:layout_scrollFlags="scroll|exitUntilCollapsed"
app:titleEnabled="false">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:visibility="visible">
<!--<ImageView-->
<!--android:layout_width="match_parent"-->
<!--android:layout_height="match_parent"-->
<!--android:src="#drawable/banner_detail_course_img"-->
<!--android:scaleType="centerCrop"/>-->
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#color/colorPrimaryDark"
android:layout_marginBottom="110dp">
<!-- android:background="#drawable/banner_detail_course_img"-->
<TextView
android:id="#+id/header_txtTitleCourse"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_marginTop="60dp"
android:layout_marginEnd="10dp"
android:text="courseItem.title"
android:textColor="#fff"
android:textSize="30sp" />
<TextView
android:id="#+id/header_txtShortDescCourse"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/header_txtTitleCourse"
android:layout_alignParentEnd="true"
android:layout_marginTop="10dp"
android:layout_marginEnd="10dp"
android:text="courseItem.shortDescription"
android:textColor="#fff"
android:textSize="15sp" />
<TextView
android:id="#+id/header_txtRate"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/header_txtShortDescCourse"
android:layout_alignParentEnd="true"
android:layout_marginTop="10dp"
android:layout_marginEnd="10dp"
android:drawablePadding="5dp"
android:text="courseItem ratingAvg"
android:textColor="#fff"
android:textSize="15sp" />
<!--android:drawableEnd="#drawable/ic_star"
android:background="#drawable/rounded_background_textview"-->
<TextView
android:id="#+id/header_txtEnrolled"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/header_txtShortDescCourse"
android:layout_marginTop="10dp"
android:layout_marginEnd="10dp"
android:layout_toStartOf="#+id/header_txtRate"
android:drawablePadding="5dp"
android:text="#{courseItem.numberEnroll.concat(#string/space).concat(#string/number_enroll)}"
android:textColor="#fff"
android:textSize="15sp" />
<!--android:background="#drawable/rounded_background_textview"
android:drawableEnd="#drawable/ic_user_enrolled"-->
<TextView
android:id="#+id/header_txtDuration"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/header_txtRate"
android:layout_alignParentEnd="true"
android:layout_marginTop="10dp"
android:layout_marginEnd="10dp"
android:drawablePadding="5dp"
android:text="#{courseItem.duration.concat(#string/space).concat(#string/label_hour)}"
android:textColor="#fff"
android:textSize="15sp" />
<!-- android:background="#drawable/rounded_background_textview"
android:drawableEnd="#drawable/ic_play_icon"-->
<TextView
android:id="#+id/header_txtInstructor"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/header_txtRate"
android:layout_marginTop="10dp"
android:layout_marginEnd="10dp"
android:layout_toStartOf="#+id/header_txtDuration"
android:text="#{#string/txt_label_instructor.concat(#string/space).concat(courseItem.instructorName)}"
android:textColor="#fff"
android:textSize="15sp" />
<!-- android:background="#drawable/rounded_background_textview"-->
<TextView
android:id="#+id/header_txtUpdate"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/header_txtInstructor"
android:layout_alignParentEnd="true"
android:layout_marginTop="10dp"
android:layout_marginEnd="10dp"
android:text="#{#string/last_update_course.concat(#string/space).concat(courseItem.updateDate)}"
android:textColor="#FFF"
android:textSize="15sp" />
<!-- android:background="#drawable/rounded_background_textview"-->
</RelativeLayout>
<FrameLayout
android:id="#+id/flPreview"
android:layout_width="260dp"
android:layout_height="220dp"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:background="#color/colorPrimary"
android:layout_marginTop="20dp">
<ImageView
android:id="#+id/imgPreview"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scaleType="centerCrop"
/>
<!-- android:src="#drawable/preview_video_view"-->
<ImageView
android:id="#+id/imgPlayButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:background="#color/colorPrimary"
/>
<!-- android:src="#drawable/ic_play_video"-->
<TextView
android:id="#+id/header_txtPreview"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal|bottom"
android:layout_marginBottom="20dp"
android:text="txt_show_preview_video"
android:textColor="#FFF"
android:textSize="20sp"
android:textStyle="bold" />
</FrameLayout>
</RelativeLayout>
<android.support.v7.widget.Toolbar
android:id="#+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
app:layout_collapseMode="pin"
app:popupTheme="#style/ThemeOverlay.AppCompat.Light">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
android:id="#+id/imgBack"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_marginTop="10dp"
android:layout_marginEnd="20dp"
/>
<!-- android:src="#drawable/ic_back_press"-->
<ImageView
android:id="#+id/imgFavorit"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="10dp"
android:layout_marginTop="10dp"
android:layout_toEndOf="#+id/imgShare"
/>
<!--android:src="#drawable/ic_favorite_toolbar"-->
<ImageView
android:id="#+id/imgShare"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentStart="true"
android:layout_marginTop="10dp"
android:layout_marginEnd="20dp"
/>
<!-- android:src="#drawable/ic_share"-->
</RelativeLayout>
</android.support.v7.widget.Toolbar>
</android.support.design.widget.CollapsingToolbarLayout>
</android.support.design.widget.AppBarLayout>
<android.support.v4.widget.NestedScrollView 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:layout_gravity="fill_vertical"
app:layout_behavior="#string/appbar_scrolling_view_behavior">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:id="#+id/txtCurrentPrice"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_marginTop="30dp"
android:layout_marginEnd="20dp"
android:text="#{courseItem.price}"
android:textSize="30sp"
android:textStyle="bold" />
</RelativeLayout>
</android.support.v4.widget.NestedScrollView>
</android.support.design.widget.CoordinatorLayout>
just change the values and images according to your project
I have a code here which contains of a coordinator layout. Inside that coordinator layout, there is an appbar layout and a nested scrollview beneath it.I want the appbar layout(map) to be still even when nestedscroll view scrolls.I have images to explain my thoughts. Initial stage, stage two. Notice that the map remains still while only nested scroll view scrolls and finally, nested scroll view overlaps entire map fragment.
<?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:id="#+id/main_content"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
android:background="#android:color/white">
<android.support.design.widget.AppBarLayout
android:id="#+id/MyAppbar"
android:layout_width="match_parent"
android:layout_height="550dp"
android:fitsSystemWindows="true"
>
<android.support.design.widget.CollapsingToolbarLayout
android:id="#+id/collapse_toolbar"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_scrollFlags="scroll|exitUntilCollapsed"
android:fitsSystemWindows="true">
<android.support.v7.widget.Toolbar
android:id="#+id/my_toolbar"
android:layout_width="match_parent"
android:layout_height="60dp"
app:layout_collapseMode="pin"
>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
android:id="#+id/close_button"
android:layout_width="35dp"
android:layout_height="35dp"
android:layout_centerVertical="true"
android:src="#drawable/close_black"
/>
<TextView
android:id="#+id/shipping_to_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="SHIPPING TO"
android:textColor="#color/black"
android:textStyle="bold"
android:textSize="10dp"
android:layout_centerHorizontal="true"
android:layout_marginTop="10dp"/>
<TextView
android:id="#+id/shipping_to"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="926 Rosenbaum Mill"
android:textColor="#color/black"
android:layout_below="#id/shipping_to_title"
android:textSize="16dp"
android:layout_centerHorizontal="true"/>
</RelativeLayout>
</android.support.v7.widget.Toolbar>
<fragment
android:id="#+id/map"
android:name="com.google.android.gms.maps.SupportMapFragment"
android:layout_width="match_parent"
android:layout_height="550dp"
tools:context=".MapFragment"
android:layout_below="#id/my_toolbar"
app:layout_collapseMode="pin"
>
<RelativeLayout
android:id="#+id/outermost_wrapper"
android:layout_width="match_parent"
android:layout_height="match_parent"
>
<RelativeLayout
android:id="#+id/bottom_wrapper"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_marginBottom="20dp"
android:layout_marginStart="20dp"
android:layout_marginEnd="20dp"
android:layout_centerHorizontal="true"
>
<include
android:id="#+id/getDirections"
layout="#layout/track_shipment_activity_get_directions_fragment_layout"
android:visibility="gone"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:layout_centerHorizontal="true"
/>
<include
android:id="#+id/received"
layout="#layout/track_shipment_activity_received_fragment_layout"
android:visibility="gone"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:layout_centerHorizontal="true"
/>
<include
android:id="#+id/enrouteToDestination"
layout="#layout/track_shipment_activity_button_fragment_layout"
android:visibility="gone"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:layout_centerHorizontal="true"
/>
<include
android:id="#+id/trackOrder"
layout="#layout/track_shipment_track_order_button_fragment_layout"
android:visibility="gone"
/>
<RelativeLayout
android:id="#+id/trackOrderBelow"
android:layout_width="300dp"
android:layout_height="40dp"
android:layout_below="#id/trackOrder"
android:layout_marginBottom="20dp"
android:background="#FBFBFB"
android:layout_centerHorizontal="true"
android:visibility="gone">
<TextView
android:id="#+id/tracking_code_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/tracking_code"
android:textSize="14dp"
android:textColor="#color/black"
android:layout_marginStart="10dp"
android:layout_centerVertical="true"/>
<TextView
android:id="#+id/tracking_code"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/tracking_code_numbers"
android:layout_toRightOf="#id/tracking_code_title"
android:textSize="14dp"
android:textColor="#color/black"
android:layout_marginStart="10dp"
android:layout_centerVertical="true" />
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/double_boxes"
android:layout_alignParentEnd="true"
android:layout_marginEnd="10dp"
android:layout_centerVertical="true"/>
</RelativeLayout>
</RelativeLayout>
</RelativeLayout>
</fragment>
</android.support.design.widget.CollapsingToolbarLayout>
</android.support.design.widget.AppBarLayout>
<android.support.v4.widget.NestedScrollView 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:layout_gravity="fill_vertical"
app:layout_behavior="#string/appbar_scrolling_view_behavior">
<RelativeLayout xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="#+id/abc"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="#id/MyAppbar"
android:layout_marginTop="30dp"
tools:context=".MapFragment">
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<ScrollView
android:id="#+id/scroll_view"
android:layout_width="match_parent"
android:layout_height="match_parent">
<RelativeLayout
android:id="#+id/relative_layout_wrapper"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#color/activity_background">
<RelativeLayout
android:id="#+id/relative_layout_inner"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#android:color/white"
android:focusedByDefault="true">
<ImageView
android:id="#+id/order_icon"
android:layout_width="30dp"
android:layout_height="30dp"
android:layout_marginStart="15dp"
android:layout_marginTop="25dp"
android:contentDescription="#string/app_name"
android:src="#drawable/orders" />
<TextView
android:id="#+id/order_date_title"
android:layout_width="wrap_content"
android:layout_height="30dp"
android:layout_marginTop="25dp"
android:layout_toEndOf="#id/order_icon"
android:gravity="center"
android:paddingLeft="5dp"
android:text="#string/order_date2"
android:textColor="#android:color/black" />
<TextView
android:id="#+id/order_date"
android:layout_width="wrap_content"
android:layout_height="30dp"
android:layout_alignParentEnd="true"
android:layout_marginEnd="15dp"
android:layout_marginTop="25dp"
android:layout_toEndOf="#id/order_date_title"
android:gravity="center|end"
android:paddingLeft="90dp"
android:text="#string/date5"
android:textColor="#android:color/black"
android:textStyle="bold" />
<ImageView
android:id="#+id/placeBy_icon"
android:layout_width="30dp"
android:layout_height="30dp"
android:layout_below="#id/order_icon"
android:layout_marginStart="15dp"
android:layout_marginTop="20dp"
android:contentDescription="#string/app_name"
android:src="#drawable/person" />
<TextView
android:id="#+id/placed_by_title"
android:layout_width="wrap_content"
android:layout_height="30dp"
android:layout_below="#id/order_date_title"
android:layout_marginTop="20dp"
android:layout_toEndOf="#id/placeBy_icon"
android:gravity="center"
android:paddingLeft="5dp"
android:text="#string/placed_by"
android:textColor="#android:color/black" />
<TextView
android:id="#+id/placed_by"
android:layout_width="wrap_content"
android:layout_height="30dp"
android:layout_alignParentEnd="true"
android:layout_below="#id/order_date_title"
android:layout_marginEnd="15dp"
android:layout_marginTop="20dp"
android:layout_toEndOf="#id/placed_by_title"
android:gravity="center|end"
android:paddingLeft="100dp"
android:text="#string/user_name"
android:textColor="#android:color/black"
android:textStyle="bold" />
<ImageView
android:id="#+id/delivery_icon"
android:layout_width="30dp"
android:layout_height="30dp"
android:layout_below="#id/placeBy_icon"
android:layout_marginStart="15dp"
android:layout_marginTop="20dp"
android:contentDescription="#string/app_name"
android:src="#drawable/delivery" />
<TextView
android:id="#+id/delivery_method_title"
android:layout_width="wrap_content"
android:layout_height="30dp"
android:layout_below="#id/placed_by_title"
android:layout_marginTop="20dp"
android:layout_toEndOf="#id/delivery_icon"
android:gravity="center"
android:paddingLeft="5dp"
android:text="#string/delivery_method"
android:textColor="#android:color/black" />
<TextView
android:id="#+id/delivery_method"
android:layout_width="wrap_content"
android:layout_height="30dp"
android:layout_alignParentEnd="true"
android:layout_below="#id/placed_by_title"
android:layout_marginEnd="15dp"
android:layout_marginTop="20dp"
android:layout_toEndOf="#id/delivery_method_title"
android:gravity="center|end"
android:text="#string/shipping"
android:textColor="#android:color/black"
android:textStyle="bold" />
<RelativeLayout
android:id="#+id/add_to_calander_button_shipment"
android:layout_width="340dp"
android:layout_height="40dp"
android:layout_below="#+id/delivery_icon"
android:layout_centerHorizontal="true"
android:layout_marginBottom="20dp"
android:layout_marginTop="20dp"
android:background="#drawable/add_to_calander">
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true">
<ImageView
android:id="#+id/addToCalIcon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:contentDescription="#string/app_name"
android:src="#drawable/orders" />
<TextView
android:id="#+id/addToCalText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="5dp"
android:layout_marginTop="2dp"
android:layout_toEndOf="#id/addToCalIcon"
android:text="#string/add_to_calander"
android:textSize="14dp" />
</RelativeLayout>
</RelativeLayout>
</RelativeLayout>
<View
android:id="#+id/threeItems"
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_below="#+id/relative_layout_inner"
android:layout_marginStart="10dp"
android:layout_marginTop="30dp"
android:background="#color/activity_background" />
<TextView
android:id="#+id/threeItemstext"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/relative_layout_inner"
android:layout_marginStart="10dp"
android:layout_marginTop="30dp"
android:text="#string/number_of_items"
android:textColor="#color/black"
android:textSize="16dp"
android:textStyle="bold" />
<android.support.v4.widget.NestedScrollView
android:id="#+id/nestedRecyclerView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="#id/threeItems">
<android.support.v7.widget.RecyclerView
android:id="#+id/simpleRecyclerView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#android:color/white"
android:nestedScrollingEnabled="false"
app:layout_behavior="#string/app_bar_scrolling_view_behavior">
</android.support.v7.widget.RecyclerView>
</android.support.v4.widget.NestedScrollView>
<include
android:id="#+id/delivery_details"
layout="#layout/track_shipment_delivery_details_fragment"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#id/nestedRecyclerView"
android:layout_marginBottom="5dp"
android:layout_marginEnd="10dp"
android:layout_marginStart="10dp"
android:layout_marginTop="10dp" />
<include
android:id="#+id/order"
layout="#layout/track_shipment_order_total_fragment"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#id/delivery_details"
android:layout_marginBottom="5dp"
android:layout_marginEnd="10dp"
android:layout_marginStart="10dp"
android:layout_marginTop="5dp" />
<include
android:id="#+id/need_help"
layout="#layout/track_shipment_need_help_fragment"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#id/order"
android:layout_marginBottom="10dp"
android:layout_marginEnd="10dp"
android:layout_marginStart="10dp"
android:layout_marginTop="5dp" />
</RelativeLayout>
</ScrollView>
</RelativeLayout>
</RelativeLayout>
</android.support.v4.widget.NestedScrollView>
</android.support.design.widget.CoordinatorLayout>
Try adding
app:behavior_overlapTop="0dp" in your nested scroll view and also add some elevation to the nested scroll view.
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
I have a collapsing toolbar layout, below that a tab layout and below that the corresponding viewpager. I want to implement snapping such that when I collapse the collapsing toolbar layout more than half and leave it, it should snap and collapse completely. How do I do it? Here is my actual 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"
android:id="#+id/main_content"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#231f20"
android:fitsSystemWindows="true">
<android.support.v4.view.ViewPager
android:id="#+id/viewpager"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="?attr/actionBarSize"
app:layout_behavior="#string/appbar_scrolling_view_behavior" />
<android.support.design.widget.TabLayout
android:id="#+id/tabs"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:layout_gravity="bottom"
android:background="#231f20"
app:layout_anchor="#+id/appbar"
app:layout_anchorGravity="bottom"
app:tabGravity="fill"
app:tabMode="fixed" />
<android.support.design.widget.AppBarLayout
android:id="#+id/appbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
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="#FAC80A"
app:expandedTitleMarginBottom="110dp"
app:expandedTitleMarginStart="200dp"
app:layout_scrollFlags="scroll|exitUntilCollapsed">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:fitsSystemWindows="true"
app:layout_collapseMode="parallax">
<ImageView
android:id="#+id/imageView78"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:layout_alignParentStart="true"
android:layout_alignParentLeft="true"
android:background="#drawable/user_profile_bg_img"
android:scaleType="fitXY"
android:src="#drawable/gradient" />
<ImageView
android:id="#+id/imageView82"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:elevation="10dp"
android:src="#drawable/user_profile_shape_profile_pic"
android:layout_centerVertical="true"
android:layout_marginLeft="30dp" />
<ImageView
android:id="#+id/imageView80"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:layout_gravity="center_vertical"
android:elevation="10dp"
android:layout_marginRight="60dp"
android:layout_marginTop="35dp" />
<ImageView
android:id="#+id/imageView81"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:elevation="10dp"
android:layout_gravity="center_vertical"
android:layout_marginRight="20dp"
android:layout_marginTop="35dp" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_marginLeft="30dp"
android:layout_marginTop="300dp"
android:orientation="horizontal">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:orientation="vertical"
android:paddingRight="10dp"
android:elevation="10dp"
android:id="#+id/fans">
<TextView
android:id="#+id/textView7"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#FFFFFF"
android:textSize="16sp" />
<TextView
android:id="#+id/textView8"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:alpha="0.8"
android:text="Fans"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="#FFFFFF" />
</LinearLayout>
<ImageView
android:id="#+id/imageView179"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginRight="10dp"
android:src="#drawable/user_profile_thin_line_separator_profile_metrics" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:orientation="vertical"
android:paddingRight="10dp"
android:elevation="10dp"
android:id="#+id/comments">
<TextView
android:id="#+id/textView9"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#FFFFFF"
android:textSize="16sp" />
<TextView
android:id="#+id/textView12"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:alpha="0.8"
android:text="Comments"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="#FFFFFF" />
</LinearLayout>
<ImageView
android:id="#+id/imageView180"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginRight="10dp"
android:src="#drawable/user_profile_thin_line_separator_profile_metrics" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:orientation="vertical"
android:paddingRight="10dp"
android:elevation="10dp"
android:id="#+id/bookmarks">
<TextView
android:id="#+id/textView13"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#FFFFFF"
android:textSize="16sp" />
<TextView
android:id="#+id/textView111"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:alpha="0.8"
android:text="Bookmarks"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="#FFFFFF" />
</LinearLayout>
<ImageView
android:id="#+id/imageView181"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginRight="10dp"
android:src="#drawable/user_profile_thin_line_separator_profile_metrics" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:orientation="vertical"
android:elevation="10dp"
android:id="#+id/galleries">
<TextView
android:id="#+id/textView112"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#FFFFFF"
android:textSize="16sp" />
<TextView
android:id="#+id/textView113"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:alpha="0.8"
android:text="Galleries"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="#FFFFFF" />
</LinearLayout>
</LinearLayout>
<TextView
android:id="#+id/textView114"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="200dp"
android:layout_marginTop="200dp"
android:textColor="#FFFFFF" />
</RelativeLayout>
<android.support.v7.widget.Toolbar
android:id="#+id/toolbar"
android:elevation="4dp"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
app:layout_collapseMode="pin"
app:popupTheme="#style/ThemeOverlay.AppCompat.Light">
</android.support.v7.widget.Toolbar>
</android.support.design.widget.CollapsingToolbarLayout>
</android.support.design.widget.AppBarLayout>
</android.support.design.widget.CoordinatorLayout>
it latest version of the design library, compile 'com.android.support:design:23.1.0', the snap has been added
app:layout_scrollFlags="scroll|exitUntilCollapsed|snap"
should do it