Multiple imageview on touch action listener - android

I have 4 views in the same activity. I want to move each Imageview on touch in whole screen, but it allow me to move in its width height.
Each image view's layout height and width is wrap_content.
It works fine with one image view with fill_parent.

Its explained in this example.

Related

Resizing only the height of CardView also changes the width

I currently have a recycler view that has a list of CardViews.
When I click on the card I want to be able to expand the card (change only the height). This is working fine by setting the new height to the card with an animation.
The problem is that when I click to expand the card, the width also shrinks to less than half the width of the screen. If I scroll the view away and come back the width is set correctly. Every time I try to expand the height, it expands to the right size but the width shrinks.
Is there something that I'm supposed to do to expand/collapse a card in a recycler view and not have this side effect of also resizing the card width?
I tried only setting the height in a valueAnimator and that works for the expansion.
I tried to set the width programmatically at the end of the animation to match parent but that has no effect.
for better solution pls share code with us, until that.
check your xml codes for any Wrap content value for width.
It will solve your issue.

fix height and width of all images added dynamically to image view

I have horizontal scroll view in which i have to add images which are coming from server which are shown of equal size in height and width.
how to set height and width with centre zooming of image
You can use this DynamicHeightImageView. You have to explicitly give the with of the imageview here and height will be set by setHeightRatio() method. You can use scaleType as centerCrop on imageView or if you want to use the zooming you can use any zooming animation.

CardView vs LinearLayout - images scalling issue

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.

In framelayout, if I want to put a view in the position that starts from 1/2 of the screen width

In framelayout, if I want to put a view in the position that starts from 1/2 of the screen width. How can I do it? Thanks.
You can accomplish that in multiple ways. It only depends if you really need to stick with the FrameLayout.
Two easiest would be those:
FrameLayout - you would need to know whats the width of the layout (so if your layout is wrap_content it might get tricky). Set your view's gravity to left, and set its margin_left to half of the layout's width.
LinearLayout - either put it inside your FrameLayout (not very good practice), or (if you can) swap it with your FrameLayout. Set it's orientation to horizontal, add dummy view with width = 0dp, weight = 1. Then add your view with the same values for width and weight.

android app - make view only take up portion of parent view

I have a background image on my app, and I want my listview to be in the form of a window that overlays the background image. Sort of like the the form which has a white filter in this picture:
http://25.media.tumblr.com/ad75c4a9dad9650ed53d754712f4fbb2/tumblr_mgemxiU2W01r2wjwko2_1280.png
I currently have a listview defined in xml with:
android:layout_width="fill_parent"
android:layout_height="fill_parent"
and a semi transparent color as its background. This is great, but it takes up the whole screen, since it fills the parent width and height. What is the best way to make it slightly smaller than the parent's dimensions so that it is say, (fill_parent - some relative value) height and width?
Use margin in a layout to make it smaller relative to the parent layout and other child's
Use a FrameLayout as a parent, then add your ListView and set width and height to wrap_content. Now it should "float" above the other views inside the FrameLayout. You can use padding and margin to set its position.

Categories

Resources