android - slide relativelayout to the side with static buttons - java

In my Activity I have two RelativeLayouts and two buttons. When you first open the Activity, you have to see a RelativeLayout and the buttons. Then you can slide the RelativeLayout to the right or to the left. The buttons don't move. While sliding, you see the other RelativeLayout below. After a completed slide you see the full RelativeLayout that was below.
How can I implement this in my Android application (min SDK version 14)?
Code examples are a big plus, but not necessary. It is ok to show me the way :)

There's something called a navigation drawer which comes as a template in Android Studio. There are also many sliding menu libraries out there: https://android-arsenal.com/search?q=sliding specifically you might look at https://android-arsenal.com/details/1/1429
If you want to do it from scratch, it'll go something like: have one layout, say a Frame Layout as your root. Then you add the two Relative Layouts and your buttons. Then you need to implement a OnTouchListener in your activity and set on the relative layout that can slide: when the MotionEvent is ACTION_MOVE, you need to calculate the difference between the last touch event and the current touch event and then you can call translateX(dx) on the sliding relative layout where dx is the calculated difference.

Related

Make ViewPager swipable through external layout / from outside

In my application I have an activity thats layout is basicly following:
App layout
The red part is a viewpager with fragments.
The blue part is a layout with buttons that doesnt change with swipe on viewpager.
But i want that the viewpager is swipable (smoothly) in the hole green framed area. It should act like normal viewpager behavior.
I have absolutely no idea if that is even possible or not, but hope it does.
I thought that it is maybe possible with a gestureoverlay or something, but don't know how to apply the detected gesture on the viewpager.
Only detecting swipe and set current page is not what I want achieve.
(I'm writing in java)
If the height of the viewpager and buttons layout are somewhat fixed, here is a solution:
1, use a ConstraintLayout as the root container
2, make viewpager the same size as the root, set the viewpager's padding to some value say 8dp
3, place the buttons layout over the view pager, taking up the bottom half space(except for some margin), the viewpager should still respond to touch where there is no button
4, for fragments inside view pager, use a ConstraintLayout to put the content at the top half of the page
I think this is what you are looking for
Nested Action Bar Tabs(with ViewPager)
There's also a demo on Github: https://github.com/r3dm4n/NestedActionBarTabswithViewPagerDEMO
Let me know if it helped

How to change image during a scroll on Android

I'm a beginner on Android development and am trying to build my first app. I have an activity with a round target image and I'd like to make this image vanish at scroll down and display an another image instead that would snap to the toolBar (see the example images below).
I've researched this, but have only found information about using effects in apps where the image just vanishes. Perhaps, the Coordinator Layout could be useful here?
Initial state of my layout
After scrolling up, I want to change to a state like this.
To summarize, I have to :
- make my round Image go behind de ToolBar
- make the rectangular ImageView2 appear below the ToolBar
- Align my buttons (I guess it's about speed ? The one in the middle should go faster or something like that).
- Display new infos coming from below
You should surely use CoordinatorLayout. The point is that you should add custom behavior to your ImageView.
You can see an example here:
https://www.bignerdranch.com/blog/customizing-coordinatorlayouts-behavior/

Android: i need to do a menu like the image

i'm developing an application for android that is already done for IOS, is not big problem.
the thing is that my boss want it to be exactly the same, but one of the menus is the problem, is like a slide menu but with zoom and a background image, anyone have any idea how can i do this, i already google it but no results :(, a library would help.
here is a picture with the menu for IOS.
I don't think if it would be an effective solution but you can use a RelativeLayout.
Put the selection part behind in a LinearLayout then put a framelayout front to contain list fragments. This way you shouldn't use an action bar to have absolutely same looking with iOs version.
When someone clicks open button apply an animation to your framelayout. scale it by %75 and move it 25% in y coordinate and move it %50 in x coordinate. When buttons in your LinearLayout apply a reverse animation to your FrameLayout. If swap button clicked change your fragment with new one. You can also aply a transaction animation to your fragments.
I hope you know how to handle this stuff. If no I can do my best to code an example.
EDIT:
Don't forget to set your flame layout unclickable when you move it to right side.
https://github.com/SpecialCyCi/AndroidResideMenu
I think I found your answer. I came across this in a list of libraries it is 3.8 on the list https://github.com/Trinea/android-open-project/tree/master/English%20Version
Cheers!

Overlap a layout with viewPager

maybe you can help me. I want to use viewPager to overlap an other layout. so for example: I the first Fragment. On this Fragment is a picture, than I swipe to the right and then the second Fragment should just go over the first Fragment. It's like in the Android Youtube App in which you swipe from left to right and the settings and etc go over the main layout(like in the picture). Can you tell me what i have to do?
Thanks a lot, Vinzenz.
picture:
http://i.stack.imgur.com/CQ8gL.png
What you're asking for is actually not related to ViewPager. There is another layout you can use to implement the same navigation pane overlay: DrawerLayout link: http://developer.android.com/reference/android/support/v4/widget/DrawerLayout.html

flip board menu style for android

In my app,first activity if we click one button it should open sencond activity with transparence only at the end some part. So when we are in second activity, the content of first activity should visible some part. Its like exactly Flipboard style menu in android, in flip board if we click top red button we will get another screen in that we can visible previous screen at the bottom like this i need. If any one having ideas please share with me how to do flip board style menu.
Use Fragments for this problem that's what they are made for.
If you want to use API 8, I still recomment Fragments but then you need to use ActionBarSherlock it provides you with all features you need.

Categories

Resources