I need to show some text and at the bottom I need two tabs. The current code works only if the text is small, if the text fills the whole screen, then the tabs are not shown when scrolling.
My activity XML is:
<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.NestedScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport="true"
tools:context="dk.zispa.vibetasks.TaskDetailedView">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<RelativeLayout
android:id="#+id/task_view_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:id="#+id/taskTitle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="5dp"
android:layout_marginTop="10dp"
android:clickable="true"
android:focusable="true"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="#color/black"
android:textSize="20sp" />
<TextView
android:id="#+id/taskBreadcrumbs"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#id/taskTitle"
android:layout_marginStart="5dp"
android:layout_marginTop="3dp"
android:clickable="true"
android:focusable="true"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="#color/secondaryText"
android:textSize="14sp" />
<View
android:id="#+id/divider"
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_below="#id/taskBreadcrumbs"
android:layout_marginBottom="10dp"
android:layout_marginTop="10dp"
android:background="#color/divider" />
<TextView
android:id="#+id/taskDescription"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#id/divider"
android:layout_marginStart="5dp"
android:clickable="false"
android:focusable="false"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="#color/secondaryText" />
<LinearLayout
android:id="#+id/hoursInfo"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#id/taskDescription"
android:layout_margin="5dp"
android:orientation="horizontal">
<TextView
android:id="#+id/taskEstimatedHours"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="#color/orange"
android:gravity="center"
android:paddingBottom="3dp"
android:paddingTop="3dp"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="#color/white" />
<TextView
android:id="#+id/taskWorkedHours"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="#color/colorPrimaryLight"
android:gravity="center"
android:paddingBottom="3dp"
android:paddingTop="3dp"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="#color/white" />
</LinearLayout>
</RelativeLayout>
<android.support.v4.view.ViewPager
android:id="#+id/container"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#id/hoursInfo">
<android.support.design.widget.TabLayout
android:id="#+id/book_tab_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:tabGravity="fill">
<android.support.design.widget.TabItem
android:id="#+id/book_description_tab_item"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="TAB1" />
<android.support.design.widget.TabItem
android:id="#+id/book_reviews_tab_item"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="TAB2" />
</android.support.design.widget.TabLayout>
</android.support.v4.view.ViewPager>
</LinearLayout>
</android.support.v4.widget.NestedScrollView>
Do you have any ideas how can I make the tabs visible when you scroll down?
Thank you in advance
You can try to replace the LinearLayout with RelativeLayout. Put the task_view_layout with alignParentTop="true" and the view pager with alignParentBottom="true" and layoutBelow="#+id/task_view_layout"
Related
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>
I have TabLayout with 3 tabs and it works well. Tabs are scrolling inside if content not fitting to screen. Now I want to vertically scroll whole content except toolbar. Currently I'm scrolling inside tablayout, but I need to scroll header linearlayout and tablayout, which starts in middle of screen.
P.S. Tried ScrollView, but then scroll not worked at all (including scrolling tabs inside). Also content in tabs not showing up
Layout:
<?xml version="1.0" encoding="utf-8"?>
<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=".GameInfoActivity">
<LinearLayout
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="?android:attr/actionBarSize"
android:background="#color/colorPrimaryDark"
android:theme="#style/ThemeOverlay.AppCompat.Dark.ActionBar"
app:popupTheme="#style/ThemeOverlay.AppCompat.Light" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="150dp"
android:background="#ffffff">
<ProgressBar
android:id="#+id/progressBar"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:visibility="gone" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:orientation="horizontal"
android:paddingBottom="8dp"
android:paddingTop="8dp">
<TextView
android:id="#+id/team1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:maxWidth="240dp"
android:text="Team 1"
android:textColor="#color/colorBlackBG"
android:textSize="15sp" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text=" - "
android:textColor="#color/colorBlackBG" />
<TextView
android:id="#+id/team2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:maxWidth="240dp"
android:text="Team 2"
android:textColor="#color/colorBlackBG"
android:textSize="15sp" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView
android:id="#+id/gameInfo_league_name"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center_horizontal"
android:text="League Name" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="100dp"
android:orientation="horizontal"
android:weightSum="3">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:gravity="center_horizontal"
android:orientation="vertical">
<ImageView
android:id="#+id/gameInfo_flag1"
android:layout_width="70dp"
android:layout_height="70dp"
android:layout_marginTop="8dp"
android:text="date"
android:textColor="#b71c1c"
android:textSize="14sp"
app:srcCompat="#drawable/game_info_flag_placeholder" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:gravity="center"
android:orientation="vertical">
<TextView
android:id="#+id/score"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="0:0"
android:textColor="#777777"
android:textSize="24sp" />
<TextView
android:id="#+id/date"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:text="date"
android:textColor="#b71c1c"
android:textSize="14sp" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:gravity="center_horizontal"
android:orientation="vertical">
<ImageView
android:id="#+id/gameInfo_flag2"
android:layout_width="70dp"
android:layout_height="70dp"
android:layout_marginTop="8dp"
android:text="date"
android:textColor="#b71c1c"
android:textSize="14sp"
app:srcCompat="#drawable/game_info_flag_placeholder" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
</RelativeLayout>
<android.support.design.widget.TabLayout
android:id="#+id/tabs"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#color/colorPrimaryDark"
app:tabIndicatorColor="#color/colorAccent"
app:tabIndicatorHeight="4dp"
app:tabSelectedTextColor="#android:color/white"
app:tabTextColor="#android:color/white">
<android.support.design.widget.TabItem
android:id="#+id/tabItem"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/match_details" />
<android.support.design.widget.TabItem
android:id="#+id/tabItem2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/head_to_head" />
<android.support.design.widget.TabItem
android:id="#+id/tabItem3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/prediction" />
</android.support.design.widget.TabLayout>
<android.support.v4.view.ViewPager
android:id="#+id/container"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#ffffff"
app:layout_behavior="#string/appbar_scrolling_view_behavior" />
</LinearLayout>
</LinearLayout>
Screenshot:
Please use Coordinate Layout and AppBarLayout. You can check this link for different scrolls.
https://github.com/codepath/android_guides/wiki/Handling-Scrolls-with-CoordinatorLayout
This link shows you exactly what you want to acheive
https://gist.github.com/iPaulPro/1468510f046cb10c51ea
I am Trying to scroll whole layout but I can't, only tablayout scroll and relative layout above the tablayout they can't scroll, how to fix it, I am trying to make like instagram profile or account fragment page... help to fix it... thanks in advance and I am using under tablayout framelayout not a viewpager and attach with framelayout fragment the 1st tab I can click then that fragment use the scroll, linear and the recyclerview that fragment call then whole layout scroll, but another second tab I can click then that fragment use the linear and gridview only and that fragment call then half layout scroll, where I am wrong please tell me...
<?xml version="1.0" encoding="utf-8"?>
<ScrollView
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport="true"
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<RelativeLayout
android:id="#+id/relativelayout"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<LinearLayout
android:id="#+id/imglayout"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<de.hdodenhof.circleimageview.CircleImageView
android:id="#+id/cvprofile"
android:layout_width="86dp"
android:layout_height="86dp"
app:civ_border_color="#a4a4a4"
app:civ_border_width="0.5dp"
android:layout_margin="12dp"
android:src="#drawable/img" />
</LinearLayout>
<LinearLayout
android:id="#+id/digitlayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_toRightOf="#id/imglayout"
android:layout_marginLeft="12dp"
android:layout_marginRight="12dp"
android:layout_marginTop="12dp">
<TextView
android:id="#+id/post"
android:layout_weight="1"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:text="100"
android:gravity="center"
android:textColor="#color/black"
android:textSize="16sp"
android:textStyle="bold" />
<TextView
android:id="#+id/followers"
android:layout_weight="1"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:text="100"
android:gravity="center"
android:textColor="#color/black"
android:textSize="16sp"
android:textStyle="bold"/>
<TextView
android:id="#+id/following"
android:layout_weight="1"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:text="43"
android:gravity="center"
android:textColor="#color/black"
android:textSize="16sp"
android:textStyle="bold"/>
</LinearLayout>
<LinearLayout
android:id="#+id/textlayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_toRightOf="#id/imglayout"
android:layout_below="#id/digitlayout"
android:layout_marginLeft="12dp"
android:layout_marginRight="12dp"
android:layout_marginTop="2dp">
<TextView
android:id="#+id/posts"
android:layout_weight="1"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:text="posts"
android:gravity="center"
android:textSize="16sp" />
<TextView
android:id="#+id/followerss"
android:layout_weight="1"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:text="follwers"
android:textSize="16sp"
android:gravity="center"/>
<TextView
android:id="#+id/followings"
android:layout_weight="1"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:text="follwers"
android:textSize="16sp"
android:gravity="center"/>
</LinearLayout>
<TextView
android:id="#+id/tvedit"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="#string/edit_profile"
android:layout_marginLeft="12dp"
android:layout_marginRight="12dp"
android:layout_marginTop="10dp"
android:textSize="15sp"
android:textStyle="bold"
android:textColor="#color/black"
android:background="#drawable/bg_textview"
android:layout_toRightOf="#id/imglayout"
android:layout_below="#id/textlayout"
android:gravity="center_horizontal"/>
<View
android:id="#+id/view1"
android:layout_below="#id/imglayout"
android:layout_width="match_parent"
android:layout_height="0.5dp"
android:background="#b6b6b6" />
<android.support.design.widget.TabLayout
android:id="#+id/tabLayout"
android:layout_below="#id/view1"
app:tabIndicatorHeight="0dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:tabGravity="fill"
app:tabMode="fixed">
<android.support.design.widget.TabItem
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:icon="#drawable/frame1"/>
<android.support.design.widget.TabItem
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:icon="#drawable/frame1" />
<android.support.design.widget.TabItem
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:icon="#drawable/frame1" />
<android.support.design.widget.TabItem
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:icon="#drawable/frame1" />
</android.support.design.widget.TabLayout>
<View
android:id="#+id/view2"
android:layout_below="#id/tabLayout"
android:layout_width="match_parent"
android:layout_height="0.5dp"
android:background="#b6b6b6" />
<FrameLayout
android:id="#+id/framelayout"
android:layout_below="#id/view2"
android:layout_width="match_parent"
android:layout_height="match_parent">
</FrameLayout>
</RelativeLayout>
</ScrollView>
Try changing ScrollView to NestedScrollView
android.support.v4.widget.NestedScrollView
Try to add a LinearLayout inside your ScrollView(ScrollView --> LiearLayout-->RelativeLayout--> ...). Or just add android:fillViewport="true" to your Scrollview.
Bro, I just copied your code to m xml and there is no problem with the scrolling...if you still have a problem then just add a relative layout before scrollview ....like this
RelativeLAyout>ScrollView>RelativeLayout
Try this
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:fillViewport="true">
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<RelativeLayout
android:id="#+id/relativelayout"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<LinearLayout
android:id="#+id/imglayout"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<de.hdodenhof.circleimageview.CircleImageView
android:id="#+id/cvprofile"
android:layout_width="86dp"
android:layout_height="86dp"
android:layout_margin="12dp"
android:src="#drawable/img"
app:civ_border_color="#a4a4a4"
app:civ_border_width="0.5dp" />
</LinearLayout>
<LinearLayout
android:id="#+id/digitlayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="12dp"
android:layout_marginRight="12dp"
android:layout_marginTop="12dp"
android:layout_toRightOf="#id/imglayout">
<TextView
android:id="#+id/post"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center"
android:text="100"
android:textColor="#color/black"
android:textSize="16sp"
android:textStyle="bold" />
<TextView
android:id="#+id/followers"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center"
android:text="100"
android:textColor="#color/black"
android:textSize="16sp"
android:textStyle="bold" />
<TextView
android:id="#+id/following"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center"
android:text="43"
android:textColor="#color/black"
android:textSize="16sp"
android:textStyle="bold" />
</LinearLayout>
<LinearLayout
android:id="#+id/textlayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#id/digitlayout"
android:layout_marginLeft="12dp"
android:layout_marginRight="12dp"
android:layout_marginTop="2dp"
android:layout_toRightOf="#id/imglayout">
<TextView
android:id="#+id/posts"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center"
android:text="posts"
android:textSize="16sp" />
<TextView
android:id="#+id/followerss"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center"
android:text="follwers"
android:textSize="16sp" />
<TextView
android:id="#+id/followings"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center"
android:text="follwers"
android:textSize="16sp" />
</LinearLayout>
<TextView
android:id="#+id/tvedit"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#id/textlayout"
android:layout_marginLeft="12dp"
android:layout_marginRight="12dp"
android:layout_marginTop="10dp"
android:layout_toRightOf="#id/imglayout"
android:background="#drawable/bg_textview"
android:gravity="center_horizontal"
android:text="#string/edit_profile"
android:textColor="#color/black"
android:textSize="15sp"
android:textStyle="bold" />
<View
android:id="#+id/view1"
android:layout_width="match_parent"
android:layout_height="0.5dp"
android:layout_below="#id/imglayout"
android:background="#b6b6b6" />
<android.support.design.widget.TabLayout
android:id="#+id/tabLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#id/view1"
app:tabGravity="fill"
app:tabIndicatorHeight="0dp"
app:tabMode="fixed">
<android.support.design.widget.TabItem
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:icon="#drawable/frame1" />
<android.support.design.widget.TabItem
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:icon="#drawable/frame1" />
<android.support.design.widget.TabItem
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:icon="#drawable/frame1" />
<android.support.design.widget.TabItem
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:icon="#drawable/frame1" />
</android.support.design.widget.TabLayout>
<View
android:id="#+id/view2"
android:layout_width="match_parent"
android:layout_height="0.5dp"
android:layout_below="#id/tabLayout"
android:background="#b6b6b6" />
<FrameLayout
android:id="#+id/framelayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="#id/view2"></FrameLayout>
</RelativeLayout>
</LinearLayout>
</ScrollView>
I need a help with CoordinatorLayout... I need hide/show toolbar when scrolling and together with this hiding behavior I need make smaller text and hide another layout in my AppBarLayout...
My layout looks like this:
<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:local="http://schemas.android.com/apk/res-auto"
android:id="#+id/coordinatorLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#color/main_light_gray">
<include
layout="#layout/toolbar_layout_filter_sales" />
<RelativeLayout
android:id="#+id/relativeLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
local:layout_behavior="#string/appbar_scrolling_view_behavior">
<LinearLayout
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#color/main_light_gray">
<android.support.design.widget.TabLayout
android:layout_gravity="center"
android:layout_marginTop="10dp"
android:layout_marginBottom="10dp"
android:id="#+id/tabs"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#drawable/tablayout_background"
local:tabIndicatorColor="#color/main_red"
local:tabIndicatorHeight="0dp"
local:tabGravity="center"
local:tabBackground="#drawable/tab_background_selector"
local:tabMode="fixed"
local:tabPaddingStart="20dp"
local:tabPaddingEnd="20dp"
local:tabTextColor="#color/main_dark_text"
local:tabSelectedTextColor="#color/white" />
<android.support.v4.view.ViewPager
android:id="#+id/viewpager"
android:layout_width="match_parent"
android:layout_height="fill_parent"
local:layout_behavior="#string/appbar_scrolling_view_behavior" />
</LinearLayout>
</RelativeLayout>
<!--</LinearLayout>-->
</android.support.design.widget.CoordinatorLayout>
Layout toolbar_layout_filter_sales looks like this:
<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.AppBarLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:local="http://schemas.android.com/apk/res-auto"
android:id="#+id/appbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#drawable/layout_rounded_corners"
android:stateListAnimator="#null"
android:theme="#style/ThemeOverlay.AppCompat.Dark.ActionBar">
<android.support.v7.widget.Toolbar
local:layout_scrollFlags="scroll|enterAlways"
android:id="#+id/toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
local:popupTheme="#style/ThemeOverlay.AppCompat.Light">
<LinearLayout
android:layout_marginTop="25dp"
android:orientation="horizontal"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center">
<TextView
android:textStyle="bold"
android:textColor="#color/white"
android:id="#+id/toolbar_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#android:color/transparent"
style="#style/TextAppearance.AppCompat.Widget.ActionBar.Title"
android:layout_gravity="center" />
</LinearLayout>
<LinearLayout
android:orientation="horizontal"
android:id="#+id/toolbar_refresh_layout"
android:layout_marginRight="15dp"
android:layout_marginLeft="15dp"
android:layout_gravity="right"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<ImageView
android:id="#+id/toolbar_refresh"
android:layout_width="20dp"
android:layout_height="20dp"
android:scaleType="centerInside"
android:src="#drawable/ic_refresh" />
</LinearLayout>
</android.support.v7.widget.Toolbar>
<LinearLayout
android:id="#+id/filterLayout"
android:orientation="horizontal"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginBottom="5dp">
<TextView
android:textSize="18dp"
android:textStyle="bold"
android:ellipsize="marquee"
android:maxLines="1"
android:text="Today"
local:MvxBind="Text SelectedFilterText"
android:textColor="#color/white"
android:id="#+id/filterTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:gravity="center"
android:layout_marginLeft="5dp"
android:layout_marginRight="2dp"
android:layout_marginBottom="1dp" />
<Button
android:textAllCaps="false"
android:id="#+id/filterButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="14dp"
android:text="15.5.2018"
local:MvxBind="Text CurrentPeriod"
android:ellipsize="marquee"
android:maxLines="1"
android:textColor="#color/white"
android:gravity="center_vertical"
android:textStyle="normal"
android:background="#android:color/transparent"
android:drawableEnd="#drawable/arrow_down_white"
android:drawablePadding="10dp"
android:layout_marginLeft="2dp"
android:layout_marginRight="5dp"
android:layout_marginBottom="0dp" />
</LinearLayout>
<ImageView
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="#color/main_dark_line"
android:layout_marginLeft="30dp"
android:layout_marginRight="30dp"
android:layout_marginBottom="10dp"
android:layout_marginTop="0dp" />
<LinearLayout
android:id="#+id/filterLayout"
android:orientation="vertical"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginBottom="10dp">
<TextView
android:text="58 395,00"
local:MvxBind="TextFormatted TotalSales, Converter=SpannableStringPriceConverter"
android:textSize="26dp"
android:textStyle="bold"
android:ellipsize="marquee"
android:maxLines="1"
android:textColor="#color/white"
android:id="#+id/salesTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:gravity="center"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_marginBottom="5dp" />
<TextView
local:MvxBind="Text LastUpdate, Converter=LastUpdateConverter"
android:textSize="12dp"
android:textStyle="italic"
android:ellipsize="marquee"
android:maxLines="1"
android:text="XX"
android:textColor="#color/white"
android:id="#+id/lastUpdateTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:gravity="center"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp" />
</LinearLayout>
</android.support.design.widget.AppBarLayout>
In default it looks like this:
After scrolling I have this:
But I need something like this:
I need text with value make smaller and text under value hide.
I am working on a coordinator layout with a nested scroll view. I also have 3 buttons at the bottom of my screen in my layout. Now when I scroll the layout the last elements of my scroll view being overlapped with the buttons I put at the bottom. I tried using a relative layout as parent to get rid of this problem but it is still persisting. So how can I get rid of this problem?The layouts are given below:
activity_agent_profile_2:
<?xml version="1.0" encoding="utf-8"?><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"
android:background="#fff"
tools:context=".AgentProfileActivity2">
<android.support.design.widget.CoordinatorLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#fff"
android:fitsSystemWindows="true"
android:layout_above="#+id/laytbtns">
<android.support.design.widget.AppBarLayout
android:layout_width="match_parent"
android:layout_height="270dp"
android:fitsSystemWindows="true"
android:theme="#style/AppTheme.AppBarOverlay">
<android.support.design.widget.CollapsingToolbarLayout
android:id="#+id/agent_profile_toolbar"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
app:contentScrim="?attr/colorPrimary"
app:expandedTitleMarginBottom="125dp"
app:expandedTitleMarginStart="118dp"
app:expandedTitleTextAppearance="#style/expandedappbar"
app:layout_scrollFlags="scroll|exitUntilCollapsed">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#fff"
android:fitsSystemWindows="true"
app:layout_collapseMode="parallax">
<ImageView
android:id="#+id/backdrop"
android:layout_width="match_parent"
android:layout_height="180dp"
android:fitsSystemWindows="true"
android:scaleType="centerCrop"
android:src="#drawable/back" />
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="180dp"
android:background="#66000000">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_marginLeft="120dp"
android:orientation="vertical">
<TextView
android:id="#+id/lbl_agent_profile_position"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/lbl_agent_profile_Name"
android:ellipsize="end"
android:maxLines="1"
android:text="Real Estate Professional at Exit Alliance Realty"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="#fff"
android:textSize="12sp"
android:typeface="sans" />
<TextView
android:id="#+id/lbl_agent_profile_membersince"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Member Since: 2015"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="#fff"
android:textSize="13sp"
android:typeface="sans" />
</LinearLayout>
</RelativeLayout>
<ImageView
android:id="#+id/img_agent_profile_image"
android:layout_width="100dp"
android:layout_height="140dp"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_marginLeft="12dp"
android:layout_marginStart="12dp"
android:scaleType="fitStart"
android:src="#drawable/no_profile" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/backdrop"
android:layout_marginLeft="5dp"
android:layout_toEndOf="#+id/img_agent_profile_image"
android:layout_toRightOf="#+id/img_agent_profile_image"
android:orientation="vertical">
<RelativeLayout
android:id="#+id/relativeLayout3"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#fff">
<ImageView
android:id="#+id/imageView13"
android:layout_width="15dp"
android:layout_height="15dp"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_centerVertical="true"
android:src="#drawable/ic_phone_img" />
<TextView
android:id="#+id/lbl_agent_profile_phone"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_marginLeft="3dp"
android:layout_toEndOf="#+id/imageView13"
android:layout_toRightOf="#+id/imageView13"
android:text="01723735134"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="#56698F"
android:textSize="13sp"
android:typeface="sans" />
</RelativeLayout>
<RelativeLayout
android:id="#+id/relativeLayout4"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#fff">
<ImageView
android:id="#+id/imageView14"
android:layout_width="15dp"
android:layout_height="15dp"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_centerVertical="true"
android:src="#drawable/ic_location_nopadding" />
<TextView
android:id="#+id/lbl_agent_profile_address"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_marginLeft="3dp"
android:layout_toEndOf="#+id/imageView14"
android:layout_toRightOf="#+id/imageView14"
android:ellipsize="end"
android:maxLines="1"
android:text="2868 Al Urabuh Road, Al Urudh, Ryadh"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="#56698F"
android:textSize="12sp"
android:typeface="sans" />
</RelativeLayout>
<RelativeLayout
android:id="#+id/relativeLayout5"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#fff">
<ImageView
android:id="#+id/imageView15"
android:layout_width="15dp"
android:layout_height="15dp"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_centerVertical="true"
android:src="#drawable/ic_website" />
<TextView
android:id="#+id/lbl_agent_profile_website"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_marginLeft="3dp"
android:layout_toEndOf="#+id/imageView15"
android:layout_toRightOf="#+id/imageView15"
android:ellipsize="end"
android:maxLines="1"
android:text="www.ibaax.com"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="#56698F"
android:textSize="12sp"
android:typeface="sans" />
</RelativeLayout>
</LinearLayout>
</RelativeLayout>
<android.support.v7.widget.Toolbar
android:id="#+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:layout_marginTop="-50dp"
app:layout_collapseMode="pin"
app:popupTheme="#style/AppTheme.PopupOverlay" />
</android.support.design.widget.CollapsingToolbarLayout>
</android.support.design.widget.AppBarLayout>
<include layout="#layout/content_agent_profile" />
</android.support.design.widget.CoordinatorLayout>
<LinearLayout
android:id="#+id/laytbtns"
android:layout_width="match_parent"
android:layout_height="40dp"
android:layout_alignParentBottom="true"
android:background="#495B81">
<Button
android:id="#+id/testbutton"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginRight="1dp"
android:layout_weight="1"
android:background="#56688f"
android:onClick="btnEmail_click"
android:text="Message"
android:textColor="#fff"
android:textStyle="bold"
android:typeface="sans" />
<Button
android:id="#+id/SMSButton"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginRight="1dp"
android:layout_weight="1"
android:background="#56688f"
android:onClick="btnSMS_click"
android:text="SMS"
android:textColor="#fff"
android:textStyle="bold"
android:typeface="sans" />
<Button
android:id="#+id/cancelButton"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="#56688f"
android:onClick="btnPhone_click"
android:text="Call"
android:textColor="#fff"
android:textStyle="bold"
android:typeface="sans" />
</LinearLayout></RelativeLayout>
content_agent_profile.xml:
<android.support.v4.widget.NestedScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#fff"
android:layout_gravity="fill_vertical"
app:layout_behavior="#string/appbar_scrolling_view_behavior"
tools:context=".AgentProfileActivity2"
tools:showIn="#layout/activity_agent_profile2">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<View
android:layout_width="match_parent"
android:layout_height="0.5dp"
android:layout_marginTop="5dp"
android:background="#d3d3d3" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="10dp"
android:orientation="vertical">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="8dp"
android:text="Specialities"
android:textColor="#60aaff"
android:textSize="18sp"
android:textStyle="bold" />
<TextView
android:id="#+id/lbl_agent_profile_specialites"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="8dp" />
</LinearLayout>
<View
android:layout_width="match_parent"
android:layout_height="0.5dp"
android:layout_marginTop="5dp"
android:background="#d3d3d3" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="10dp"
android:orientation="vertical">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="8dp"
android:text="Service Area"
android:textColor="#60aaff"
android:textSize="18sp"
android:textStyle="bold" />
<TextView
android:id="#+id/lbl_agent_profile_service"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="8dp" />
</LinearLayout>
<View
android:layout_width="match_parent"
android:layout_height="0.5dp"
android:layout_marginTop="5dp"
android:background="#d3d3d3" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="10dp"
android:orientation="vertical">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="8dp"
android:text="Profile Summery "
android:textColor="#60aaff"
android:textSize="18sp"
android:textStyle="bold" />
<WebView
android:id="#+id/web_agentprofile_description"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</LinearLayout>
<View
android:layout_width="match_parent"
android:layout_height="0.5dp"
android:layout_marginTop="5dp"
android:background="#d3d3d3" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="10dp"
android:orientation="vertical">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="8dp"
android:text="Active Listing"
android:textColor="#60aaff"
android:textSize="18sp"
android:textStyle="bold" />
<UI.ExpandableHeightGridView
android:id="#+id/gridview_agent_property"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="8dp"
android:horizontalSpacing="2dp"
android:isScrollContainer="false"
android:numColumns="1"
android:stretchMode="columnWidth"
android:verticalSpacing="2dp" />
</LinearLayout>
</LinearLayout></android.support.v4.widget.NestedScrollView>
Here is an image of the issue:
Contents in scroll view is being overlapped
Edit:
So I fixed the issue by setting a margin-bottom to 80dp in my nested scroll view. It seems to work for now but it is not a permanent solution. If anyone can come up with a better solution, I will be really grateful.
<include layout="#layout/content_agent_profile"
android:layout_above="#+id/your above layout id"
android:layout_below="#+id/below layout id"/>
So I fixed the issue by setting a margin-bottom to 80dp in my nested scroll view. It seems to work for now but it is not a permanent solution. If anyone can come up with a better solution, I will be really grateful.
If you're using ConstraintLayout and your included layout overlapping other views, then give your include layout height and width.
<include
android:id="#+id/errorScreen"
layout="#layout/error_screen_layout"
android:layout_width="0dp"
android:layout_height="wrap_content"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/topView"/>