android layout with fragment breaks when toolbar is there - android

Couldn't find a more appropriate title but my problem is the following. I have a LinearLayout that contains another LinearLayout and a fragment. I also want to add the toolbar but when I do so, then I only see the toolbar and the other screen is just white.
Here is the layout:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout 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:orientation="horizontal"
tools:context="xeniasis.mymarket.MainActivity">
<include
android:id="#+id/toolbar"
layout="#layout/toolbar" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:baselineAligned="false"
android:weightSum="4">
<LinearLayout
android:id="#+id/categories_layout"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:paddingRight="20dp">
<ExpandableListView
android:id="#+id/categories_listView"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</LinearLayout>
<fragment
android:id="#+id/mainPane"
android:name="xeniasis.mymarket.Products"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="3"
tools:layout="#layout/activity_main" />
</LinearLayout>
</LinearLayout>
Toolbar:
<android.support.v7.widget.Toolbar xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:elevation="4dp"
android:padding="5dp"
android:theme="#style/ToolbarTheme" />
And the fragment layout:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout 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:orientation="vertical"
tools:context="xeniasis.mymarket.MainActivity">
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/main_content"
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.v4.widget.SwipeRefreshLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/swipeRefreshContainer"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="#dimen/activity_vertical_margin"
android:paddingLeft="8dp"
android:paddingRight="8dp"
android:paddingTop="#dimen/activity_vertical_margin">
<GridView
android:id="#+id/productsGridview"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:numColumns="3"></GridView>
</android.support.v4.widget.SwipeRefreshLayout>
<android.support.design.widget.FloatingActionButton
android:id="#+id/settings"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom|start"
android:layout_margin="8dp"
android:clickable="true"
android:elevation="5dp"
android:src="#android:drawable/ic_menu_search" />
</android.support.design.widget.CoordinatorLayout>
</LinearLayout>
This only happens when I have a fragment, cause I previously had the same xml with a static layout where the fragment is now.

The problem is that you used a LinearLayout with
android:orientation="horizontal"
and since the toolbar has match_parent as width it occupies all the screen.
Try to use
android:orientation="vertical"
in the root layout

Related

How to remove empty white space at the bottom of the screen in NestedScrollView?

I'm using a NestedScrollView to make the carousel and viewPager scrollable. I added the carousel on the main layout because I need it on all pages from the tab layout. All the pages of the tab layout have only a recycler view in the fragment. The problem is that on the bottom of the screen there is a lot of empty white space that I can't figure out how to remove.
This is the main layout activity xml
`
<?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:orientation="vertical"
android:background="#color/blue_primary"
tools:context=".ui.activity.SplashscreenActivity">
<LinearLayout
android:id="#+id/mainTopBar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="#dimen/margin_padding_size_xlarge"
android:orientation="horizontal">
////// irrelevant code
</LinearLayout>
<LinearLayout
android:id="#+id/mainLL"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="fill_vertical"
android:layout_alignParentBottom="true"
android:layout_below="#+id/mainTopBar"
android:orientation="vertical">
<com.google.android.material.tabs.TabLayout
android:id="#+id/tab_layout"
android:background="#color/blue_primary"
app:tabTextAppearance="#style/MyCustomTextAppearance"
app:tabIndicatorColor="#color/plan_popular_gradient_1"
app:tabSelectedTextColor="#color/white"
app:tabTextColor="#color/white"
app:tabGravity="fill"
android:clipToPadding="true"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<androidx.core.widget.NestedScrollView
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:fillViewport="true"
android:overScrollMode="never"
android:layout_gravity="fill_vertical"
app:layout_behavior="#string/appbar_scrolling_view_behavior"
android:orientation="vertical">
<LinearLayout
android:id="#+id/secondLL"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="top"
android:orientation="vertical">
<com.gigamole.infinitecycleviewpager.HorizontalInfiniteCycleViewPager
android:id="#+id/carousel"
android:layout_width="match_parent"
android:layout_height="#dimen/featured_height"
app:icvp_interpolator="#android:anim/accelerate_decelerate_interpolator"
app:icvp_scroll_duration="3000"
app:icvp_center_page_scale_offset="#dimen/icon_size_large"
app:icvp_min_page_scale_offset="#dimen/margin_padding_size_xmedium"
app:icvp_max_page_scale="0.8"
app:icvp_min_page_scale="0.55"
app:icvp_medium_scaled="false"/>
<androidx.viewpager2.widget.ViewPager2
android:id="#+id/view_pager"
android:paddingHorizontal="#dimen/margin_padding_size_small"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</LinearLayout>
</androidx.core.widget.NestedScrollView>
</LinearLayout>
</RelativeLayout>
`
This is the fragments xml
`
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="#+id/app_layout_content_container"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:focusable="false"
tools:context=".ui.fragments.AppLayoutFragment">
<androidx.recyclerview.widget.RecyclerView
android:id="#+id/app_layout_scroll_rv"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="fill_vertical"
android:focusable="false"
android:focusableInTouchMode="false" />
</LinearLayout>
`
This is the recycler view item xml
`
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/home_item_content_wrapper"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="#dimen/margin_padding_size_medium"
android:focusable="false"
android:orientation="vertical">
<TextView
android:id="#+id/itemHomeTitle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:focusable="false"
android:textStyle="bold"
android:textSize="#dimen/text_size_large" />
<androidx.recyclerview.widget.RecyclerView
android:id="#+id/itemHomeRv"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:nestedScrollingEnabled="false"
android:orientation="horizontal"
android:focusable="false" />
</LinearLayout>
`
I tried all the answers I could find on stackoverflow (you can see all the attributes on the NestedScrollView) but none of them fixed my problem.

