I have an imageview that displays a photo taken with the phone's camera, which can be changed by the user. The problem I'm having is that the picture is scaling too small within the imageview, is there a way to force the bitmap to fit the imageview completely?
Next time, please search a few minutes, before you ask a question!
In the layout xml-file you have to add the following attributes to your ImageView to make it fill out the view:
android:scaleType="fitCenter"
You can find the attribute in the ImageView documentation's list of XML Attributes. The different scaleTypes can then be found by clicking "android:scaleType" to get to its description.
Related
I have a list which contains posts that each contain one image. The ImageView width is set to match_parent, so it's always the same. Thee ImageView height is set to wrap_content, so the image height is not always the same. The last thing is what causes a problem with scrolling, because I'm also using Glide. The system doesn't know how far it has to scroll until Glide loads the picture, gets the dimensions of it and then resizes the ImageView. When the picture is done loading and the ImageView height is set, the list "jumps" and the screen shows another post. This is solved when wrap_content is replaced by a fixed value, but this is not what I want, because in that case there's a lot of empty space around the picture for some images.
Is there any other way to achieve what I want?
Edit: the solution works, but it was still not what we wanted to achieve. We ended up changing the JSON. It now shows a ratio as well, with which the size of the ImageView can be calculated before the picture is loaded. This way the ImageView has a fixed size anyway, but it's an individual fixed size.
Check out Glide.with.pauseRequests:
if you call Glide.with(fragment/activity).pauseRequests(), new
requests will not run until you make a corresponding resumeRequests()
call. Those changes let you add an OnScrollListener and pause/resume
requests depending on the scroll state.
I'm trying to take a screenshot with Robot and view it in an ImageView, The problem is the screenshot coordinates is the ImageView Global coordinates.
So basically I'm trying to capture what's behind the Imageview but instead I get a picture of the Imageview itself.
I can't minimize because I'm taking several continuous screenshots that may vary in resolution.
What can I do?
So i have an image with dimensions of 6720x280, i want to put this image in the ImageView with dimensions of 280x280 and be able to scroll it on imageview touch (it is a product image, so basically i want to rotate the image inside the ImageView). So every time user drags ImageView image should rotate by 280px.
Here is a process of obtaining image:
Image is stored on the web server
User accesses product page
Script pre-loads the image from the server and saves it to assets folder
Using InputStream im opening image from assets folder
Converting it to Drawable
Updating ImageView with setImageDrawable
Since i'm new to android development, i don't know on how to approach this problem. So that's why i'm asking for help (at least, please, point me to the right direction), any help is really appreciated.
Thank you for your attention
P.S. Here is how it should look like:
This is how am i doing in HTML:
<div class="product_viewer" style="background-image: url('/assets/products/product_id.jpg'); background-position: -2800px 0px;"></div>
I am a newbie in android development too, but may be using a scrollview can help you. You can use addView method to add an imageview into a scrollview as i understood. Here is the developer guide for scrollview
https://developer.android.com/reference/android/widget/ScrollView.html
I hope it helps.
I have a really annoying bug that has crept into my android app and I can't locate the cause (although it is possibly because I upgraded to SDK 23).
I am dynamically referencing a series of ImageView elements and filling the ImageView with a bitmap:
ImageView img = (ImageView) activity.findViewById(context.getResources().getIdentifier(result.getView(), "id", context.getString(R.string.packagename)));
img.setImageBitmap(bitmap);
All of the ImageViews were filling correctly and now just one of the images is not filling (but the others are)
I suspect that the image is filling but is subsequently being either overwritten, hidden, sent to back or something else.
I have tried the debugger in Android studio that appears to confirm the ImageView is being correctly referenced and there is an image in 'bitmap' but what I can't seem to do is find if it is subsequently changed
Question
Is there a way to set a debugging 'trap' to catch whenever a Resource ID is accessed (i.e. I want to know when there are changes to my R.id.inv_image
Thanks for suggestions and have now resolved problem - may be helpful to someone in the future!
I had an ImageView with and xml setting:
android:layout_height="400dp"
android:layout_alignBottom="#+id/value_title"
So this anchored the base of the ImageView and the 400dp height was bigger than the available space on the display (?? ImageView was sticking out of the top but truncated??)
I believe that prior to sdk 23 the bitmap I put in the box was bottom aligned and I could see it without problem as the height of the bitmap was about half the ImageView height and filled the visible ImageView perfectly.
From sdk 23 it seems the bitmap is top aligned and so the image was invisible as the bitmap was placed above the viewable region, and all I could see was the blank bottom of the ImageView.
Fixed it by reducing the height of ImageView:
android:layout_height="106dp"
I'm New in Android World
I have an activity which preview images by imageview and the image view take a fill parent and fill all the screen, I want when i click the image view show for example a seekbar on the top of the image without reducing the image size .
note the seek bar already invisible and i show it correctly
but i want it show on the image view itself without reduce the image height.
thanks