Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Are there any ways to put view slightly outside its parent layout?

It's a question about Android layouts. Here's what I eagerly want to get:

Layout

Dark-gray is a LinearLayout. Orange is layout X and then Green is a FrameLayout. I need to put Green outside its parent - layout X. The layout hierarchy described can't be changed. The only option is layout X - it could be whatever you want.

Any ideas?

like image 263
Andrey Agibalov Avatar asked May 03 '12 13:05

Andrey Agibalov


People also ask

How do I place a view at center of relative layout?

Below that, the layout_height=0 and layout_weight=1 attributes on the RelativeLayout cause it to take up all the remaining space. You can then center the button in the RelativeLayout . You can play with padding on the button to get it to the size you want.

How do I move one view to the top of another android?

Just in case if you want to place a view on top of a ButtonView then use this; android:elevation="7dp" for the view which needs to be placed on top of the button. Thanks. It worked, but also worked with 1dp up for me.

What is clipChildren in android?

android:clipChildren="false" allows each child to draw outside of its own bounds, within the parent. It doesn't allow children to draw outside of the parent itself. For that you would need to set android:clipChildren="false" on the grandparent (as well).

Which is better linear layout or relative layout?

Relativelayout is more effective than Linearlayout. It is a common misconception that using the basic layout structures leads to the most efficient layouts. However, each widget and layout you add to your application requires initialization, layout, and drawing.


1 Answers

Use -

android:clipChildren="false" android:clipToPadding="false" 

in every parent of your child view, then you put 'left margin' of your view to be negative,which will put your child view outside of parent view and will not even clip the view.

like image 93
Darpan Avatar answered Sep 22 '22 21:09

Darpan