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

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).

Related

Blend two views in Android

Is it possible to blend two different views in different modes like Multiply, Add etc.
I have two views one is a RelativeLayout matching parent shape with a background image. Another one is ImageView (solid colored custom shape) inside the parent RelativeLayout.
I need to blend top ImageView to the background image in Multiply mode.
any kind of help would be appreciable.

Customising top of DialogFragment

Maybe some kind of simple question to those who are skilled at android layouts, but what is the best approach to draw smth like this (maybe what widget to use) for positioning rounded area which spreads out of top border of dialogFragment and is horizontally centered like this:
You will have to create a custom layout for Dialogs.
In this case, you have all the control you want for defining dialogs layout, same as for any view.
If heart icon is all you have, create an xml for white circle and use it as a background for the heart, set it to top of parent, center it horizontally.
As you will have exact height of circle, you can set half of it as top margin for the rest of the layout below to make circle look like a hump (as on screenshot).
You can use a 9 patch as the background of you dialog. Define the stretch areas and the content area and you should be good :
And for exemple use this 9 patch file:

Android layout vs. custom view

I want to generate the following for my Android application.
I tried to achieve this using RelativeLayout and some drawables (empty circle, filled circle, dotted line) I created using XML , but I am not even close to it. Is it the right way to generate such views with layouts. If so, is RelativeLayout is the way to go? Or should I create a custom view for that?
why are there 4 dots between the last item and the one before it, while the other have 3 dots?
anyway, i think you can achieve those results by having a listView with custom items.
each item would be shown as a relativeLayout with 2 imageViews (one below the other) and a textView on the right of the upper one.
the upper imageView would have the large dot (filled or not), with optional dots above it, and the imageView below would stretch its size according to the textView (align to its bottom plus add some more for extra small-dots) and have tiled dots as its background.
another approach would be to have a listView of textViews and an imageView on its left, and you draw the circles according to what the listView is currently showing (even while scrolling). it's much harder, but might be more precise.

Element positioning on android Layout grid-based

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.

Evenly spacing views within adjacent layouts

I'm working on the controls for a game, and require part of the control panel (gray in the figure below) to change dynamically, either showing a single canvas (left) or 5 buttons (right). The border between the lower-row views should always be positioned at exactly the same x-position as the border between the buttons on the upper row, as shown. At the same time, all twelve upper buttons should be scaled and distributed evenly.
I've considered several approaches, but as of yet none do all of what I want:
Using two LinearLayouts, one for each row of controls: reliably aligning the borders seems to be impossible, and replacing part of the layout is difficult at best.
Using a TableLayout: again, replacing a portion of the layout is difficult.
Using a RelativeLayout: resizing and aligning buttons independently of the screen size doesn't seem possible
Any suggestions for an alternative method, or on how to make one of the above approaches work? It would also be nice if there were some way to animate the change of views, i.e. sliding in the buttons from the left over the canvas. Thanks!
Interesting, I've done this several weeks ago. What I did is to make use of this property of View object: "Visibility". So that means at a fixed position, I can set any View to display on to, not depending on any type of Layout, it can be Visibility.GONE, Visibility.VISIBLE or Visibility.INVISIBLE.
In my app, I used RelativeLayout to set relative position to the right side TextView.
Give it a try :)
In order to close this question: I have solved the problem by writing a custom layout class that places and sizes the child views without heeding the measured size of the children. Effectively this gives me the behavior of a linear layout with layout weights, but is more deterministic with border placement.
A ViewAnimator is used to switch between the Canvas and the Buttons.

Categories

Resources