I have a layout with 2 ImageView, for example, a square(part 3) and a rectangle(part 1) as in the attached picture.
I want these ImageView has a clipped part in common ( part 2).
The problem is I must use the RelativeLayout ( for some other reasons).
So, I try to set alignParentLeft for both , and margin left/ margin right properties with hope that they will be clipped.
Any suggestion is appreciated.
Thanks.
Related
Please look at following 2 layouts.
First, cardview:
http://pastebin.com/iYzUiDQ7
Second, LinearLayout only (layout is actually the same as the one inside my CardView):
http://pastebin.com/xijHZCPw
So, second layout contains WebView component + single LinearLayout under it that should represent the same layout as single CardView item.
It works, however... I'm having problems with scaling images. If I set very large image as image for my ImageView placed on CardView, it will be scaled nicely to fit on my CardView. CardView's height won't be changed, instead, image will be scaled proportionally to fit.
But when I'm trying to do the same with second layout I linked, my LinearLayout changes its height if I set large image. How should I change my second layout to get the same effect for my LinearLayout, placed at bottom of my screen?
I get the difference between the two layout.
you had set the layout_height with 100dp in CardView. so the height of LinearLayout in CardView will does not beyond that. But you set the layout_height with wrap_content in you second LinearLayout.
Try to set maxHeight or layout_height with digit to deal with you problem.
Hope this can help you.
I am looking for a suggestion how to create a layout which looks like the image above.
I can't figure out how the area in white is done.
Any pointers will be appreciated.
Grav- Gravity/Layout Gravity
Rel Lay - Relative Layout
Txt.V - TextView
Img.V - Image View
L.L - LinearLayout
Ornt - Orientation
Hoz - Horizontal
Ver - Vertical
Set left Layout's L.Height to match_parent, Right Layout's L.Height to wrap_content set min-height to right.layout.
If RelativeLayout is used in Left layout, use align_parentTop center_horizontal align_parentBottom respectively.
You might not get the same while working in eclipse, but will get the required in Device/Emulator. Note, your effort is needed.
Here is a good tutorial on customizing a ListView (Scroll down to Section 1.4): http://www.vogella.com/tutorials/AndroidListView/article.html
If you're looking to make rounded corners you can look at this post:
How do I create a ListView with rounded corners in Android?
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.
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.
I have a GridView populated with ImageButtons at runtime. Some buttons are smaller than others and they hug the top of their row; I want them centered in their row. I think I could accomplish this with a margin (or maybe even gravity) but programmatically I don't see any way to do this.
The usual advice is to use LayoutParams, but the layout params available via GridView's LayoutParams are very limited and don't include margin or gravity.
Thanks in advance for any suggestions!
If your images are a part of a linearlayout of any other layout view, on the image, you could use something like :
<View
android:gravity="center-vertical"/>
This will handle the view to be in the center of the vertical stretch. If you use :
android:layout_gravity
then it will position it according to its parent.