I have a parent LinearLayout called ContainerLayout where I put 2 other LinearLayouts inside of it. The parent LinearLayout has rounded corners, so logically it has to sort of clip anything showing outside the rounded corners right ? Well, Android has another theory...
The ContainerLayout should have an outside border, not an inner one.
I wanna be able to hide any overflowing stuff outside of the ContainerLayout, the same we do in CSS if any of you are familiar with overflow: hidden. Thanks.
Add paddings to your ContainerLayout. In this case try 6 dp.
Related
I have a layout like this. Colored green is a horizontal LinearLayout, blue is a vertical LinearLayout and black are EditTexts (whose width and height can change). The red line represents where the EditTexts in the blue LinearLayout touch.
What I'm trying to accomplish is align the outer EditTexts so that the red line is always in the vertical center of them. On the image it already looks like that since I set the layout's gravity to center, but my issue occurs when the height of one of the EditTexts in the blue layout is bigger that the other. It should look like this, but in reality it looks like this.
What I'm trying to achieve can be accomplished with ConstraintLayouts by constraining the outer EditText's top to the bottom of the top inner (inner meaning those which used to be in the blue layout) EditText and the bottom to the top of the bottom inner EditText, but then there are other issues
All EditTexts would be in the same layout which messes with the code a lot
You can constrain the end/start to only one other View and so one of the inner EditTexts would overlap the outer one (e.g. if the outer EditText was constrained to the top inner EditText, the bottom inner EditText would overlap the outer one if it were wider than the top one) Demonstration
Every View is created dynamically so using LinearLayouts makes locating each one way easier
How would you approach this issue?
There is no way to use just the XML for the layout you have to center the external EditTexts to the red line. ConstraintLayout is the way to go but, if that is not desirable, then you can apply translation to the external EditTexts. The idea is that you would measure the vertical location of the red line and the top position of each EditText. You would then apply enough translation in the Y direction to place the EditTexts where you want them
Se setTranslationY() and getY().
I have a relative layout with background image (9patch). I have set this image as background to the layout using xml. When I add another relative layout which has buttons and textviews, there is little space left before the new layout. I didnt set any padding. I also tried by setting padding top to 0. If i remove the background image the alignment will be proper with no space left on top of new layout. I have also tried by setting match parent and fill parent in new layout but still the space remains on top of it. The space left is very little like 3dp-5dp.
can someone suggest about this issue pls.
EDIT : space is on top of the new layout horizontally and i have tried setting gravity to top and also top left.
The black pixels on the top and left define the stretch area of the 9-patch, while the pixels on the bottom and right define the fill area. My guess is that you have a fill area defined that does not cover the entire right and bottom edges.
Here's a good guide.
I need to make a mask on an HorizontalLinear Layout.
the mask must blear (sfumate) the layout at right and left.
In the layout i'have 5 picture, tha can scroll horizontally
Have any idea?
You an horizontal scroll view from devian Horizontal ListView in Android?.
For the dimming, this may be tricky, you could maybe just add some imageview to each side of the list, but you will have to re-implement it I think, not sure.
wrap the ImageView in a FrameLayout, when the mask should be shown, on FrameLayout.setForegroundDrawable(arg) . The 'arg' is drawable with a transparent color value.
Hope it helps.
Anyone got a clue how to handle following issue:
I have a Layout with background drawable like grey border, then I add padding of the border width to `Layout.
Child Layout has background drawable representing a selector, when pressed its darker gray (see image) and when not pressed its little bit lighter.
How to get rid of that sharp edge in the picture, I can't add margin to child Layout, because the pressed state must fill totally the child Layout.
It seems that the only solution here is to add the margin and suck it, or adjust the background drawables to have rounded corners as well.
I Need to shift an ImageView, which is a direct child of a LinearLayout, a bit to the left.
What happens: The View is shifted (can see the "bounding box" is shifted, with android layout manager) but the drawable keeps in the same place.
Also the drawable is cut on the right side, if I set margin low enough.
Why is this? Any advice?
Clarification: I have to shift the Image to the left. That means a bit ouside of the bounds of the containing layout.
It seems elements are always clipped when they get outside of parent's bounds (also with clipChildren=false).
A solution is to create an additional container-layout for everything besides of the item to be shifted. And then shift the container-layout in the opposite direction.
For example, to shift -10dip:
<Original container ...>
<Item to be shifted/>
<New container with margin 10dip>
<Previous content of Original container ... />
</New container with margin 10dip>
</Original container>
If your container have enough padding you can set its clipToPadding to false and use negative margin!
Why are you using negative margin? use a positive a bit more to the opposite side of the ImageView to the direction you want to shift the image, i.e. if you want to shift the image to the left, use more positive margin to the right.