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/
Related
I need to achieve this UI in Android. When sliding right, it increases the percentage and the blue view increases in both ways, and when sliding left it decreases it, both view and percentage in TextView. Any ideas I can do that? Thanks
enter image description here
I used the library that has almost the same design that you need. If it's not convenient for you can check implementation and create your own custom view. Basically you would need to track touch events in OnTouchListener and draw on Canvas with coordinates that you got from OnTouch.
I'm new to Android programming. I'm working on an app that requires some form of animation. Please take a look at
I want an animation where a scroll rolls down at the top with this text in it as soon as this activity starts & rolls up when the connect button is pressed. I have no clue where or how to begin with the animation. Any kind of links to tutorials or posts on StackOverflow will be of much help.
Thank you for your time!
Since your question is really really broad, I'll give you a broad answer as well.
I think by "scrolling animation" you mean an animation in which a black (or some other color) area slowly covers up/reveals the screen. I don't know why would this look cool, but whatever.
Step 1
Create an animation XML file. In this file, you would specify that the view should translate downwards by x pixels where x is the height of the screen. And create another animation file. This time, specify that it should translate upwards.
If you need help creating XML view animations, have a look here
Now you have two animations - move upwards and downwards.
Step 2
Okay, now you should create a custom view. You can start by doing this:
public class ScrollingView extends View {
}
And implement all the required constructors.
Override onDraw like this:
cover the whole view with black or some other color
draw the scroll at the top of the view. The scroll should be an image like this one:
If you don't like using an image, you can draw it yourself, using code!
You can get help on this here
Step 3
In onCreate of your activity, create a ScrollingView. This view should be as wide as the screen and as high as the screen. Position the view at (0, 0) and bring it to front so that it covers up the whole screen.
Step 4
Next, apply the animation you created in step 1 to the scrolling view.
I am making a game of Gomoku in Android. I have made a grid out with drawLine(): http://i.stack.imgur.com/Mm4HZ.jpg
I am now trying to make the app detect presses within the small squares. I was thinking perhaps I could generate buttons to be in the center of each square. I have the height/width of a single square saved to varibles so getting the center points to each square shoudln't be difficult. However, how should I dynamically generate buttons where each corresponds to a certain [i][j] in a 10 * 10 matrix where the field data is stored?
You can register an onClickEvent with any view in android. What you want is an invisible view the area of the places were you want click events. I suggest using buttons or something visual so that you can see where the areas are, register the click events for each view, then hide the views so that they are invisible.
I wan't to develop game named "Balda".
I have a 2d grid of imageviews (or buttons, maybe).
User should be able move his finger on the grid, and app should know wich images in grid was touched in this move.So, in the picture below is what I'm trying to achieve. A - is start point where user pressed on screen. B is end point where finger leaves the screen. And I need to know what images were touched (There are blue in the picture).
I know that I can do something like this. But I think that this is a wrong solution, because It contradicts the principle of giving functionality by responsibilitys.
I think that it is responsibility of the imageView to know when finger enters its borders and when it is leaving its borders.
I thought, that this would be in android API. And it has MotionEvent like EVENT_HOVER_ENTER and EVENT_HOVER_LEAVE but it's not working with finger. After finger is pressed on some View it will recieve all other MotionEvents, if I get it right.
I think that this is wrong. What can I do to get this functionality? Maybe I could create some custom listeners and custom Views, that supports them?
I think your requirement is slightly similar to custom gridview.
You can try below steps-
1)Create Custom view
2)Attach TouchListener to it.
3)Divide this view into 4*3 matrix.
4)Map your images to this 4*3 matrix
5)Write a function which gives the cell number respective toTouched Co-ordinates
6)After getting cell number;get the mapped image for that cell number
7)Put this image in arraylist
8)When user lifts his finger you will get arraylist of touched images(do whatever you want with it).
9)Remember to put this custom view in your activity
Tell me,if you have any doubt or concern
In my application I implemented a Gallery like view using GridView. I want to change the number of columns in GridView manually as per user's choice. I can change it by providing any button or menu option. I want to do same thing with Zoom / Pinch operation like, if some one tries to zoom the GridView, it should reduce the number of columns and increase the same if tries to Pinch. To achieve this I tried overriding onTouch event but its neither smooth nor as desired. If any one knows or have any idea of how to achieve this please let me know.
This won't be easy.
First I would try this:
Put a plain View on top of the GridView (i.e. this View is at the same position as GridView and has the same width and height).
Override the onTouchEvent of this plain View. If you detect a Pinch Zoom do the special handling (changing the GridView's columns). If you don't detect a Pinch Zoom, let the onTouchEvent return false (not handled) letting the touch-events bubble down to the underlying GridView.
The trick is in recognizing a Pinch Zoom correctly and not messing up the default touch behavior of the GridView.