Element positioning on android Layout grid-based - android

I've drawn a background (using photoshop) with a circle forming a 4x4 grid. I would like to position some element (like a little circle image/button) inside the circle accurately. How can I do this? Should I use a particular layout? It's a background for a grid-based game.
Background (It will be more accurate): http://uptiki.altervista.org/viewer.php?file=spojjb30484tjasmqbo2.png

You should split the background into 2 parts.
1. A background with whatever fancy image it has to the gridview.
2. Indiviudual cells in the gridview has it's own background that can be circle or square or different colored circles to show selected cell, etc.

Related

How do I create a layout w/ a white background, grey border with a triangle arrow - Android

How would I replicate this in Android, my general instinct would be to create a regular layout w/ a border, then have 2 layouts that contain a triangle (one the same color as the border + one that's slightly smaller but white and overlap the two), idk if there's an easier way to do that:
You can use 9patch to achieve something like you wanted.
The Draw 9-patch tool is a WYSIWYG editor that allows you to create
bitmap images that automatically resize to accommodate the contents of
the view and the size of the screen. Selected parts of the image are
scaled horizontally or vertically based indicators drawn within the
image.
A complete guideline can be found here : http://developer.android.com/tools/help/draw9patch.html
The easiest way to reach this, is to set the layout background to that image.
background="#drawable/template"
Probably you want to have the area out of the "bubble" transparent, so you will need to save it as PNG.

Two rounded seekbars overlay each other

I need to place two rounded seekbars on the same circle area (like on the screenshot). I use SeekArc library. But even if I use only half of the circle for seekbar, view takes the same as full circle. Each SeekBar on the screenshot takes the whole screen and one of them is not active because it's under other one.
If I try to hardcode width then height changes automatically. Is there any way to leave the same height but crop not needed space around widget? Or any other way to place two SeekBard on the circle area?

android relativelayout xml background image with many relative textviews (dynamic clock)

I want to make something like an analog clock with a background image and many TextViews.
The TextViews will get the data programmatically, which is working. But my problem is the design. How can I set the TextView's position in relation to the background image? It should work on different screen sizes ...
Is there maybe a way to take the middle of the screen and set a margin to the center for each of them, like I foretold with the arrow in the picture?

Android: creating custom 2D avatar

I am creating an app that allows a user to build a custom 2D avatar by specifying things like shoes, socks, skin color, etc...
Currently my solution has been to create a .PNG of each item and then to 'stack' them all on top of each other in a RelativeLayout. So for example, I create an ImageView of two shoes and align the ImageView to the center of the relative layout and the bottom of the Relative Layout. Next I 'stack' the bottom edge of the socks to the top edge of the shoe. And on and on.
This method works, but I feel like I don't have much control over where the parts sit and would much rather be able to calculate the x,y coordinates at run time and place the images that way. For instance, this works well if all of the ImageViews are stacked, but if I need to place one ImageView 10 pixels below the top edge of another ImageView I can't do it (or at least I haven't figured out how yet).
I am looking for a solution that will allow me to control the x,y position of ImageViews and allow ImageView to be offset from each other.
If you'd rather place the images by x,y coordinates, then you should consider using a single view and simply drawing the images on top. See this doc on custom drawing. You'll find drawBitmap and some of its overloads useful.

Android tabbar, which active item overlaps adjacent items (see image)

I need to make tabbar of the following desigh:
Its active item overlaps adjacent items.
My problem is that I don't know how to make different tabs overlap each other (as far as I know, it isn't possible to change z-order of views programmatically). How to do it?
P.S. By the way, that is not necessary for me to use particularly tabbar. That can be, for example, 3 buttons in horizontal linear layout or any other combination of views which allows to make tabbar functionality.
I made this one by creating 3 buttons with rounded angles, big container with rounded angles (only top of it is displayed on my image) and linear layout behing above mentioned views, which fills space between bottom angles of any 2 adjacent buttons.
This linear layout consists of 4 parts which change its background color to appropriate one dynamically in buttons' onclicklistener (same for 3 buttons).
Shadows are implemented via gradient of black (with different alpha) in button's background drawables (which are layer-list with 3 shape items - background shape, padded shadow shape and again padded background shape).

Categories

Resources