I'm trying to make my app be able to draw with your finger like Snapchat on part of the screen but not the whole thing? Every example I have seen of drawing is just an app that turns your whole screen into the canvas and does nothing else but I'm having a hard time implementing it as just part of my app. So as well as how to just choose a section of the screen as the canvas is it possible to make another activity just like the examples that extends view that I include or can I put everything in MainActivity.java?
Yes, there is. You can create a fragment, or as many as you want, and them place the fragment(s) wherever you want in the activity by using some of the available layouts.
For example, you can use a relative layout. You can add a frame layout to the relative layout and align it in the activity where you want, set its size, and then add the fragment to it. You can check this link to learn about fragments and their usage if you don't know them.
Related
I have been trying to find a way to get this done but keep running into issues.
I want to be able to have a map in a frame (it does not necessarily have to be a FrameLayout, i just want it framed so it only takes up 1/2 or 2/3 the screen) ontop of my current layout and to have the current activity still displayed behind it.
In a perfect world, i would like to attach this view to a button and animation so clicking the button causes this view to slide in from offscreen left and settle in the center of my current activity, while still being fully clickable and and the map being useable (can zoom, click, etc.)
I have tried doing this with a fragment, but the issue is that the Activity i am working in is already extending another class that is absolutely necessary, so i can not extend Fragment or FragmentActivity, so i cant use fragments (unless i am missing a work around to achieve this.)
The same goes for MapActivity and MapView, cant extend the MapActivity class so cant use MapView.
Any time i try to inflate a map view or anything i get runtime errors because my activity does not extend the pertinent class. Is there a work around for this?
Does anyone have a suggestion as to how i can get this map to display the way i am looking for?
This is easily achieved in iOS but i cant seem to figure it out in Android.
Thank you in advance
EDIT
I am not looking for code, unless you have a specific example in which case obviously code is very helpful, but i am looking for an idea as to how to achieve this -- a push in the right direction if you will -- so i can write the code myself.
Solved this by adding a frame layout to my "Main" activity. That frame layout's class was set to my Map class. The Map class extended FragmentActivity and its contentView is set to my map_fragment.xml. The map_fragment.xml contains only a fragment and that fragments name is set to com.google.android.....SupportMapFragment.
After setting up my project in this way as well as setting up the correct screen layouts and dimensions for sizing purposes as well as defining a GoogleMap in my Map class, i was able to display a fully usable and interactive map over my "Main" activity.
I overrode some Activity transition animations to the Map class and got my project working 100% how i want it to.
I didnt ask for code, so i will not supply any code, but this process is pretty straight-forward if you follow the same process as i have described above.
I already had buttons on my original app but now I created an image on canvas in Android and have combined the two together, however I cannot view the buttons on the page but can only see the image on the page. These buttons were designed to move to different pages. Does anyone know how this can be done. I have also used extend Activity instead of View/SurfaceView is that ok or will that be causing the problem?
Thanks.
I'm working on implementing a UI for an Android application, and I wanted to ask if there is already something in the native widgets to accomplish most of what I'm trying to do.
The application that I'm working on performs 15 different tasks that can be divided into 3 different groups. (5 tasks per group) I have 18 icon images (3 for the groups and 15 for the individual tasks) and I want to be able to panel these icons (starting with the groups) like this:
I want the next icon visible below and above (if further down than the first icon) and swipe to go to the next icon
Once an icon is clicked, the panels slide to the side, exposing the next layer (the specific 5 tasks for the selected group) with the selected group still visible on the side:
From there, the user can tell at a glance what group they are in, what the current, next and previous selectable tasks are, and that by swiping right, they can get back to the group selection.
What types of widgets would I need to look into in order to accomplish something like this? Are there already pre-built lists to do these activities?
Thanks for any guidance!
You can get close with a LinearLayout of ImageView widgets and a ScrollView (vertical) or HorizontalScrollView. However, it will not give you the desired "centered image with bits of the previous/next images" effect -- it will be wherever the user positions it.
You can get close with a Gallery. However, it will not give you the vertical orientation, and it will always give you a fixed set of full options to the sides, not the partial images that you seek.
If it's gotta be the way you describe it, you'll have to roll it yourself. Gestures and animations should give you the desired effect.
Have you taken a look at ViewFlipper? http://developer.android.com/reference/android/widget/ViewFlipper.html This will give the side by side effect but you will have to make custom views for each group to populate it with the proper icons.
I'd use a ListActivity for the first 3 top level items. This won't give you the auto centering effect that you'll probably want, but you should be able to look at the Gallery source code, which can be found here, and make some modifications to the ListActivity so that it autocenters.
For the next items, I'd add an onClick and a GestureListener so you can navigate to another activity with another list view. Since you know where you came from (add some data to your Intent) you can set the color rectangle on the left so that it appears that you have just swiped the whole view left.
If you need to customize the animation, you can call this:
overridePendingTransition(R.anim.slide_left_entry, R.anim.slide_left_exit);
To make the yellow icon look good as it animates to the left, I'd change the list bounds (on the first activity) to have no margins, and change the yellow icon to have square right edges - This will make the small yellow rectangle on the next activity appear to be part of the first activity.
It should be relatively easy to mock this up to see if it's going to work properly for you.
Good luck!
EDIT: Ok, so I've made a basic project that does most of what you want.
here is the link to the eclipse project file. I was going to put the source up here, but there's a bit much to display.
What you still have to do:
Tweak animation
Configure the layer lists to display the correct colors
Add information to the top level intent for the sub-activity to be able to configure itself.
Quite a few other small things.
I think I've got the main stuff done. I've also added the gesture listener I talked about, although re-reading your question, you actually didn't ask for that. Since it's cool, I left it in.
Good Luck once again!!
Have you thought of launching Activities with different view configurations? You can switch from one activity to another with a gesture and you can Animate the views. What your UI looks like to me is a bunch of screens with affordances that show the other screens. So one Activity per screen maybe the same in different configurations or something like that.
I am developing an application in which each Activity has a View which shows a PNG Image, followed by a TextView, an EditText and other views... The Activity's Content View is inflated using an XML layout file.
Depending on which options the user chooses/how he interacts with the application, I want to dynamically draw onto the PNG Image.
Is this possible? If so, how? If not, how else could I go about it? Could you point me towards a tutorial on this sort of thing?
Many thanks
Darius
Is there a way to absolutely position an UI element on Android so that it is located outside an Activity? For example: can you create a fullscreen ImageView simply by moving/resizing an ImageView inside an existing regular Activity instead of creating a new fullscreen activity?
EDIT: Re-reading my question I see I wasn't very clear about what I'm trying to accomplish. I'd like to temporarily extend an element to cover the notification bar at the top of the screen. I need to create a semitranslucent fullscreen overlay but since translucent activities cannot cover the notification bar I'm trying to find out if it's possible for an element to break out of activity's bounds and resize itself to fill the whole screen, top to bottom.
That depends on what specifically you're trying to do. You can easily draw graphics offscreen and then animate their movement into the screen using a Canvas, but this is more for graphics than for user-interface elements. For moving buttons or such, you can have a look at another question here "How to position View off-screen". I gave a brief intro on how to use canvases, but the questioner found another way to do it using a customised linear layout and view animations.
Lastly, if you're trying to zoom and scroll an image around that's larger than the ImageView, there are some sources you can look at for inspiration. I realies this isn't strictly your question, but I'm including it since it might be linked to what you're thinking about. You can find a tutorial on Anddev.org and an open source app on Google Code.