I have a fragment,in which I have a calendar, text view and a listview. All these views are inside the scroll view. I need two things in that layout.
I want to disable the scrolling of the list view.
How scroll to invoke scroll view when I swipe up, I want to hide calendar and text view. And on swipe down. It shows the whole layout.
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:animateLayoutChanges="true"
>
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport="true"
android:layout_below="#+id/rel"
android:id="#+id/scroll"
>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<LinearLayout
android:id="#+id/compactcalendar_view_container"
android:layout_below="#+id/rel"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="New Text"
android:textColor="#e1dcdc"
android:background="#011627"
android:id="#+id/date_picker_text_view"
android:textAlignment="center" />
<com.github.sundeepk.compactcalendarview.CompactCalendarView
android:id="#+id/cvCalendar"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="250dp"
app:compactCalendarTargetHeight="250dp"
android:layout_below="#+id/textView14"
app:compactCalendarBackgroundColor="#011627"
app:compactCalendarCurrentDayBackgroundColor="#FFC107"
app:compactCalendarCurrentSelectedDayBackgroundColor="#939393"
app:compactCalendarTextColor="#e1dcdc"
app:compactCalendarTextSize="12sp" />
</LinearLayout>
<ListView
android:id="#+id/lvList"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:divider="#e9e9e9"
android:dividerHeight="10dp"
android:clickable="false"
android:focusable="false"
android:focusableInTouchMode="false"
android:scrollbars="none"
android:background="#eee"
android:layout_below="#+id/scroll"
android:layout_centerHorizontal="true" />
</LinearLayout>
</ScrollView>
</RelativeLayout>
Related
want to scroll RecyclerView and views in scroll view, in this code scroll only work on views but not scroll the RecyclerView or scroll hide the RecyclerView.I am using nested scrollview but same not working.
scroll views and RecyclerView like as one layout is scrolling.
<?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">
<ScrollView
android:id="#+id/scrol"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/topRl5"
android:fillViewport="true">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:visibility="visible">
<android.support.v4.widget.NestedScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/nested_scrol"
android:orientation="vertical"
android:visibility="visible">
<com.github.mikephil.charting.charts.BarChart
android:id="#+id/chart1"
android:layout_width="match_parent"
android:layout_height="#dimen/_300sdp"
android:layout_below="#+id/weekly_summary"
android:visibility="visible" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:background="#color/grey_light"
android:gravity="center"
android:padding="#dimen/_5sdp"
android:text="تفصیلی رپورٹ"
android:textSize="#dimen/_15sdp" />
</LinearLayout>
</android.support.v4.widget.NestedScrollView>
</LinearLayout>
</ScrollView>
<LinearLayout
android:id="#+id/daily_earning_list"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/scrol"
android:visibility="visible">
<include
layout="#layout/weekly_list"
android:layout_width="match_parent"
android:layout_height="wrap_content"
/>
</LinearLayout>
</RelativeLayout>
Here is my RecyclerView i include it in main class
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="wrap_content"
tools:showIn="#layout/activity_barchart"
tools:context=".guaranteeDetails.baarChart.BarChartActivity">
<android.support.v7.widget.RecyclerView
android:id="#+id/weekly_recycler_view"
android:layout_marginRight="#dimen/_4sdp"
android:layout_marginLeft="#dimen/_4sdp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
/>
Use should use NestedScrollView instead of ScrollView
And I would also recommend setting
Recyclerview.setNestedScrollingEnabled(false);
I'm beginner in android, and I don't know why this happens.
Without SwipeRefreshLayout the RecyclerView is fully visible, but with SwipeRefreshLayout, the first item isn't shown.
Maybe it's under the toolbar? (The hidden item exists, I checked it in numerous ways.)
<android.support.v4.widget.SwipeRefreshLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="#+id/swipe_layout">
<android.support.v7.widget.RecyclerView
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="#+id/MainRecyclerView"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="#string/appbar_scrolling_view_behavior">
</android.support.v7.widget.RecyclerView>
</android.support.v4.widget.SwipeRefreshLayout>
List:
<?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="wrap_content"
android:orientation="horizontal"
android:paddingTop="8dip"
android:paddingBottom="8dip"
android:paddingLeft="16dip"
android:paddingRight="16dip"
android:weightSum="10"
android:gravity="center">
<ImageView
android:id="#+id/CharacterItemRankImageView"
android:layout_width="50dp"
android:layout_height="50dp"
android:layout_weight="0"
android:src="#drawable/challengemode_medal_bronze"/>
<TextView android:id="#+id/CharacterItemNameTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="3.5"
tools:text="Name"/>
<TextView android:id="#+id/CharacterItemPointsTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAlignment="center"
android:layout_weight="6"
tools:text="Points"/>
<ImageButton
android:id="#+id/CharacterItemRemoveButton"
android:layout_width="50dp"
android:layout_height="50dp"
android:layout_weight="0.5"
android:src="#drawable/ic_delete_grey600_48dp"
android:scaleType="fitXY" style="#style/Widget.AppCompat.Button.Borderless" />
</LinearLayout>
I guess you are using a CoordinatorLayout as root of your view. In that case, what is happenning is that the toolbar is being hidden by the first item of your RecyclerView.
To fix this issue, you just need to add the layout behavior to the SwipeRefreshLayout and remove from your RecyclerView.
<android.support.v4.widget.SwipeRefreshLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="#+id/swipe_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="#string/appbar_scrolling_view_behavior">
<android.support.v7.widget.RecyclerView
android:id="#+id/MainRecyclerView"
android:layout_width="match_parent"
android:layout_height="match_parent">
</android.support.v7.widget.RecyclerView>
</android.support.v4.widget.SwipeRefreshLayout>
So I have a fragment with 2 RecyclerView lists. I want to swipe fragment to refresh those lists but when I scroll one of those lists to see hidden elements SwipeToRefresh refreshes those lists. How to prevent it from that?
Here is my XML layout:
<FrameLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="#+id/main_fragment">
<android.support.v4.widget.SwipeRefreshLayout
android:id="#+id/main_fragment_swipe_to_refresh"
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.design.widget.CoordinatorLayout
android:id="#+id/main_fragment_coordinator_layout"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:weightSum="2">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_weight="1">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="4dp"
android:textSize="18sp"
android:textColor="#color/primary_dark"
android:text="Najpopularniejsze przepisy" />
<android.support.v7.widget.RecyclerView
android:id="#+id/top_recipes_recycler_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:scrollbars="vertical" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_weight="1">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="4dp"
android:textSize="18sp"
android:textColor="#color/primary_dark"
android:text="Najnowsze przepisy" />
<android.support.v7.widget.RecyclerView
android:id="#+id/latest_recipes_recycler_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:scrollbars="vertical" />
</LinearLayout>
</LinearLayout>
</android.support.design.widget.CoordinatorLayout>
</android.support.v4.widget.SwipeRefreshLayout>
</FrameLayout>
Any ideas?
You can consume the swipe down event in RecycleView when it can scroll up.
Just custom the RecycleView and intercept the event when you need.
I want to see RecyclerView items when scrolling it from behind of top layout ( LinearLayout with top id).
I can see the scroll bar from behind but recyclerview item , no .
please help.
this is my xml layout :
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
android:layout_height="match_parent"
android:layout_width="wrap_content"
xmlns:android="http://schemas.android.com/apk/res/android"
android:background="#android:color/transparent">
<LinearLayout
android:background="#android:color/transparent"
android:alpha="0.25"
android:id="#+id/top"
android:layout_alignParentTop="true"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
>
<Button
android:background="#80000000"
android:textColor="#color/material_blue_grey_950"
android:id="#+id/btn_ketabdonUpdate"
android:layout_width="0dp"
android:text="yyyyy"
android:layout_weight="1"
android:layout_height="match_parent" />
<android.support.v7.widget.AppCompatButton
android:background="#80000000"
android:textColor="#color/material_blue_grey_950"
android:id="#+id/btn_ketabdonFilter"
android:text="xxxxx"
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="match_parent" />
</LinearLayout>
<android.support.v4.widget.SwipeRefreshLayout
android:layout_alignParentTop="true"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="#+id/swipeRefreshLayout"
>
<android.support.v7.widget.RecyclerView
android:paddingTop="50dp"
android:scrollbars="vertical"
android:fadeScrollbars="true"
android:paddingRight="5dp"
android:verticalScrollbarPosition="left"
android:scrollbarStyle="outsideInset"
android:id="#+id/rv_fragment"
android:layout_height="match_parent"
android:layout_width="wrap_content"
/>
</android.support.v4.widget.SwipeRefreshLayout>
</RelativeLayout>
I have a Fragment fully occupied by a ScroolView. I added a ViewPager inside the layout in the ScrollView, like in this code:
<FrameLayout
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"
tools:context="com.asdf.AFragment">
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<ScrollView
android:id="#+id/scrollView"
android:layout_width="match_parent"
android:fillViewport="true"
android:scrollbars="vertical"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/top_linear_layout"
android:orientation="vertical">
<FrameLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:minHeight="100dp">
<TextView
android:id="#+id/meteo_placeholder"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="Meteo and others"
android:textAppearance="?android:attr/textAppearanceSmall" />
</FrameLayout>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Begin"
android:textSize="30dp"
/>
<!--THIS IS NOT SHOWN-->
<android.support.v4.view.ViewPager
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/view_pager_main"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
>
<android.support.v4.view.PagerTitleStrip
android:id="#+id/title_strip_main"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="top"
android:paddingTop="4dp"
android:paddingBottom="4dp" />
</android.support.v4.view.ViewPager>
<!-- LAST TEXT VIEW -->
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="End"
android:textSize="30dp"
/>
</LinearLayout>
</ScrollView>
But the ViewPager is not shown at all. I am sure it works because its adapter is used (I can see the call to getItem(), and the ViewPager alone works fine ).
If I remove the last text view however, the ViewPager is shown, but the ScrollView is not scrollable at all, and all the LinearLayout' contents are restricted to the screen height, like if there was no ScrollView