Pinterest long click on image and display button - android

I dont know how to achieve this effect on long click. Long click on image in pinterest android app. Three buttons sliding from red ring to left.
Edit: like this https://github.com/GnosisHub/GHContextMenu

Put 3 invisible ImageViews in the layout (these are the buttons). Set an onLongCLickListener on the larger ImageView. When the long click occurs, make the three buttons visible and animate them into position with ObjectAnimator or ViewPropertyAnimator. When you want to dismiss the buttons, animate them back to where they started and make them invisible again.
You will have to do some math and figure out how far to translate (move) the buttons in the X and Y directions, and it will be different for each button. I suggest placing the buttons where you want them to be when they are visible. When you want to animate them, calculate the difference between their current position and the center of the larger image (or from the touch location). Then you set translation X and translation Y to those values and animate them back to 0.

Related

Android animation spinning wheel with clickable circles

I was looking for animation which is like a spinning wheel which has circles and they are clickable. So two Actions one is Touch and fling to rotate the wheel second to click the circle. Circle values need to be dynamically assigned.
Please have a look at attached Click to view the sample image to help you visualize

Position Buttons in a Circle Around a Button

I want to place some (a variable number of!) buttons in a circle around a button in the center. It should be flexible enough that I can easily add one button more in the circle or remove one.
I'd also maybe like to add some animation in the future: the buttons should appear from one side and then circle around the button in the center.
It would be extremely easy to implement but android somehow doesn't allow to set absolute positions.
I mean I can easily calculate the positions where the buttons should be on the circle but how can I the place them there?
By the way, I don't want to add the buttons dynamically they are already on the view (wie View.INVISIBLE).
thanks for your help

Panoramic Background animation in Android

I have a panoramic background as a sky that i want to move from left to right and then from right to left to simulate a moving clouds animation as a screen background .
This should repeat indefinitely and after goin to the right most then return back to the left most..
I have tried the following:
Animation left = AnimationUtils.loadAnimation(MainActivity.this, com.icare.kids.R.anim.view_transition_out_right);
left.setRepeatCount(Animation.INFINITE);
left.setRepeatMode(Animation.REVERSE);
left.setDuration(3000);
findViewById(id.cloud).startAnimation(left);
But this does not seem to work... any solution for that ?
I am currently setting the image to an ImageView as follows:
<ImageView
android:id="#+id/cloud"
android:layout_width="3000dip"
android:layout_height="wrap_content"
android:layout_below="#id/topbar"
android:scaleType="matrix"
android:src="#drawable/bgpan" />
how can i set the image to the screen to start from the left most like this below, so to help in the panoramic animation effect:
The best solution that is efficient and fast on all phone ranges was to actually only animate the clouds while keeping the background static.
you can also add some variable to the speed that would add some randomization to the speed of the clouds so you don't get a monotonic looping.
Implementation details and solution was taken from this answer
One thing you might be able to try is using a Viewpager object with fake drag, where you continually re-add the background to new views that get generated, while disabling user input.
This will give the illusion of what you are trying to do.
So lets say you have 4 views in your adapter, each view contains just one of the image assets that fills the whole screen, and Viewpager's fake drag pans from View A to View B, draws View C and draws View D, then it fake drags from View B to View C and draws View A again
I'm curious if that would work for you

Touch move and resize layout

I see on the Galaxy Tab Email app or in My Files app (run on galaxy tab). The user can touch on a vertical line and move, the listview size change following user touch moving.
Like this video :
Galaxy_tab_email_app
I see that when user touch on the edge of the listview. A Vertical line appear. Like this image :
My question are :
How can the app appear the line with special red part on the image?
How the app resize the listview?
As my guess. The "line view" catch touch action, and when user move his finger, the app resize the listview (or listview's parent layout) size. But I don't know whether we have another way ?
Thank you and sorry because my english is not really well.
A guess, because I don't know how this app does it:
a. Create a custom view class and have properties which describe x,y, width, height etc. and a property for the y position to draw the pointer ("special bit in red").
x,y, width, height just describe the position of the bar. The pointer position is controlled by the listview depending on which item you select. Override the onDraw() method of the view to draw the bar. It's not difficult to draw shapes like this on a canvas.
http://www.stanford.edu/class/cs193a/06/
b. Override the onTouch() method of the class and capture drag actions on the bar. Use an Interface to register callbacks to classes which want to know when the bar is dragged, e.g. the listview on the left and the layout on the right.
Study the custom checkbox example here:
http://iserveandroid.blogspot.co.uk/

Implementing wheel shaped interface navigation tool

I am interested in implementing a user interface navigation control mechanism based on a wheel shaped device (or pie chart shaped or circle shaped) in my Android app.
I would like only half of the wheel to be visible at any time. That is, only the top half of the wheel should be visible since the bottom half should be below the border of the screen. The user can then turn the 'half wheel' to show options hidden by the screen border. The visible top half should then be divided into three parts like a pie chart, so the user can press either one of them to invoke some action. The following pic should explain (it is an example with seven (A-G) options).
http://imgur.com/lNu1F
The rotation itself should not be hard, but I am having a hard time understanding how to position the wheel so that half of it is outside the actual screen. I am thinking that loading the entire wheel (but hiding half of it) is best, since that is that graphics I have and it will also allow a smooth animation when the user swipes to show some other options. How can I make Android show the wheel in this way?
Also. Any comment on how to implement the 'swipe along the wheel shape' would be appreciated.
Thank you.
So for the wheel - you are hving trouble knowing how to position the wheel because you are using XML to align you objects and would like to use something like "Align Object Center To Bottom" which does not exist.
Here is one approach that might work fine: Mask the wheel view.
Is it possible to mask a View in android?
As for swipe the wheel along, I would register the wheel to take touche events, and use only the horizontal componenet of move events to apply to the rotation of the wheel. This setup is common in audio software that uses knobs.
However if you want to have it stick to the users finger in a more realistic fashion, you will need to do the following:
When the user first touches the wheel, calculate the angle from the wheel center to the finger.
Every time the finger moves, check the angle from the wheel center to the finger - and rotate the wheel the amount that the angle has changed from the last touch event.
The formula for getting the angle between two points is this:
Float angleInRadians = Math.atan2(point1.y-point2.y, point1.x-point2.x);

Categories

Resources