Android RecyclerView Gravity issue

I am using DrawerLayout to show Navigation Drawer, in that A NavigationView, the xml code is :
MyDrawerLayout.xml
<android.support.design.widget.NavigationView
android:id="#+id/nav_view"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="start"
android:fitsSystemWindows="true">
<include layout="#layout/layout_navigation_list" />
</android.support.design.widget.NavigationView>
layout_navigation_list.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#color/white"
android:orientation="vertical">
<include
android:id="#+id/headerLayout"
layout="#layout/nav_header_dash_nav"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_gravity="top"
android:gravity="top" />
<android.support.v7.widget.RecyclerView
android:id="#+id/recyclerNav"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/headerLayout"
android:layout_alignParentBottom="true"
android:layout_gravity="bottom"
android:background="#color/white"
android:foregroundGravity="bottom" />
</RelativeLayout>
In the RecyclerView i have only 3 items to be shown, and they are aligning on the top of the RecyclerView layout which is i don't want. Hence my question here is , how to send those items to the bottom of the RecyclerView (just like shown in the image).
Set match_parent instead wrap_content field layout_height in relativeLayout :
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#color/white"
android:orientation="vertical">
Insert a ConstraintLayout
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:background="#color/white"
android:orientation="vertical">
<include
android:id="#+id/headerLayout"
layout="#layout/nav_header_dash_nav"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_gravity="top"
android:gravity="top" />
<android.support.constraint.ConstraintLayout
android:layout_below="#id/headerLayout"
android:layout_alignParentBottom="true"
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.v7.widget.RecyclerView
android:id="#+id/recyclerNav"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#color/white"
app:layout_constraintBottom_toBottomOf="parent"
/>
</android.support.constraint.ConstraintLayout>
</RelativeLayout>
You should have to MATCH_PARENT height instead of WRAP_CONTENT in root relative layout in file layout_navigation_list.xml. So it looks like,
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#color/white"
android:orientation="vertical">
...
...
...
</RelativeLayout>
Notes: Gravity won't work with relative layouts.

Fragment not displaying in fullscreen when using viewpager

