I Have Two Fragment class for my project, On my first FragmentA, I have added a FrameLayout to the FragmentA xml file,named as filter_pop_up_frame_lyt_container. so on a button click from from FragmentA, Im adding a new FragmentB to the framelayout of FragmentA. so my intention was to see the framelayout height to be match parent. When my recyclerView items in FragmentA is loaded, the height of the Frame Layout taking only the height of the FragmentB . How can we make the framelayout matchparent.
Tried with this solution :FrameLayout height not matching parent , but not working for me.
sampleCode for my FragmentA xml File:
<?xml version="1.0" encoding="utf-8"?>
<androidx.drawerlayout.widget.DrawerLayout 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/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#color/tastry_btn_txt"
tools:openDrawer="start">
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="match_parent">
<com.agrawalsuneet.dotsloader.loaders.CircularDotsLoader
android:id="#+id/circle_dot_loader"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:elevation="100dp"
android:foregroundGravity="center"
android:visibility="visible"
app:loader_bigCircleRadius="25dp"
app:loader_circleRadius="5dp"
app:loader_defaultColor="#color/blue_dark"
app:loader_firstShadowColor="#color/lit_grey6"
app:loader_secondShadowColor="#color/lit_grey4"
app:loader_selectedColor="#color/lit_grey3"
app:loader_showRunningShadow="true" />
</RelativeLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<!-- The ActionBar displayed at the top -->
<androidx.appcompat.widget.Toolbar xmlns:app="http://schemas.android.com/tools"
xmlns:local="http://schemas.android.com/apk/res-auto"
android:id="#+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="#color/palate_survey_bg"
app:ignore="NamespaceTypo"
local:popupTheme="#style/ThemeOverlay.AppCompat.Light"
local:theme="#style/ThemeOverlay.AppCompat.Dark.ActionBar">
<androidx.appcompat.widget.SearchView
android:id="#+id/Advance_search"
android:layout_width="match_parent"
android:layout_height="40dp"
android:layout_marginEnd="50dp"
android:background="#drawable/filter_search_bar_bg_lyt"
app:iconifiedByDefault="false"
app:queryHint="Search">
</androidx.appcompat.widget.SearchView>
<View
android:id="#+id/filter_loc_divider"
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_margin="20dp"
android:layout_marginTop="40dp"
android:background="#99a3bc" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"></LinearLayout>
</androidx.appcompat.widget.Toolbar>
<LinearLayout
android:id="#+id/search_container"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="#+id/toolbar"
android:background="#66100202"
android:clickable="true"
android:orientation="vertical"
android:translationZ="15dp"
android:visibility="gone">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="8dp"
android:fontFamily="sans-serif-medium"
android:text="Popular Searches"
android:textColor="#color/white"
android:textSize="22dp"
android:textStyle="normal">
</TextView>
<androidx.recyclerview.widget.RecyclerView
android:id="#+id/recycler_advance_search"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="#+id/toolbar"
android:orientation="vertical">
<androidx.core.widget.NestedScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#color/tastry_btn_txt"
android:fillViewport="true">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<LinearLayout
android:id="#+id/filter_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="15dp"
android:gravity="center_vertical"
android:orientation="horizontal">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:src="#drawable/filter">
</ImageView>
<TextView
android:id="#+id/filter_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="10dp"
android:fontFamily="sans-serif-medium"
android:text="Filter By"
android:textColor="#color/white"
android:textSize="22sp"
android:textStyle="normal" />
</LinearLayout>
<LinearLayout
android:id="#+id/filter_container_lyt"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="#+id/filter_layout"
android:layout_alignParentTop="true"
android:layout_marginTop="2dp"
android:background="#495471"
android:gravity="center_vertical"
android:orientation="vertical">
<androidx.recyclerview.widget.RecyclerView
android:id="#+id/recycler_view_filter_category"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:tabTextAppearance="#android:style/TextAppearance.Widget.TabWidget" />
</LinearLayout>
<RelativeLayout
android:id="#+id/wine_complete_lyt"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="#+id/filter_layout"
android:layout_marginStart="3dp"
android:orientation="vertical">
<androidx.recyclerview.widget.RecyclerView
android:id="#+id/recycler_view_red_wine_category"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="10dp" />
</RelativeLayout>
<FrameLayout
android:id="#+id/filter_pop_up_frame_lyt_container"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="#+id/filter_layout"
android:background="#color/orange"
android:elevation="50dp"
android:translationZ="30dp" />
</RelativeLayout>
</androidx.core.widget.NestedScrollView>
</LinearLayout>
</RelativeLayout>
<com.google.android.material.navigation.NavigationView
android:id="#+id/nav_view"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="start"
android:background="#color/palate_survey_bg"
android:fitsSystemWindows="true"
app:headerLayout="#layout/header"
app:itemIconSize="20dp"
app:itemIconTint="#color/white"
app:itemTextColor="#color/white"
app:menu="#menu/drawermenu" />
</androidx.drawerlayout.widget.DrawerLayout>
sampleCode for FragmentB layout:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="#+id/linear_layout_root_price_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#66FF0000"
android:orientation="vertical">
<!-- android:background="#drawable/filter_bg_round_corner"-->
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#drawable/filter_bg_round_corner"
android:orientation="vertical">
<LinearLayout
android:id="#+id/progress_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="15dp"
android:orientation="vertical">
<com.google.android.material.slider.RangeSlider
android:id="#+id/filter_price_ranger_Slider"
style="#style/Theme.TastrySampleApp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:progressDrawable="#drawable/progress_layout_bg"
android:stepSize="1"
android:theme="#style/Theme.TastrySampleApp"
android:valueFrom="0.0"
android:valueTo="100.0"
app:labelBehavior="gone"
app:thumbColor="#01b0c3"
app:tickVisible="false"
app:values="#array/initial_slider_values" />
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:id="#+id/onStartTrackingTouch"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="9dp"
android:ellipsize="end"
android:maxLines="1"
android:text="$0"
android:textColor="#color/black"
android:textSize="16sp">
</TextView>
<TextView
android:id="#+id/onStopTrackingTouch"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:ellipsize="end"
android:maxLines="1"
android:text="$100+"
android:textColor="#color/black"
android:textSize="16sp">
</TextView>
</RelativeLayout>
</LinearLayout>
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_margin="10dp"
android:layout_marginTop="20dp"
android:background="#99a3bc">
</View>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginTop="10dp"
android:gravity="right"
android:orientation="horizontal"
android:padding="14dp">
<TextView
android:id="#+id/filter_price_wine_count"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ellipsize="end"
android:gravity="center"
android:maxLines="1"
android:text="1234"
android:textColor="#color/black"
android:textSize="20sp"
android:textStyle="bold"
android:visibility="gone">
</TextView>
<TextView
android:id="#+id/filter_price_wine_txt"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:layout_weight="0"
android:ellipsize="end"
android:maxLines="1"
android:text="Wines"
android:textColor="#color/black"
android:textSize="20sp"
android:textStyle="bold"
android:visibility="gone">
</TextView>
<View
android:layout_width="0dp"
android:layout_height="10dp"
android:layout_gravity="center"
android:layout_weight="1" />
<LinearLayout
android:id="#+id/filter_price_root_clear_lyt"
android:layout_width="110dp"
android:layout_height="35dp"
android:layout_gravity="center"
android:layout_marginLeft="50dp"
android:layout_toLeftOf="#+id/filter_price_Apply"
android:background="#drawable/filter_clear_bg"
android:gravity="center"
android:visibility="gone">
<ImageView
android:id="#+id/close_filter_price"
android:layout_width="wrap_content"
android:layout_height="20dp"
android:layout_gravity="center"
android:layout_marginTop="2dp"
android:src="#drawable/close_white">
</ImageView>
<TextView
android:id="#+id/clear_price_filter"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="6dp"
android:layout_marginTop="3dp"
android:layout_toRightOf="#id/close_filter_price"
android:text="Clear All"
android:textColor="#f2faff"
android:textStyle="bold">
</TextView>
<TextView
android:id="#+id/price_clear_count"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="4dp"
android:layout_marginTop="3dp"
android:layout_toRightOf="#id/clear_price_filter"
android:textColor="#f2faff"
android:textStyle="bold">
</TextView>
</LinearLayout>
<com.google.android.material.button.MaterialButton
android:id="#+id/filter_price_Apply"
android:layout_width="wrap_content"
android:layout_height="35dp"
android:layout_alignParentRight="true"
android:layout_marginLeft="10dp"
android:background="#drawable/filter_apply_bg"
android:gravity="center"
android:text="Apply"
android:textAllCaps="false"
android:textColor="#f2faff"
android:textSize="12sp"
android:visibility="gone">
</com.google.android.material.button.MaterialButton>
</LinearLayout>
</LinearLayout>
</LinearLayout>
When I removed the scrollview from the layout , the height of the frame layout was set to match parent. Worked perfectly.
Related
I have created a recycler view containing a list of items , for example options like Home, contacts profile with the help of Adapter in my FragmentA class. so currently on clicking each of the items in recycler view, I'm opening a fragment above the Fragment A. so once the fragment is opened, I have to show a blur background below the opened Fragment, so that the items in FragmentA can be slightly visible and once the user clicks the blur view , they have to close the opened fragment also. How can we blur the view and close the Fragment by clicking on the blurview??
sample code for fragmentA layout, where I'm adding the newly opened fragment into the filter_pop_up_frame_lyt which shows above the Main Fragment A
<?xml version="1.0" encoding="utf-8"?>
<androidx.drawerlayout.widget.DrawerLayout 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/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
tools:openDrawer="start">
<LinearLayout
android:id="#+id/dot_layout"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/drawer_layout"
android:layout_centerInParent="true"
android:elevation="50dp"
android:gravity="center">
<androidx.core.widget.NestedScrollView
android:id="#+id/scrollView_lyt"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#color/tastry_btn_txt"
android:isScrollContainer="false"
android:visibility="visible">
<RelativeLayout
android:id="#+id/root_lyt_click"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<include
android:id="#+id/toolbar"
layout="#layout/toolbar" />
<LinearLayout
android:id="#+id/filter_container_lyt"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/toolbar"
android:layout_marginTop="2dp"
android:background="#495471"
android:gravity="center_vertical"
android:orientation="vertical">
<LinearLayout
android:id="#+id/filter_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/toolbar"
android:layout_margin="15dp"
android:layout_marginTop="10dp"
android:gravity="center_vertical"
android:orientation="horizontal">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:src="#drawable/filter">
</ImageView>
<TextView
android:id="#+id/filter_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:fontFamily="sans-serif-medium"
android:text="Filter By"
android:textColor="#color/white"
android:textSize="22dp"
android:textStyle="normal" />
</LinearLayout>
<androidx.coordinatorlayout.widget.CoordinatorLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
app:tabTextAppearance="#android:style/TextAppearance.Widget.TabWidget"
android:layout_marginLeft="3dp">
<androidx.recyclerview.widget.RecyclerView
android:id="#+id/recycler_view_filter_category"
android:layout_width="wrap_content"
app:tabTextAppearance="#android:style/TextAppearance.Widget.TabWidget"
android:layout_height="wrap_content" />
</androidx.coordinatorlayout.widget.CoordinatorLayout>
</LinearLayout>
<FrameLayout
android:id="#+id/filter_pop_up_frame_lyt"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#id/filter_container_lyt"
android:elevation="5dp">
</FrameLayout>
<com.google.android.material.navigation.NavigationView
android:id="#+id/nav_view"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="start"
android:background="#color/palate_survey_bg"
android:fitsSystemWindows="true"
app:headerLayout="#layout/header"
app:itemIconSize="20dp"
app:itemIconTint="#color/white"
app:itemTextColor="#color/white"
app:menu="#menu/drawermenu" />
</androidx.drawerlayout.widget.DrawerLayout>
SampleCode for the Fragment to be opened Above the MainFragment:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="#+id/linear_layout_root_price_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<!-- android:background="#drawable/filter_bg_round_corner"-->
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#drawable/filter_bg_round_corner"
android:orientation="vertical">
<LinearLayout
android:id="#+id/progress_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="15dp"
android:orientation="vertical">
<com.google.android.material.slider.RangeSlider
android:id="#+id/filter_price_ranger_Slider"
style="#style/Theme.TastrySampleApp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:progressDrawable="#drawable/progress_layout_bg"
android:stepSize="1"
android:theme="#style/Theme.TastrySampleApp"
android:valueFrom="0.0"
android:valueTo="100.0"
app:labelBehavior="gone"
app:thumbColor="#01b0c3"
app:tickVisible="false"
app:values="#array/initial_slider_values" />
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:id="#+id/onStartTrackingTouch"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="9dp"
android:ellipsize="end"
android:maxLines="1"
android:text="$0"
android:textColor="#color/black"
android:textSize="16sp">
</TextView>
<TextView
android:id="#+id/onStopTrackingTouch"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:ellipsize="end"
android:maxLines="1"
android:text="$100+"
android:textColor="#color/black"
android:textSize="16sp">
</TextView>
</RelativeLayout>
</LinearLayout>
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_margin="10dp"
android:layout_marginTop="20dp"
android:background="#99a3bc">
</View>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginTop="10dp"
android:gravity="right"
android:orientation="horizontal"
android:padding="14dp">
<TextView
android:id="#+id/filter_price_wine_count"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ellipsize="end"
android:gravity="center"
android:maxLines="1"
android:text="1234"
android:textColor="#color/black"
android:textSize="20sp"
android:textStyle="bold"
android:visibility="gone">
</TextView>
<TextView
android:id="#+id/filter_price_wine_txt"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:layout_weight="0"
android:ellipsize="end"
android:maxLines="1"
android:text="Wines"
android:textColor="#color/black"
android:textSize="20sp"
android:textStyle="bold"
android:visibility="gone">
</TextView>
<View
android:layout_width="0dp"
android:layout_height="10dp"
android:layout_gravity="center"
android:layout_weight="1" />
<LinearLayout
android:id="#+id/filter_price_root_clear_lyt"
android:layout_width="110dp"
android:layout_height="35dp"
android:layout_gravity="center"
android:layout_marginLeft="50dp"
android:layout_toLeftOf="#+id/filter_price_Apply"
android:background="#drawable/filter_clear_bg"
android:gravity="center"
android:visibility="gone">
<ImageView
android:id="#+id/close_filter_price"
android:layout_width="wrap_content"
android:layout_height="20dp"
android:layout_gravity="center"
android:layout_marginTop="2dp"
android:src="#drawable/close_white">
</ImageView>
<TextView
android:id="#+id/clear_price_filter"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="6dp"
android:layout_marginTop="3dp"
android:layout_toRightOf="#id/close_filter_price"
android:text="Clear All"
android:textStyle="bold"
android:textColor="#f2faff">
</TextView>
<TextView
android:id="#+id/price_clear_count"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="4dp"
android:layout_marginTop="3dp"
android:layout_toRightOf="#id/clear_price_filter"
android:textStyle="bold"
android:textColor="#f2faff">
</TextView>
</LinearLayout>
<com.google.android.material.button.MaterialButton
android:id="#+id/filter_price_Apply"
android:layout_width="wrap_content"
android:layout_height="35dp"
android:layout_alignParentRight="true"
android:layout_marginLeft="10dp"
android:background="#drawable/filter_apply_bg"
android:gravity="center"
android:text="Apply"
android:textAllCaps="false"
android:textColor="#f2faff"
android:textSize="12sp"
android:visibility="gone">
</com.google.android.material.button.MaterialButton>
</LinearLayout>
</LinearLayout>
</LinearLayout>
I have been trying to use RelativeLayout in ScrollView to positioning two LinearLayouts, one to top and one to center. I've used layout_alignParentTop and layout_centerVertical. To prevent overlapping I've tried to use layout_below on second LinearLayout but it breaks layout_centerVertical and the second LinearLayout goes to top. How to do it? Thanks.
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport="true"
xmlns:app="http://schemas.android.com/apk/res-auto"
tools:context=".activities.StartFragment">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<LinearLayout
android:id="#+id/trial_button"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="20dp"
android:layout_marginRight="20dp"
android:layout_marginTop="25dp"
android:layout_alignParentTop="true"
android:background="#drawable/trial_border"
android:foreground="?android:attr/selectableItemBackground"
android:clickable="true"
android:orientation="horizontal">
<ImageView
android:layout_width="wrap_content"
android:layout_height="30dp"
android:layout_gravity="top"
android:layout_marginRight="10dp"
android:layout_marginTop="3dp"
android:layout_marginLeft="10dp"
android:src="#drawable/ic_access_time_black_24dp" />
<LinearLayout
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:layout_marginBottom="5dp"
android:layout_marginTop="5dp"
android:orientation="vertical">
<TextView
android:id="#+id/trial_text"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="left|center"
android:text="#string/trial_exp"
android:textColor="#color/darkGrey"
android:textSize="15sp" />
<TextView
android:id="#+id/trial_more"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="right|center"
android:text="#string/trial_exp_more"
android:textColor="#color/darkGreen"
android:layout_marginRight="10dp"
android:textSize="13sp" />
</LinearLayout>
</LinearLayout>
<LinearLayout
android:id="#+id/main_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#id/trial_button"
android:layout_centerVertical="true"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="top"
android:gravity="center"
android:orientation="vertical">
<ImageView
android:id="#+id/VImage"
android:layout_width="wrap_content"
android:layout_height="200sp"
android:src="#drawable/image_global" />
<TextView
android:id="#+id/VText"
android:layout_width="match_parent"
android:layout_height="40dp"
android:gravity="center"
android:text="#string/protection_disabled"
android:textColor="#color/darkRed"
android:textSize="18sp"
android:textStyle="bold" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="top"
android:gravity="center"
android:orientation="vertical">
<com.google.android.material.button.MaterialButton
android:id="#+id/start_vpn_button"
style="#style/Widget.AppCompat.Button.Borderless.Colored"
android:layout_width="141dp"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:text="#string/protect_me"
android:textColor="#color/white"
android:textStyle="bold"
app:backgroundTint="#color/green" />
<com.google.android.material.button.MaterialButton
android:id="#+id/stop_vpn_button"
style="#style/Widget.AppCompat.Button.Borderless.Colored"
android:layout_width="141dp"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:text="#string/unprotect_me"
android:textColor="#color/white"
android:textStyle="bold"
android:visibility="gone"
app:backgroundTint="#color/red" />
</LinearLayout>
<LinearLayout
android:id="#+id/r_button"
android:layout_width="match_parent"
android:layout_height="45dp"
android:layout_marginLeft="20dp"
android:layout_marginTop="50sp"
android:layout_marginRight="20dp"
android:background="#drawable/single_border"
android:clickable="true"
android:foreground="?android:attr/selectableItemBackground"
android:orientation="horizontal">
<ImageView
android:id="#+id/r_image"
android:layout_width="wrap_content"
android:layout_height="30dp"
android:layout_gravity="center"
android:src="#drawable/image_r_50" />
<TextView
android:id="#+id/r_text"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="left|center"
android:text="#string/r_to"
android:textColor="#color/darkGrey"
android:textSize="15sp" />
</LinearLayout>
</LinearLayout>
</RelativeLayout>
</ScrollView>
In my activity I am using Tablayout bellow 300dp from the top is set. in Tablayout I have 3 fragments, the problem is it's showing the fragments but my layout is not scrolling up. I tried Scrollview and NesterScrollview, but none of them worked. please see my xml code below
<?xml version="1.0" encoding="utf-8"?>
<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="wrap_content"
android:orientation="vertical"
xmlns:app="http://schemas.android.com/apk/res-auto">
<android.support.v7.widget.Toolbar
android:id="#+id/toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<android.support.v4.widget.NestedScrollView
android:id="#+id/scrollView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport="true"
app:layout_behavior="#string/appbar_scrolling_view_behavior">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<FrameLayout
android:layout_width="match_parent"
android:layout_height="260dp"
android:background="#fff">
<!-- Cover Image -->
<ImageView
android:id="#+id/bgimage"
android:layout_width="match_parent"
android:layout_height="180dp"
android:scaleType="fitXY"
android:src="#drawable/profilebg" />
<!-- Round image -->
<ImageView
android:id="#+id/shareicon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="40dp"
android:tint="#color/black"
android:layout_gravity="bottom"
android:padding="5dp"
android:background="#drawable/imageborder"
android:src="#drawable/share"/>
<android.support.v7.widget.CardView
android:layout_width="140dp"
android:layout_height="140dp"
android:elevation="12dp"
android:id="#+id/view2"
app:cardCornerRadius="100dp"
android:layout_centerHorizontal="true"
android:innerRadius="0dp"
android:shape="ring"
android:layout_gravity="center"
android:layout_marginTop="60dp"
android:thicknessRatio="1.9">
<ImageView
android:id="#+id/profilepic"
android:layout_width="130dp"
android:layout_height="130dp"
android:layout_gravity="center"/>
</android.support.v7.widget.CardView>
<ImageView
android:id="#+id/editic"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="right|bottom"
android:tint="#color/black"
android:layout_marginRight="40dp"
android:background="#drawable/imageborder"
android:padding="6dp"
android:src="#drawable/ic_pencil"/>
</FrameLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:background="#fff">
<zesteve.com.myapplication.font.RobotoTextView
android:id="#+id/usertitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Tom Cruise"
android:textSize="22dp"
android:textColor="#color/black"
android:layout_gravity="center"/>
<zesteve.com.myapplication.font.RobotoTextView
android:id="#+id/userlocation"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Syracuse, New York"
android:layout_gravity="center"
android:textColor="#color/black"
android:textSize="14dp"/>
</LinearLayout>
<View
android:layout_width="match_parent"
android:layout_height="0.1dp"
android:background="#color/material_purple_500"
android:layout_marginTop="25dp"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:layout_weight="1"
android:gravity="center"
android:layout_marginTop="5dp">
<zesteve.com.myapplication.font.RobotoTextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="256"
android:textColor="#color/black"
android:textStyle="bold"
android:textSize="16dp" />
<zesteve.com.myapplication.font.RobotoTextView
android:layout_width="wrap_content"
android:layout_height="0dp"
android:layout_weight="1"
android:text="LIKES"
android:textSize="12sp"/>
</LinearLayout>
<View
android:layout_width="0.1dp"
android:layout_height="50dp"
android:background="#color/material_purple_500"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:layout_weight="1"
android:gravity="center"
android:layout_marginTop="5dp"
>
<zesteve.com.myapplication.font.RobotoTextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="2,080"
android:textColor="#color/black"
android:textStyle="bold"
android:textSize="16dp" />
<zesteve.com.myapplication.font.RobotoTextView
android:layout_width="wrap_content"
android:layout_height="0dp"
android:layout_weight="1"
android:text="FOLLOWERS"
android:textSize="12sp"/>
</LinearLayout>
<View
android:layout_width="0.1dp"
android:layout_height="50dp"
android:background="#color/material_purple_500"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:layout_weight="1"
android:gravity="center"
android:layout_marginTop="5dp"
android:layout_marginBottom="5dp">
<zesteve.com.myapplication.font.RobotoTextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="144"
android:textColor="#color/black"
android:textStyle="bold"
android:textSize="16dp" />
<zesteve.com.myapplication.font.RobotoTextView
android:layout_width="wrap_content"
android:layout_height="0dp"
android:layout_weight="1"
android:text="FOLLOWING"
android:textSize="12sp"/>
</LinearLayout>
</LinearLayout>
<View
android:layout_width="match_parent"
android:layout_height="0.1dp"
android:background="#color/material_purple_500" />
<android.support.design.widget.TabLayout
android:id="#+id/tabs"
android:layout_width="match_parent"
android:layout_height="40dp"
app:tabGravity="fill"
app:tabMode="fixed"
style="#style/NavigationTab"
android:background="?attr/colorPrimary"/>
<android.support.v4.view.ViewPager
android:id="#+id/ptab_viewpager"
android:layout_width="match_parent"
android:layout_height="wrap_content"
/>
</LinearLayout>
</android.support.v4.widget.NestedScrollView>
</RelativeLayout>
I also tried below
<?xml version="1.0" encoding="utf-8"?>
<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="wrap_content"
android:orientation="vertical"
xmlns:app="http://schemas.android.com/apk/res-auto">
<android.support.v7.widget.Toolbar
android:id="#+id/toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<ScrollView
android:id="#+id/scrollView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport="true"
>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<FrameLayout
android:layout_width="match_parent"
android:layout_height="260dp"
android:background="#fff">
<!-- Cover Image -->
<ImageView
android:id="#+id/bgimage"
android:layout_width="match_parent"
android:layout_height="180dp"
android:scaleType="fitXY"
android:src="#drawable/profilebg" />
<!-- Round image -->
<ImageView
android:id="#+id/shareicon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="40dp"
android:tint="#color/black"
android:layout_gravity="bottom"
android:padding="5dp"
android:background="#drawable/imageborder"
android:src="#drawable/share"/>
<android.support.v7.widget.CardView
android:layout_width="140dp"
android:layout_height="140dp"
android:elevation="12dp"
android:id="#+id/view2"
app:cardCornerRadius="100dp"
android:layout_centerHorizontal="true"
android:innerRadius="0dp"
android:shape="ring"
android:layout_gravity="center"
android:layout_marginTop="60dp"
android:thicknessRatio="1.9">
<ImageView
android:id="#+id/profilepic"
android:layout_width="130dp"
android:layout_height="130dp"
android:layout_gravity="center"/>
</android.support.v7.widget.CardView>
<ImageView
android:id="#+id/editic"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="right|bottom"
android:tint="#color/black"
android:layout_marginRight="40dp"
android:background="#drawable/imageborder"
android:padding="6dp"
android:src="#drawable/ic_pencil"/>
</FrameLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:background="#fff">
<zesteve.com.myapplication.font.RobotoTextView
android:id="#+id/usertitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Tom Cruise"
android:textSize="22dp"
android:textColor="#color/black"
android:layout_gravity="center"/>
<zesteve.com.myapplication.font.RobotoTextView
android:id="#+id/userlocation"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Syracuse, New York"
android:layout_gravity="center"
android:textColor="#color/black"
android:textSize="14dp"/>
</LinearLayout>
<View
android:layout_width="match_parent"
android:layout_height="0.1dp"
android:background="#color/material_purple_500"
android:layout_marginTop="25dp"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:layout_weight="1"
android:gravity="center"
android:layout_marginTop="5dp">
<zesteve.com.myapplication.font.RobotoTextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="256"
android:textColor="#color/black"
android:textStyle="bold"
android:textSize="16dp" />
<zesteve.com.myapplication.font.RobotoTextView
android:layout_width="wrap_content"
android:layout_height="0dp"
android:layout_weight="1"
android:text="LIKES"
android:textSize="12sp"/>
</LinearLayout>
<View
android:layout_width="0.1dp"
android:layout_height="50dp"
android:background="#color/material_purple_500"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:layout_weight="1"
android:gravity="center"
android:layout_marginTop="5dp"
>
<zesteve.com.myapplication.font.RobotoTextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="2,080"
android:textColor="#color/black"
android:textStyle="bold"
android:textSize="16dp" />
<zesteve.com.myapplication.font.RobotoTextView
android:layout_width="wrap_content"
android:layout_height="0dp"
android:layout_weight="1"
android:text="FOLLOWERS"
android:textSize="12sp"/>
</LinearLayout>
<View
android:layout_width="0.1dp"
android:layout_height="50dp"
android:background="#color/material_purple_500"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:layout_weight="1"
android:gravity="center"
android:layout_marginTop="5dp"
android:layout_marginBottom="5dp">
<zesteve.com.myapplication.font.RobotoTextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="144"
android:textColor="#color/black"
android:textStyle="bold"
android:textSize="16dp" />
<zesteve.com.myapplication.font.RobotoTextView
android:layout_width="wrap_content"
android:layout_height="0dp"
android:layout_weight="1"
android:text="FOLLOWING"
android:textSize="12sp"/>
</LinearLayout>
</LinearLayout>
<View
android:layout_width="match_parent"
android:layout_height="0.1dp"
android:background="#color/material_purple_500" />
<include layout="#layout/profile_tab_layout"/>
</LinearLayout>
</ScrollView>
</RelativeLayout>
and included layout is
<?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="wrap_content">
<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.TabLayout
android:id="#+id/tabs"
android:layout_width="match_parent"
android:layout_height="40dp"
app:tabGravity="fill"
app:tabMode="fixed"
style="#style/NavigationTab"
android:background="?attr/colorPrimary"/>
</android.support.design.widget.AppBarLayout>
<android.support.v4.view.ViewPager
android:id="#+id/ptab_viewpager"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="#string/appbar_scrolling_view_behavior" />
</android.support.design.widget.CoordinatorLayout>
IMAGE
this result is second approach using include. its showing tab's and fragments also, but if we scroll top rest of the content will show.
I have a problem with my app whenever it is on a larger screen. i am using fragment and whenever i run the app on a smaller screen (5.2 inches) the toolbar shows and i can use the nav bar. but when i run it on a bigger screen (5.5 inches) it suddenly takes the whole screen with the toolbar nowhere to be found.
Smaller Screen:
Bigger Screen
Layout file for app_bar_drawer:
<?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:context="com.example.jjcadiz.omas.Drawer">
<android.support.design.widget.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="#style/AppTheme.AppBarOverlay">
<android.support.v7.widget.Toolbar
android:id="#+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="?attr/colorPrimary"
app:popupTheme="#style/AppTheme.PopupOverlay" />
</android.support.design.widget.AppBarLayout>
<include layout="#layout/content_drawer" />
<android.support.design.widget.FloatingActionButton
android:id="#+id/fab"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom|end"
android:layout_margin="#dimen/fab_margin"
app:srcCompat="#android:drawable/ic_dialog_email" />
<android.support.v4.widget.DrawerLayout
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/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<android.support.v7.widget.Toolbar
android:id="#+id/toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:minHeight="?attr/actionBarSize"
android:background="?attr/colorPrimary"
app:theme="#style/MyMaterialTheme"
>
<TextView
android:layout_width="wrap_content"
android:layout_height="50dp"
android:text="Purchase Order"
/>
</android.support.v7.widget.Toolbar>
<FrameLayout
android:id="#+id/frame_container"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="#+id/toolbar">
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent"
android:orientation="vertical"
android:layout_height="match_parent"
tools:context=".MainActivity"
android:weightSum="1"
android:background="#color/BG_beige">
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:paddingBottom="5dp">
<TextView
android:id="#+id/textView3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Purchase Order"
android:textColor="#color/omas_blue"
android:layout_gravity="center"
android:textSize="25sp"
android:gravity="center"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="41dp"
android:orientation="horizontal">
<TextView
android:id="#+id/textView5"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Supplier Name:" />
<Spinner
android:id="#+id/SupplierSpinner"
android:layout_width="222dp"
android:layout_height="wrap_content" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:orientation="horizontal">
<TextView
android:id="#+id/textView6"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Date of Transac" />
<TextView
android:id="#+id/textView4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1.61"
android:text="TextView" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="55dp"
android:orientation="horizontal"
android:paddingTop="10dp">
<TextView
android:id="#+id/textView9"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Item name"
android:gravity="center"
android:layout_gravity="center"/>
<TextView
android:id="#+id/textView8"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Quantity"
android:gravity="center"
android:layout_gravity="center"/>
<TextView
android:id="#+id/textView7"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Unit Price"
android:gravity="center"
android:layout_gravity="center"/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="266dp"
android:orientation="horizontal">
<EditText
android:id="#+id/edtName"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:ems="10"
android:inputType="textPersonName"
android:hint="Unit Name"/>
<EditText
android:id="#+id/edtQuantity"
android:layout_width="117dp"
android:layout_height="wrap_content"
android:ems="10"
android:inputType="number"
android:hint="Quantity" />
<EditText
android:id="#+id/edtPrice"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:ems="10"
android:inputType="numberDecimal"
android:hint="Price"/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="39dp"
android:orientation="horizontal">
<TextView
android:id="#+id/textView11"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1.99"
android:text="Total" />
<TextView
android:id="#+id/tvTotal"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="PPP" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:orientation="vertical">
<TextView
android:id="#+id/textView13"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Prepared By:" />
<TextView
android:id="#+id/tvName"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:orientation="horizontal">
<Button
android:id="#+id/btnConfirm"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Confirm" />
<Button
android:id="#+id/btnReset"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Reset" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
</ScrollView>
</LinearLayout>
</FrameLayout>
</RelativeLayout>
Use this xml in your layout it will work.
I have three EditText in my layout. When i click on any of them then it shrinks my layout and the second layout is barely visible. I want that when i click on second layout ("Dear Parents"), keyboard should overlap the last edittext (teachers name) and when i click on last edittext then it should appear above keyboard.
Here are the screenshots
and here is the code
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:card_view="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#color/actionbar_title_color"
android:orientation="vertical">
<include
android:id="#+id/include"
layout="#layout/toolbar" />
<android.support.v7.widget.CardView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="25dp"
android:layout_marginLeft="25dp"
android:layout_marginRight="25dp"
android:layout_marginTop="25dp"
card_view:cardElevation="10sp"
card_view:cardUseCompatPadding="true">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#ffffff"
android:orientation="horizontal">
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_marginTop="10dp"
android:layout_weight="1"
android:background="#drawable/filebinder" />
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="14"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:layout_marginRight="10dp"
android:orientation="horizontal">
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="6"
android:orientation="vertical">
<TextView
android:id="#+id/dateDiary"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:fontFamily="sans-serif"
android:text="30 July"
android:textColor="#03a9f4"
android:textSize="20sp" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_marginBottom="10dp"
android:background="#03a9f4" />
</LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="#drawable/diarybookmark" />
</LinearLayout>
<ScrollView
android:id="#+id/scrollView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="10dp">
<EditText
android:id="#+id/diaryHeading"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_margin="10dp"
android:ems="5"
android:fontFamily="sans-serif"
android:hint="Diary Heading"
android:inputType="textPersonName"
android:textAlignment="center"
android:textColor="#000000"
android:textSize="18sp" />
</ScrollView>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<EditText
android:id="#+id/diaryTeacherName"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_gravity="center"
android:fontFamily="sans-serif"
android:hint="Teacher\'s Name..."
android:textSize="16sp" />
<at.markushi.ui.CircleButton
android:id="#+id/addDiaryEntry"
android:layout_width="74dip"
android:layout_height="74dip"
android:layout_gravity="right"
android:src="#drawable/ic_action_tick"
app:cb_color="#color/actionbar_title_color"
app:cb_pressedRingWidth="8dip"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true" />
<EditText
android:id="#+id/diaryContent"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_above="#+id/addDiaryEntry"
android:layout_alignLeft="#+id/scrollView"
android:layout_alignStart="#+id/scrollView"
android:layout_alignTop="#+id/scrollView"
android:fontFamily="sans-serif"
android:gravity="top"
android:hint="Enter Diary Note...\n\n\n\n"
android:text="Dear Parents,"
android:textSize="14sp" />
</RelativeLayout>
</LinearLayout>
</LinearLayout>
</android.support.v7.widget.CardView>
</LinearLayout>
and here is my manifest
<activity
android:name=".DiaryEntry.DiaryEntryTeacherActivity"
android:label="DiaryEntry"
android:windowSoftInputMode="adjustResize"
android:theme="#style/AppTheme.NoActionBar"></activity>
You need to use ScrollView as;
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:card_view="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#color/actionbar_title_color"
android:orientation="vertical">
<include
android:id="#+id/include"
layout="#layout/toolbar" />
<ScrollView
android:id="#+id/scroll_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport="true">
<android.support.v7.widget.CardView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="25dp"
android:layout_marginLeft="25dp"
android:layout_marginRight="25dp"
android:layout_marginTop="25dp"
card_view:cardElevation="10sp"
card_view:cardUseCompatPadding="true">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#ffffff"
android:orientation="horizontal">
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_marginTop="10dp"
android:layout_weight="1"
android:background="#drawable/filebinder" />
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="14"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:layout_marginRight="10dp"
android:orientation="horizontal">
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="6"
android:orientation="vertical">
<TextView
android:id="#+id/dateDiary"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:fontFamily="sans-serif"
android:text="30 July"
android:textColor="#03a9f4"
android:textSize="20sp" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_marginBottom="10dp"
android:background="#03a9f4" />
</LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="#drawable/diarybookmark" />
</LinearLayout>
<ScrollView
android:id="#+id/scrollView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="10dp">
<EditText
android:id="#+id/diaryHeading"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_margin="10dp"
android:ems="5"
android:fontFamily="sans-serif"
android:hint="Diary Heading"
android:inputType="textPersonName"
android:textAlignment="center"
android:textColor="#000000"
android:textSize="18sp" />
</ScrollView>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<EditText
android:id="#+id/diaryTeacherName"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_gravity="center"
android:fontFamily="sans-serif"
android:hint="Teacher\'s Name..."
android:textSize="16sp" />
<at.markushi.ui.CircleButton
android:id="#+id/addDiaryEntry"
android:layout_width="74dip"
android:layout_height="74dip"
android:layout_gravity="right"
android:src="#drawable/ic_action_tick"
app:cb_color="#color/actionbar_title_color"
app:cb_pressedRingWidth="8dip"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true" />
<EditText
android:id="#+id/diaryContent"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_above="#+id/addDiaryEntry"
android:layout_alignLeft="#+id/scrollView"
android:layout_alignStart="#+id/scrollView"
android:layout_alignTop="#+id/scrollView"
android:fontFamily="sans-serif"
android:gravity="top"
android:hint="Enter Diary Note...\n\n\n\n"
android:text="Dear Parents,"
android:textSize="14sp" />
</RelativeLayout>
</LinearLayout>
</LinearLayout>
</android.support.v7.widget.CardView>
</ScrollView>
</LinearLayout>