Is it possible to somehow use Android's SlidingPaneLayout to do exactly what it does except from the opposite side?
I.e. I want to bezel swipe the right-hand side of the screen instead of the left-hand side to expose the second pane, and it slides in from the right instead of the left.
Ideally I'm looking for a way to do it with this layout, or a modification of it.
i think it is possible, just as this one did it from the bottom. check the difference between it and the original code, and you will know how to do it.
I have not tried it yet but i dont see why it would't work with something like this:
<android.support.v4.widget.SlidingPaneLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/sliding_pane_layout"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<fragment
android:id="#+id/content_pane"
android:name="package.DetailFragment"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:paddingLeft="16dp"
android:paddingRight="16dp"
android:layout_marginRight="60dp"
/>
<fragment
android:id="#+id/list_pane"
android:name="package.MyListFragment"
android:layout_width="300dp"
android:layout_height="match_parent"
android:layout_gravity="left"
/>
This way you would have the ListFragment on the right side.
Now which one you want to have opened first is up to you.
If you wanted to have the left side showing first you'd need to have something like this in the onCreate method of your MainActivity:
private SlidingPaneLayout mSlidingLayout;
mSlidingLayout = (SlidingPaneLayout) findViewById(R.id.sliding_pane_layout);
mSlidingLayout.setPanelSlideListener(new SliderListener());
mSlidingLayout.openPane();
even tho i'm late i hope this helps.
Related
I am looking for solution as on images bellow:
I need to have two resizable views in one layout.
User just needs to move separation line to the top (ScrolView B becames higher) or to the bottom (ScrolView A becames higher).
What is the best solution, which gives this behavior? I know that I can extends from ScrollView and override public boolean onTouchEvent(MotionEvent ev) and protected void onDraw(Canvas canvas), but may be there is more simple solution. I want to avoid calculation the math of moving. Thank you for any information.
If you want to solve this problem quickly, I suggest you use Split Pane Layout.
Usage :
<com.mobidevelop.spl.widget.SplitPaneLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:spl="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:id="#+id/splitPaneLayout"
android:layout_height="match_parent"
spl:splitterSize="12dp"
spl:orientation="vertical"
spl:splitterPosition="50%"
spl:splitterBackground="#781b23">
<ScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="5dp"
android:text="" />
</ScrollView>
<ScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="5dp"
android:text=""/>
</ScrollView>
</com.mobidevelop.spl.widget.SplitPaneLayout>
I solved your problem by creating two xmls for portrait and landscape mode. For portrait mode, i set the panel's orientation as vertical by adding spl:orientation="vertical" and for lanscape mode, i set the panel's orientation as horizontal by adding spl:orientation="horizontal".
After doing all this, I got the look like below.
Made this into an answer.
You basically want the split screen view from Android N. You could base your code off the open source implementation in SystemUI:
http://androidxref.com/7.1.1_r6/xref/frameworks/base/packages/SystemUI/src/com/android/systemui/stackdivider/DividerView.java
Along with this for the handle:
http://androidxref.com/7.1.1_r6/xref/frameworks/base/packages/SystemUI/src/com/android/systemui/stackdivider/DividerHandleView.java
You can throw away all code that has to do with stacks (which is the row of screenshots off different activities in your history), buss events and anything that has to do with running another activity, such as the code for Vsyncing between apps (mSurfaceFlingerOffsetMs).
It should leave you with quite small and easy to use classes.
I'm using floating action menu from yavski library and I tried to place it between 2 layout just like in this question:
But when I did it with fab - menu from yavski library, it did not work...
What should I do?
EDIT
I'm adding the button between header and "cardview"(link).
When I slide down in this and I use default library for fab, it works well (Button disappear and appear when slide up). But when I use the special one, it at start looks good, but when i slide down, instead of disappearing it slides down too...
And the last problem is, that when the button is clicked, it moves a bit upwards...
"A simple library marrying together FAB + ..."
I dont use this special library your mentioned but with the default one it works like this and if the guy that created the projected worked well it should too:
<android.support.design.widget.CoordinatorLayout
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:background="#color/white">
//Content
</LinearLayout>
<android.support.design.widget.FloatingActionButton
android:id="#+id/fab"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="16dp"
android:clickable="true"
android:onClick="process"
android:src="#drawable/ic_add"
app:layout_anchor="#id/ANCHOR_VIEW"
app:layout_anchorGravity="bottom|right|end"
app:backgroundTint="#color/accent"/>
</android.support.design.widget.CoordinatorLayout>
I'm trying to replicate this animation in Google's Play Newsstand app:
http://i.imgur.com/UuX1PRO.webm
I have a layout that looks something like this:
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingLeft="8dp"
android:paddingRight="8dp"
android:paddingTop="8dp"
android:orientation="vertical">
<LinearLayout
android:id="#+id/post"
android:layout_width="match_parent"
android:layout_height="250dp"
android:orientation="vertical">
... more layouts ...
</LinearLayout>
</LinearLayout>
How can expand the LinearLayout (with ID post) to expand to the screen? Note that the height of all posts is 250dp. When the post has expanded to the screen, I want to load the replies made to the post below it (comments section).
How can I create this animation/expand effect?
You need to use material design activity transition
See here
getWindow().setExitTransition(new Explode());
Check this
You need to use an Activity transition. The article view is in fact a different Activity. See the documentation: http://developer.android.com/training/material/animations.html#Transitions
You can simply add the following line of code to your Activity.onCreate();
this.requestWindowFeature(Window.FEATURE_NO_TITLE);
This is not exact solution but I think this page on developer site is exactly what you are looking for.
I am creating an app which does some tracking on a map. The tracking part works great inside my activity.
However, I want to have some kind of small overlay in the bottom right corner (like the minimalised video playback in the YouTube app) that stays there, even when I switch activities.
I have looked at this, but it's not really what I need. I don't need it to be moveable, and I think this is impossible to keep when switching activities.
Is there some kind of class that I can implement (Widget, Fragment, ...) that would fit my needs?
Thank you,
DebboR
This is a bit late and probably not relevant to you anymore, but maybe somebody else will find this helpful.
I don't think it's possible to switch activities and keep a certain view on screen. How I think this should be done is have a main activity with fragments that swap and in the activity's layout have a view overlay on top of the fragments container.
For example:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">
<!-- Container for the fragments -->
<FrameLayout
android:id="#+id/fragment_container"
android:layout_below="#id/toolbar"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
<!-- This view will overlay the fragment in the bottom right corner -->
<View
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
</RelativeLayout>
In Android, i noticed that you can have a fixed view on top of another. For example, when you open your browser, and tap the search box, a keyboard prompt pops up (on top of a listview). However, notice that you can still scroll up and down on the listview without the keyboard going away. Like:
would someone please explain (preferrably some sample code in addition) how this works?
What i'm trying to do is just have a custom listview that always has a floating navigation bar on top of the listview and also on the bottom of the list view (it's not actually a header/footer of the listview, it's more like a header/footer of the screen). It would be similar to the example i just described, where the user can interact with both the navigation bar as well as the listview "underneath" the nav bar.
I am somewhat new to Android development, so please be nice and provide a little bit of details if you would :) much thanks in advance!!
whoops. looks like someone had a similar issue:
Layout Layers? Z-Axis?
and this post http://android-developers.blogspot.com/2009/03/android-layout-tricks-3-optimize-by.html explains how FrameLayout works and also how works, which is an even better alternative.
FrameLayout lays object in a different Z-axis, so this is the solution i was looking for.
There are many ways to achieve that, the simpler i can think of is using linear layout :
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<LinearLayout
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:id="#+id/header">
//Here you add whatever you want in your "header"
</LinearLayout>
//create your listview
<ListView
android:id="#+id/content_list"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:cacheColorHint="#00000000"
android:layout_marginRight="10dip"
android:layout_marginLeft="10dip"
android:layout_marginTop="10dip"
android:layout_marginBottom="10dip"
android:scrollbars="none"
android:paddingBottom="5dp"
/>
<LinearLayout
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:id="#+id/footer">
//Here you add whatever you want in your "footer"
</LinearLayout>