Does Android layouts work like HTML/CSS layouts? - android

I have created a button in Photoshop and I have split them into 3 images. Now I want to put those images into android button. I know how to create layouts in android but the point I am missing is how can I make them fluid?
So there is a button for which I have 3 images.
I now want to ask how can I use these images for a <Button> tag so it expands repeating the middle one. Do I need to create style here and then put background="#drawable/three_button_style" or there is something I really need to know?
Is the same going to be true for ListView? I got a list view and images for top, middle and bottom so can I create a ListView of 3 images repeating the middle one?

For scaling items Android usually uses 9-patch, which behaves something like your example but also vertically. Here's a link to the 9-patch tool that can be used to draw these:
http://developer.android.com/guide/developing/tools/draw9patch.html

Related

Is there a way to repeat the image multiple times as tiles in android?

I want to make a floor like effect using a single image in android, somethig lake the Tile effect in GIMP. For example have a square already on my app and then create an image that has that square a lot of thimesso that it looks at the end something like this
Create a GridLayout and put an image in each element.
Here's a tutorial that explains the concept of how to use images. You can of course refer to the same image multiple times, and adjust the borders and spacing to meet your needs.
You can use the RecyclerView with GridLayoutManager as your layout.

Custom View with Three Circle Images Android

I wanna create a custom view with three circle images view using native android. Now I can create one circle image view using CircleImageView from hdodenhof. I wonder if anyone can tell me which way is better to put three circles like the following pic. Thanks.
You could, as you suggest, build a custom view from three CircleImageViews and an appropriate layout.
However, I suspect that you would have difficulty getting the circles to layout in the manner shown in your sample.
I'm fairly certain that this would be next to impossible with RelativeLayout, though you may be able to accomplish this with creative use of one of the other layouts.
Other options include:
Merge the 3 images in a graphics editor, and then create a custom view using that.
Merge the 3 images as above, and just use it in an ImageView
Create a custom view from a Canvas, and draw the images yourself, at the appropriate locations.
Which you do will probably depend on how you want the custom control to behave, including:
is any part of it to be animated?
are the 3 circles to be separately clickable?

auto layout in android

Good day, i am developing an android app which generates comic like albums, i need to fit this comic to any screen width but i have trouble doing it coz of the layouts, its very odd and doesn't seem to be aligned with one another, here :
those boxe are composed of FrameLayouts which contains and ImageView (back), the frame which is a PNG (middle) and a TextView on top of the frame image. So basically the design is very complex and odd, I've heard that there is a way to make this fit automatically on every screen on IOS, they called it auto layout i guess. Is there a counter part of this on android? Thank you.
Try using a GridLayout. You should be able to achieve what you're trying to do. There's a good blog post here.

How to create round shape image using android?

I am having four piece of image.
Here I attached one sample image.
How can I create the round shaped image using these type of images?
Which layout is best for creating the UI for android?
Thanks in advance.
are you talking about something like this..
http://www.baijs.nl/tinycircleslider/
And for designing the UI for Android is depends on our requirement.it means whether you want to design something looks like rows and columns then GridLayout and tableLayout will be better,depends on requirement and look the layout will changes once try it your self and choose the best suited for your applicaiton.All the best Mate
inside relative layout add four imageview with attrs ParentTop, ParentRight, ParentBottom and ParentLeft. every image is rectangular with transparent extra area.
i can understand it is little hard to visualize on first attempt.
now come to click area. so a runtime decision about ignore transparent area click will be right thing.
more tricky way will be manage flags for all listeners and if two listener get calls its transparent area .

Android Creating Custom Buttons

I have quite a few buttons in my application, they vary in sizes based on the text inside. I want to customize the buttons but I am not sure if I should use
A) Ninepatch pngs
B) Android xml created
C) Photoshop pngs
I want the buttons to scale nicely and therefore not look distorted based on screen size. What are the positives and negatives of the above methods? Is there an ideal way to go about this?
It depends on what they should look like. Rounded corners? Complicated images? Drop shadows? Plain colors?
If you want simple buttons that are monotone in color, xml drawables are the best solution. You can do rounded corners through xml, so if plain is what you are looking for this is the best option.
If you are working with an image, then a 9 patch is the way to go. Play around with the draw9patch tool that comes with the sdk to get the hang of it. You also don't necessarily only need to leave the corners in tack, sometimes you may want to break up the resizable area depending on the image.
PNGs are the last resort as they are the least flexible of the 3 options.
By the way, you should also consider using a state list for all of your buttons, regardless of how you implement the drawable that the button uses. See the link below:
http://developer.android.com/guide/topics/resources/drawable-resource.html#StateList

Categories

Resources