I have set the parent linear layout of a round corner effect. but the bottom rectangle corner of the embedded linear layout can't be clipped.
I have set the android:clipChildren="true" to the parent linear layout. and it still not work.
Related
When I have buttons on the xml page, moving or enlarging them is very frustrating because i can't make them go where I want. Sometimes if I want to move something to the right it'll instead move somewhere else randomly or nothing will happen. Is this because of the relativelayout? And what's the difference between relative and linear layouts?
1) RelativeLayout - Views inside a RelativeLayout are relative to the position of other children in the RelativeLayout.
2) LinearLayout - Views inside the LinearLayout are in a linear pattern either horizontal or vertical.
I personally rarely use RelativeLayout unless it is inside a LinearLayout and I need to position a single view in an odd place against the horizontal or vertical aspect of LinearLayout. RelativeLayout can be confusing because if you change the dimensions of one view in it you have to adjust the dimensions of all other views that are relative to that view.
If I try to center the current view vertically within its parent. Which one should I use?
I saw TextViews use gravity="center_vertical" and ImageViews uselayout_centerVertical="true".
I am not sure why?
In textview , gravity="center_vertical" means the content in the textview will be center and vertical . you can only see the alignment of text if textview is fill_parent if its wrap_content then there will be no place for content to have alignment.If you use layout_gravity here and width and height to wrap_content then it will place the textview in the center _vertical of the parent layout.
In imageview ,layout_centerVertical="true". means place iamge and in center and vertical in the parent layout of image (i.e the container of image).
I have one linearLayout inside another Linearlayout that fills most of the screen. When I set the gravity of the child layout to center, it only centers vertically, but does not center horizontally.
Midlayout is the child layout inside of top layout.
LayoutParams params=new LayoutParams(height,height);
params.gravity=Gravity.CENTER;
LayoutParams params2=new LayoutParams(MainActivity.screenWidth,MainActivity.screenHeight-height);
params2.gravity=Gravity.CENTER;
((LinearLayout)findViewById(R.id.arrange_midlayout)).setLayoutParams(params);
((LinearLayout)findViewById(R.id.arrange_toplayout)).setLayoutParams(params2);
LinearLayout only respects gravity on the opposite axis to it's orientation, e.g. if it's orientation is horizontal then it will only set the vertical gravity. You should probably use FrameLayout instead for the outer container.
I have one relative layout within that image view. I want to fill color in relative layout only in visible portion of layout. The portion covered by image view in relative layout should be transparent. I need this to achieve transparency between relative layout and image view.
(source: 123rf.com)
how to set image in top left corner position in linearlayout ?
Try android:layout_gravity="left|top" on your ImageView in the LinearLayout. Also, it will need to be the first child of the LinearLayout. Usually, for these sorts of positioning rules, RelativeLayout is a better choice.