Overlap Views in layout of Android - android

I want to create layout having logo (small logo than screen) on the centre of the screen (horizontally & vertically) and on the top of the centred logo, I want to have a full screen (fill_parent) LinearLayout having ListView in it.
Want to keep ListView little transparent to keep my logo visible, looks like a watermark.
Can any one please tell me that what could be the XML for that?

for logo to be at centre use android:gravity="center" and also set opacity="translucent" and use it in a frame layout and also use overlay concept.
You can also check this other post.

Use Framelayout,
http://developer.android.com/guide/topics/ui/layout-objects.html
You can even use relative layout to overlap views.

Related

Create custom Layout with non-rectangle views and set clickListener for overlapping views in android

Is there any way to make following Layout in Android..? If yes please suggest how to make and how to set clickListener's of overlapping areas of Views...? i.e View 2's area overlaps 1's area and View 3's area overlaps 2'sand 4's area and so on others views overlaps..? If there is any android library to make non-rectangle buttons/Views also suggest.. Thanks.
Here is one way that this may work:
Use a rectangular ImageView for each shape. Make sure each shape is clickable.
Shape images will have a transparent portion where they fit together.
Use FrameLayout or some similar layout that will allow overlapping of Views. You will have to work with how each View overlaps.
Make the transparent portions un-clickable. See this Stack Overflow question and its accepted answer regarding one way to do this. (N.B. I have not tested this.) You should be able to work it so that clicks propagate downward to an underlying ImageView when a transparent region is clicked.
An alternate way would be just to have two views (left and right) and implement a View.OnTouchListener to determine where the click occurs by looking at adjoining pixels: their color and placement.
Good luck!

What is the best practise for padding or margin in Android?

I am relatively new to Android UI. I always get confuse in providing margin to different view like should i provide bottom margin or should i use top margin(to view below it). Also should i use RelativeLayout or LinearLayout if both can solve my problem.
Thanks
It Depends on your need
Linear Vs Relative
If you just want to stack your TextView and Button horizontally or vertically you should go with LinearLayout.
If you want to make a layout that is more complex for example you can have an ImageView covering all of the screen and Button over the ImageView or if you want your layout elements to be stack on corners or at bottom, RelativeLayout is your Guy.
Top margin vs Bottom Margin
It doesn't make much a difference its a personal preference, I Use margin-bottom on first element rather than margin-top for second element.
One noticeable difference is when you are working with Show layout bounds during development. You can see here those pink coloration indicate that it is using margin on its view while padding has no coloration. Recently I prefer to use padding if applicable with my requirements as it seems more cleaner to inspect UI when Show layout bounds is enabled from Developer option.
The image is not mine and was just use as a quick sample.
If both Linear and RelativeLayout will solve your layout, then you should use Linear as it is faster to render.
With regards to top vs. bottom Margin. That's entirely your preference and how you want to think about the elements. Does Item A always sit 40dp above the next item or does Item B always sit 40dp below the previous item?

Want to place multiple hidden buttons over a background image?

Not able to set hidden buttons over the background image, want to place hidden buttons exactly over the words (i.e total 5 hidden buttons over background image). Help!.
Try to use AbsoluteLayout or RelativeLayout with button alpha 0%.
Also consider doing it in another way. It may go wrong on different screen sizes and orienantions.
You should try to use RelativeLayout to do this (if you want to create a custom view, eg in corners). RelativeLayout is a Layout where the positions of the children can be described in relation to each other or to the parent.
See this link: RelativeLayout
See the example here and information from here

How to arrange overlapping buttons in Android xml layout?

In my layout there are three buttons and want to set PNG images for the buttons background but, the buttons overlap a little bit on one another. I want to how arrange the button in my layout. Which layout would be better for me in this context. You can see image of the layout below, that I want to develop. Please help me in this respect; your help would be cordially appreciated.
You could put all 3 buttons in a container, for example a RelativeLayout.
The center button (big one) would be aligned as "centerHorizontal=true". The left and right buttons would be aligned as "alignParentLeft=true", and respectively "alignParentRight=true". Plus, both buttons to have some margins on top.
I believe you can achieve the desired effect.
At least you can use AbstractLayout,although it is deprecated.

ANDROID, what layout elements should I use?

I need to make an android layout like this one.
tile background all over the screen.
top menu which, overlays the background ( note the shadow ).
some sort of a table with text options, maybe pictures, which can be scrolled up and down.
bottom menu, which appears by sliding up after a menu button is hit.
What kind of layout elements do you think I should use for that?
Thanks!
I think you should first learn about the Android Layout and XML layout design, then you can easily prepare this layout as well.
Relative Layout will be the better layout as compare to other layouts like Linear Layout and Table Layout.
To display middle part that is showing textual description may contains ListView (ListView because as you have mentioned Text Options should scroll up and down), but it depends on your requirement.
The RelativeLayout is the most flexible, and I think you can make all this with a minimal hierarchy view depth.
My approach would be to use a RelativeLayout. The Top Menu bar could be a custom class which extends a LinearLayout and this can be used in the RelativeLayout (in fact in any screen you have to provide UI consistency). Similarly, the bottom menu would be a custom control containing the appropriate animations. The rest of the screen would be contained in a ScrollView, possibly containing a TableLayout. I have something very similar using a MapView in the main screen and it works fine.

Categories

Resources