I want my viewpager display fragment in the full screen.It is not displaying only in the half of the screen.I am stuck with this issue from past two days.So please help me to come out of this issue.Thanks in advance.
This is my activity code named activity_subcategory.xml -
<LinearLayout
android:id="#+id/main_layout"
android:orientation="vertical"
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.support.v7.widget.Toolbar
android:id="#+id/toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?attr/colorPrimary"
app:navigationIcon="#drawable/ic_arrow_back"
android:minHeight="?attr/actionBarSize"
android:theme="#style/ThemeOverlay.AppCompat.Dark.ActionBar"
app:popupTheme="#style/ThemeOverlay.AppCompat.Light"/>
<!-- our tablayout to display tabs -->
<android.support.design.widget.TabLayout
android:id="#+id/tabLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?attr/colorPrimary"
android:layout_gravity="center_horizontal"
app:tabMode="scrollable"
app:tabSelectedTextColor="#color/buttoncolor"
android:minHeight="?attr/actionBarSize"
app:tabIndicatorColor="#color/buttoncolor"
android:theme="#style/ThemeOverlay.AppCompat.Dark.ActionBar"/>
<!-- View pager to swipe views -->
<android.support.v4.view.ViewPager
android:id="#+id/pager"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</LinearLayout>
This is my Fragment code named singlesubcategory.xml -
<?xml version="1.0" encoding="utf-8"?>
<android.support.v7.widget.CardView android:layout_width="match_parent"
android:layout_height="wrap_content"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_margin="10dp"
xmlns:android="http://schemas.android.com/apk/res/android">
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<ImageView
android:id="#+id/imgcat"
android:layout_width="100dp"
android:layout_height="100dp"
android:adjustViewBounds="true"
android:layout_margin="5dp"
android:src="#drawable/laundry1" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="5dp"
android:orientation="vertical">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:id="#+id/txtcat"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="right"
android:weightSum="10"
android:orientation="horizontal">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="2dp"
android:layout_weight="7"
android:layout_marginRight="2dp"
android:text="₹ 30"
android:gravity="center"/>
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
app:srcCompat="#drawable/ic_addtocart"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="2dp"
android:layout_weight="1"
android:layout_marginRight="2dp"
android:text="0"/>
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
app:srcCompat="#drawable/ic_removecart"/>
</LinearLayout>
</LinearLayout>
</LinearLayout>
</android.support.v7.widget.CardView>
See this image. i want that card display in full width of screen.
This is my recyclerview code.
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:orientation="vertical"
android:layout_height="match_parent">
<android.support.v7.widget.RecyclerView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="#+id/rcv"></android.support.v7.widget.RecyclerView>
</LinearLayout>
Change viewpager height
<android.support.v4.view.ViewPager
android:id="#+id/pager"
android:layout_width="match_parent"
android:layout_height="match_parent" />
in your xml activity_subcategory.xml
change parent Linear layout
<LinearLayout
android:id="#+id/main_layout"
android:orientation="vertical"
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="fill_parent">
change height to fill parent.
Use this code
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_gravity="center"
android:gravity="center"
android:layout_height="match_parent">
<android.support.v7.widget.RecyclerView
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:id="#+id/rcv"
android:layout_gravity="center"
android:foregroundGravity="center">
</android.support.v7.widget.RecyclerView>
for view pager use fill parent
<android.support.v4.view.ViewPager
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="#+id/viewPager"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
/>

Cannot Fix a header above RecyclerView in Android

