I'm trying to use the SlidingUpPanel from umano and have the slider be a ViewPager.
However, when trying to scroll left and right the ViewPager isn't moving. It appears the touch events are being intercepted by the SlidingUpPanel.
<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" >
<com.sothree.slidinguppanel.SlidingUpPanelLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="#+id/slider_layout"
android:layout_gravity="bottom">
<!-- Top Panel -->
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent" >
</LinearLayout>
<!-- Sliding Panel -->
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<android.support.v4.view.ViewPager
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="#+id/pager">
</android.support.v4.view.ViewPager>
</LinearLayout>
</com.sothree.slidinguppanel.SlidingUpPanelLayout>
</RelativeLayout>
Try:
Use the setDragView method for the ViewPager.
Use the setEnableDragViewTouchEvents so the dragview/ViewPager can have it's own touch
events.
Alternatively make a seperate View apart from the ViewPager that is intended to be for dragging and set the DragView to this View accordingly, the ViewPAger should receive the touch events seperately and can handle them. (the latter is how I do it and works with other layout)
Related
I have a requirement where I need to code a screen which has a info view in top and view pager with two tabs in the bottom. View pager has two tabs with Recycler View inside it.
The View pager should stick whenever the user scrolls up and then the recycler view inside it should start scrolling. To achieve this I created two separate fragments for top part and bottom part and wrote the xml like this.
<com.citi.mobile.dashboard.views.StickyScrollView
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:custom="http://schemas.android.com/apk/res-auto"
android:orientation="vertical"
android:fillViewport="true"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#color/core_color_FFFFFF_white">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<include
android:id="#+id/title_id"
layout="#layout/app_bar"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<FrameLayout
android:id="#+id/top_container"
android:layout_width="match_parent"
android:layout_height="wrap_content">
</FrameLayout>
<FrameLayout
android:id="#+id/bottom_container"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:tag="sticky">
</FrameLayout>
</LinearLayout>
Inside the the bottom container I have a View Pager.
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:custom="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:orientation="vertical">
<android.support.design.widget.TabLayout
android:id="#+id/TransTabs"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:tabGravity="fill"
app:tabIndicatorColor="#color/core_color_0077bb_blue"
app:tabMode="fixed"
app:tabSelectedTextColor="#color/core_color_0077bb_blue"
app:tabTextAppearance="#style/ledgerTabLayoutTextAppearance"
app:tabTextColor="#color/core_color_666666_grey"
custom:typefaceName="Roboto-Medium" />
<android.support.v4.view.ViewPager
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="#+id/transaction_pager"
android:layout_width="match_parent"
android:layout_height="wrap_content">
</android.support.v4.view.ViewPager>
This has two tabs and each has a recycler view inside this. When I run this the parent scrollview stops working and only the recyclerview scrolling works.
Try adding android:nestedScrollingEnabled="false" to the recyclerview in your xml.
I'm using a RecyclerView inside the bottom sheet from google support library. I have noticed that sometimes bottom sheet intercepts touch events. I have not found any answers to this issue.
My screen looks like this
Code for the layout:
<android.support.design.widget.CoordinatorLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#color/appColor">
<ui.view.GMapView
android:id="#+id/gMapView"
android:layout_width="match_parent"
android:layout_height="match_parent"
/>
<FrameLayout
android:id="#+id/mBottomSheet"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="android.support.design.widget.BottomSheetBehavior"
app:behavior_peekHeight="160dp"
app:behavior_hideable="false"
android:fillViewport="true"
android:orientation="vertical"
android:background="#color/uiColor"
>
<android.support.v7.widget.RecyclerView
android:id="#+id/rvAddresses"
android:layout_width="match_parent"
android:layout_height="wrap_content"
/>
</FrameLayout>
</android.support.design.widget.CoordinatorLayout>
Thanks for any help!
For that you need to stop scrolling of recycler view, below is the solution for that,
android:nestedScrollingEnabled="true"
Hi I am a beginner for android and in my app I have to show SlidingPaneLayout at the right side but using my below code it's coming from left side.
Please help me.
How can I make it be at right side?
And second my requirement is my SlidingPaneLayout must be overlapped on Action bar but using my below xml code SlidingPaneLayout showing like my below image
please suggest me how can resolve this two problem
toolbar_layout:-
<?xml version="1.0" encoding="utf-8"?>
<android.support.v7.widget.Toolbar
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#color/ColorPrimary"
android:elevation="4dp"
>
</android.support.v7.widget.Toolbar>
activity_sliding:-
<android.support.v4.widget.SlidingPaneLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/SlidingPanel"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<LinearLayout
android:layout_width="240dp"
android:layout_height="match_parent"
android:layout_gravity="right">
<ListView
android:id="#+id/MenuList"
android:layout_width="match_parent"
android:layout_height="match_parent" >
</ListView>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="right"
android:background="#101010"
android:orientation="vertical" >
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#drawable/android_robot" />
</LinearLayout>
</android.support.v4.widget.SlidingPaneLayout>
main_layout:-
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<include
android:id="#+id/tool_bar"
layout="#layout/toolbar_layout">
</include>
<include
android:id="#+id/SlidingPanel"
layout="#layout/activity_sliding">
</include>
</LinearLayout>
In your manifest, add the following attribute to the opening <application> tag.
android:supportsRtl="true"
Then add this attribute to the opening SlidingPaneLayout tag in your layout.
android:layoutDirection="rtl"
And finally, move the tool_bar <include> element into the main content LinearLayout within the SlidingPaneLayout, and adjust the ImageView's height and weight.
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#101010"
android:orientation="vertical">
<include
android:id="#+id/tool_bar"
layout="#layout/toolbar_layout">
</include>
<ImageView
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:background="#drawable/android_robot" />
</LinearLayout>
Please note that the child Views of the SlidingPaneLayout will inherit the rtl layoutDirection. This may cause problems in child Views if their layout behavior is affected by the direction. For example, a horizontally-oriented LinearLayout will lay out its children starting from the right. This is easily remedied by setting android:layoutDirection="ltr" on the affected Views.
Also note that this example hard codes the direction in the layout. If you need to support both LTR and RTL layouts application-wide, you'll need to do this programmatically, accounting for the device's default direction.
Basically I am trying to do an animation for layout upon user on touch the button. Here is the explanation:
I have a base mapview and on top of that, I am trying to put a linear layout to shows news feed. And normally the linear layout will be collapsed with an expand button. So when user on touch and drag down the button, the linear layout will expand.
I have experienced with this using JQuery and Javascript. However, I have no idea how to do this in Android.
I have found some researches: Tutorial and I not sure how to implement it. And here is my layout.xml:
<android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent">
<FrameLayout
android:id="#+id/content_frame"
android:layout_width="match_parent"
android:layout_height="match_parent">
<com.esri.android.map.MapView
android:id="#+id/map"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
initExtent="21801.3, 25801.0, 33218.7, 44830.0">
</com.esri.android.map.MapView>
</FrameLayout>
<LinearLayout
android:id="#+id/navDrawerView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="start"
android:background="#FFFFFF"
android:orientation="vertical">
<ExpandableListView
android:id="#+id/nav_left_drawer"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#color/dimgrey"
android:choiceMode="singleChoice"
android:divider="#CCCCCC"
android:dividerHeight="0.5dp"
android:groupIndicator="#null">
</ExpandableListView>
</LinearLayout>
</android.support.v4.widget.DrawerLayout>
Any guides? Thanks in advance.
I want to implement simple view pager with control from outside view.
Here is mockup:
view_with_pager.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="match_parent" >
<View android:layout_width="match_parent"
android:layout_height="100dp"
android:background="#android:color/darker_gray"
android:id="#+id/control_header"
/>
<android.support.v4.view.ViewPager
android:id="#+id/pager"
android:layout_below="#+id/control_header"
android:layout_width="match_parent"
android:layout_height="match_parent" >
</android.support.v4.view.ViewPager>
</RelativeLayout>
My purpose is to control view pager only with control_header. Maybe there is any simple way to implement this feature. Thanks
P.S. I added horizontal scroll bar just for example. It could be any view controlled with fingers like ViewPager.