creating a custom image based layout on android - android

Is it possible to create a layout based on (background) images? For example, there is well know app called Appie that uses this picture as a homescreen:
I might be able to recreate the layout with a TableLayout, but this will be difficult to get it perfectly aligned with the buttons in the image. The default layout options make it very difficult, or maybe impossible, to allow for selection of the buttons on the image (especially when the buttons are in an arc-path).
Can anyone tell me how this is done?

I had some issues positioning a badge on the corner of a view. You can check my solved question:
Positioning a badge bubble on the left upper side of a button
About how it can be done. I would do it with a RelativeLayout and TableLayout as you mentioned, but to be completely sure, you can use apktool to see how the xml are done but it might be ilegal to do it.

Related

How can I overlap TextViews?

I've just started an android development course and we had an assignment. I should create a simple birthday card app. That was not a problem until I started looking around and saw this picture.
I know 2 ways to achieve this. First, child TextViews in LinearLayout which might not allow to stack them in that sort of leaning/analog fashion. Second, and possible the simplest way I can think of, is to crop the text part and use it as an ImageView on top of the background.
I'm trying to challenge myself to create those bubbles using the code and I was wondering if somebody could help me do it.
Thanks!
If you want to recreate the stack of words on the right, you cannot use a LinearLayout. The LinearLayout won't allow you to overlap the TextViews. You'll have to use a RelativeLayout or ConstraintLayout. Each TextView should have a background image for the color and speckle design, you'll control how big the background is with TextView's padding and margin attributes. Finally you can tilt / rotate each TextView with the rotate attribute.
Don't get too ambitious with your early homework assignments, you wouldn't want to get frustrated and lose interest!

Replacing a View in Android onClick

I'm still kind of new to android. I'm writing a Tic Tac Toe game as a bit of practice. I'm trying to figure out how to replace views when I click a button. I have 9 buttons in a GridView. When a user clicks one, I want that to change to a non-clickable TextView and back to Button when a user click's the reset Button at the bottom of the screen.. I use a flag to keep track of player's turn so it'll know whether or not place an x or o. Is this even possible or am I stretching here?
You'll soon find that there are really not that many things that are stretching it for Android.
This is certainly possible. For each grid in your GridView, put in two elements - the Button, and the TextView. Change the visibility of each. In other words, you don't actually replace one with the other - you just hide one, and show the other.
So you'd have two items like this:
<Button ... android:visibility="invisible"/>
<TextView ... android:visibility="visibile"/>
And have both of these match_parent, so that they fill each grid and are basically both on top of each other.
To change the visibility in the code:
button1.setVisibility(View.INVISIBLE);
textView1.setVisibility(View.VISIBLE);
I'm trying to give you as little actual code as possible so you play with this and write it yourself, but this should definitely put you in the right direction. Let me know if you need more guidance though.
You can do it two different ways
You can put both a button and a textview in each grid and interchange their visibility when you click on the button. For this, you can set the button and textview properties from the xml layout and you dont have to do much programatically
You can use a button alone and just change the look by changing the background drawable at runtime. Then you can make it unclickable by disabling it or changing its focusable property to false
You can even use an imageview and just change the drawable src and disable it on user click. Android is quite flexible and this is not even a stretch. If you give a little more detail of the specifics you want to achieve, I could advise which solution will be best fit

Sliding drawer looks like semi circle

Android provides the SlidingDrawer by default looks like below image -
Image http://www.gru.at/android/wp-content/uploads/2010/09/s_open.png
Can we customize this SlidingDrawer looks like semi-circle type with buttons included. For, example take a look at below image -
Anyone done the SlidingDrawer like above one. I've googled it. Didn't get any nice solution for this. Anyone has idea/example blog for this?
So make sure you have Gimp and 9-Patch at the ready for a lot of trial and error...
Then what you wanna do is...
Add suitable layout to hold buttons where the current ImageView Handle is, like Horizontal LinearLayout or RelativeLayout
Cut the id of the current ImageView Handle and add it to this new Layout you just added
add your buttons to the LinearLayout/RelativeLayout (you can test it now, the buttons and the handle should all slide open at the same time)
Now add Button listeners for each of the buttons
Set the SlidingDrawer to android:allowSingleTap = "false" (tit for tat, you cant have the single tap option anymore, just the slide)
Use a ButtonSelector.xml to have different layouts for buttons be pressed or not pressed.
This is the hard part. Edit the drawables for the buttons, and handle so that they will fit together nicely if the screen is huge, small, landscape, portrait. I recommend using 9-Patch in conjunction with Gimp.
Pat yourself on the back because you now have a totally sweet custom sliding drawer.
Make sure you post pictures and state any problems or issues you ran into as I have never fully implemented this, but I did get to step 6 to make sure it was possible.
Last but not least, Good Luck...
Thanks for RelativeLayout and FrameLayout These layouts makes my requirement comportable with what i need. I've done like below steps -
First, i've splitted the full image into three pieces. And, merge these images with FrameLayout And, gave onclickListner to my center of image(Because, it was contain that arrow marks up/down)
And, i've used the Animation for just to open that View as SlidingDrawer
These steps helps me lot.

Android horizontal scroll programmatically

In Android, I want to create a particular control which may require to set the location of a component by fixed coordinates.
This is what I want to do. These screenshot are taken from a swing application of mine. I want to clone the buttons on top and their behaviour, into an android application. Basically if there are too many buttons in the menubar, left and/or right arrows appear, and clicking on them will scroll horizontally to access the hidden buttons.
I need to be able to set the coordinates of an horizontal linear layout inside another one, and even to set negative coordinates in order to scroll on the right.
I'm doing this using a null layout in swing. Can I achieve this with Android ?
I'm not sure if an HorizontalScrollView can do this. Could someone point out a good tutorial or something related to what I'd like to do.
I think a HorizontalScrollView can achieve what you intend to do with your Menu Bar. You don't need these "scroll" Buttons, because a user can swipe the menu.
You can nest LinearLayouts together, however you want. if you want to control their flow try to apply margins to them. You can set fixed Coordinates in an AbsoluteLayout, too.
Consider using a gallery? If not gallery, then a child or cousin of it. As far as I know, there is no ViewParent that will allow what your are shooting for.
Hope that helped ~Aedon

Android clickable panel UI

I am currently working on an Android app, I have completed all the 'hard stuff', such as getting my database working, and so on. Now I need to make the UI look decent.
I would like to make something that has a 'frame' layout that is clickable. You would click on a 'frame' to find out more information, a bit like the Amazon app.
If anyone has any ideas, tutorials or good links, I would be very grateful.
Thanks in advance.
Take a look at Gallery. It's built in to Android and does what I think you're looking for (at least, it describes the Amazon app's UI; since FrameLayout has a very explicit meaning in Android that is not at all what you're talking about, I ignored that part).
EDIT: A screenshot would have been helpful but I think you're actually talking about a simple list-like view.
Oh. That's either a ListView, or more likely just a vertical LinearLayout inside a ScrollView. I can tell you what I'd do: Each item in the LinearLayout would have a background set, with a width of match_parent and a height of wrap_content, using a 9patch with the right-pointing arrow inside it. I'd also define an identical but blue-highlighted version of the image for the pressed state and use a state drawable XML to let it know which to use. Then I'd just bind an onClick listener for each item I wanted to fire off a click action on.

Categories

Resources