I need to show a header above a RecyclerView but with the code below, the header is not fixed and gets scrolled with the recycler view.
Does anyone has a solution for his problem?
fragment_history_detail.xml
[[First Try]]
<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="?android:attr/colorBackground">
<RelativeLayout
android:id="#+id/header_container"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true">
<include
layout="#layout/view_header_history_detail"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</RelativeLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#id/header_container">
<android.support.v7.widget.RecyclerView
android:id="#+id/recyclerView_history_list"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
app:layoutManager="LinearLayoutManager"
tools:listitem="#layout/fragment_history_detail_item_self" />
</RelativeLayout>
</RelativeLayout>
[[Second Try]]
I also tried using LinearLayout like below. But it doesn't help.
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="?android:attr/colorBackground"
android:orientation="vertical">
<include
layout="#layout/view_header_history_detail"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<android.support.v7.widget.RecyclerView
android:id="#+id/recyclerView_history_list"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
app:layoutManager="LinearLayoutManager"
tools:listitem="#layout/fragment_history_detail_item_self" />
</LinearLayout>
[[Third Try]]
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="?android:attr/colorBackground"
android:orientation="vertical">
<include
layout="#layout/view_header_history_detail"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<RelativeLayout xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="?android:attr/colorBackground">
<android.support.v7.widget.RecyclerView
android:id="#+id/recyclerView_history_list"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
app:layoutManager="LinearLayoutManager"
tools:listitem="#layout/fragment_history_detail_item_self" />
</RelativeLayout>
</LinearLayout>
view_header_history_detail.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal">
<ImageView
android:id="#+id/imageView_back"
android:layout_width="60dp"
android:layout_height="#dimen/title_height"
android:background="?attr/colorPrimaryDark"
app:srcCompat="#drawable/vector_expand_left" />
<TextView
android:id="#+id/textview_title"
android:layout_width="match_parent"
android:layout_height="#dimen/title_height"
android:background="?attr/colorPrimaryDark"
android:gravity="center_vertical"
android:text="History Detail"
android:textAllCaps="true"
android:textColor="?attr/colorHeaderText"
android:textSize="16sp" />
</LinearLayout>
Use LinearLayout instead of RelativeLayout. And ser Orientation to vertical. So that the layout place top to bottom.
So, Your parent layout should be link this ->
<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:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="?android:attr/colorBackground">
<!--Your child layouts goes here-->
</LinearLayout>
Copy below code and put in your xml file
<RelativeLayout
android:id="#+id/header_container"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true">
<include
layout="#layout/view_header_history_detail"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</RelativeLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#id/header_container">
<android.support.v7.widget.RecyclerView
android:id="#+id/recyclerView_history_list"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
app:layoutManager="LinearLayoutManager"
tools:listitem="#layout/fragment_history_detail_item_self" />
</RelativeLayout>
remove above relative layout or you can paste ralative layout content
<RelativeLayout
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="?android:attr/colorBackground">
<android.support.v7.widget.RecyclerView
android:id="#+id/recyclerView_history_list"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
app:layoutManager="LinearLayoutManager"
tools:listitem="#layout/fragment_history_detail_item_self" />
</RelativeLayout>
if you want to fix the layout then u can do one thing as i m thinking....
look the code below....
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="?android:attr/colorBackground"
android:orientation="vertical">
<include
layout="#layout/view_header_history_detail"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<RelativeLayout xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="?android:attr/colorBackground"/>
<android.support.v7.widget.RecyclerView
android:id="#+id/recyclerView_history_list"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
app:layoutManager="LinearLayoutManager"
tools:listitem="#layout/fragment_history_detail_item_self" /></LinearLayout>
Try below code. it works for me.
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<include layout="#layout/view_header_history_detail" />
<android.support.v7.widget.RecyclerView
android:id="#+id/recyclerChat"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1" />
</LinearLayout>

How to stop ScrollView to move automatically

In the layout.xml below
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:android="http://schemas.android.com/apk/res/android">
<ScrollView
android:focusableInTouchMode="true"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<LinearLayout
android:id="#+id/category_layout_top"
android:fitsSystemWindows="true"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
xmlns:android="http://schemas.android.com/apk/res/android">
<FrameLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:descendantFocusability="beforeDescendants"
>
<ImageView
android:fitsSystemWindows="true"
android:layout_width="390dp"
android:layout_height="390dp"
android:scaleType="centerCrop"
android:id="#+id/category_Image_View"/>
</FrameLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="50dp"
android:id="#+id/category_linearlayout">
<TextView android:layout_width="match_parent"
android:layout_height="match_parent"
android:singleLine="true"
android:id="#+id/category_textView"
/>
</LinearLayout>
<android.support.v7.widget.RecyclerView
android:id="#+id/category_recycler_view"
android:layout_width="match_parent"
android:padding="10dp"
android:scrollbars="vertical"
android:layout_height="wrap_content"
android:clickable="true"/>
</LinearLayout>
</ScrollView>
<android.support.v7.widget.Toolbar
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/def_toolbar"
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:minHeight="?attr/actionBarSize"
android:background="#00FFFFFF"
android:layout_alignParentTop="true" />
</FrameLayout>
Whenever the respective activity is started, the ScrollView ends up showing the last items of the RecyclerView automatically. How to prevent that?
I tried to remove the android:descendantFocuabiity="beforeDescendants" from the Framelayout containing ImageView just in case,to see if it works, and it didn't.
Thanks in Advance!

Categories

Resources