imageview

How to get the Dimensions of a Drawable in an ImageView? [duplicate]

二次信任 提交于 2019-11-27 06:33:39
This question already has an answer here: How to get the width and height of an android.widget.ImageView? 10 answers What is the best way to retrieve the dimensions of the Drawable in an ImageView? My ImageView has an Init-Method where i create the ImageView: private void init() { coverImg = new ImageView(context); coverImg.setScaleType(ScaleType.FIT_START); coverImg.setImageDrawable(getResources().getDrawable(R.drawable.store_blind_cover)); addView(coverImg); } At some point during the layout oder measure process i need the exact dimensions of the Drawable to adjust the rest of my Components

RecyclerView with only one item displayed on screen [duplicate]

这一生的挚爱 提交于 2019-11-27 06:29:44
问题 This question already has an answer here: RecyclerView horizontal scroll snap in center 7 answers I have RecyclerView with items ImageView . I want to make RecyclerView to display only one item at time, dragging to edge like ViewPager , when changing. Anyone knows how to achieve this? I'm using code from this source: Android Simple RecyclerView Widget Example Only one difference is that I don't have TextView , only ImageView . 回答1: As from I see you need a vertical ViewPager. I'm using

Android Drop Shadow on View

本小妞迷上赌 提交于 2019-11-27 06:14:24
I have done some extensive searching for code examples on this but cannot find anything. In particular, I am looking to add a shadow to a png drawable I am using in an ImageView. This png drawable is a rounded rect with transparent corners. Can somebody please provide a code example of how to add a decent drop shadow to a view either in code or XML? Josh You could use a combination of Bitmap.extractAlpha and a BlurMaskFilter to manually create a drop shadow for any image you need to display, but that would only work if your image is only loaded/displayed once in a while, since the process is

Changing ImageView source

久未见 提交于 2019-11-27 06:01:52
I have an ImageView with a source image set in the xml using the following syntax: <ImageView android:id="@+id/articleImg" style="@style/articleImgSmall_2" android:src="@drawable/default_m" /> Now I need to change this image programmatically. What I need to do is delete the old image and add a new one though. What I have done is this: myImgView.setBackgroundResource(R.drawable.monkey); It works but I noticed android stacks the new image on top of the old one (dont ask me how I found out it's not relevant for the discussion :). I definitely need to get rid of the old one before setting the new

android multitouch image zooming?

时间秒杀一切 提交于 2019-11-27 05:58:07
问题 I'm displaying an image on full screen now i want to zoom it in or out. Any one guide on how I can implement multi touch image zooming? I am using the 2.1 sdk version. 回答1: There is the possibility to use a webview to display a local file. The Webview has integrated multitouch zooming. Have a look at my question regarding this topic. 回答2: I have a working implementation for 2.1+ WebView solution caused problems for me on 4.0.x (lot's of weird white spaces appearing) https://github.com

Inflated ImageView to put in GalleryView isn't the right size

淺唱寂寞╮ 提交于 2019-11-27 05:55:14
问题 I am trying to inflate an ImageView that scales a Drawable that I can display in a GalleryView. My code to inflate the view seems to work fine, except that the attributes of the ImageView are not applied. Specifically, the inflated ImageView does not have the width/height that I set for it via the android:layout params in XML. Can someone show me what I'm doing wrong? I want to set the width/height of the image in dp, so that it is the correct size across multiple screen dpis and support

ImageView OutofMemoryException

北城余情 提交于 2019-11-27 05:53:27
问题 I have a problem when inserting an image in an ImageView. I have tried several ways to solve it but it still fails, the latest version follows. The image size is 3000x3000. Code: ImageView iv = (ImageView) findViewById(R.id.imageView); Bitmap originalBitmap = BitmapFactory.decodeResource(getResources(), R.drawable.prueba_plano_2).copy(Bitmap.Config.ARGB_8888, true); iv.setImageBitmap(originalBitmap); XML: <FrameLayout android:id="@+id/root" android:layout_width="match_parent" android:layout

How to add a gradient to a ImageView nested in a CollapsingToolbar

偶尔善良 提交于 2019-11-27 05:52:13
问题 I'am working on an Android app with material design. I have a detail view with a CollapsingToolbarLayout and a ImageView (works fine so far). Unfortunately the title is not readable if there is a bright image. So far I tried to add a gradient (Add gradient to imageview) but this solution didn't work for me because of the CollapsingToolbarLayout. Here you can see my code: <android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http

How do I remove extra space above and below imageView?

半腔热情 提交于 2019-11-27 05:38:52
问题 I have a really simple image within a RelativeLayout and for some reason I am getting extra spacing on the top and bottom which I can't remove. How can I clear it out? Here is what it looks like: Here is the code: <?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" > <ImageView android:id="@+id/imageView1" android:layout_width="wrap_content" android:layout

Maximum width and height for ImageView in Android

馋奶兔 提交于 2019-11-27 05:21:22
问题 So I have an ImageView set with android:maxHeight="100px" android:maxWidth="250px" android:minHeight="100px" android:minWidth="250px" android:scaleType="centerInside" This image view is used to show a picture that is obtained from the gallery or camera. In both cases, the image is not resized to fit inside the imageview, it just stretches its space as much as it needs. Any idea how to make it stay inside those bounds? <?xml version="1.0" encoding="utf-8"?> <EditText android:layout_height=