imageview

What is the difference between src and background of ImageView

梦想与她 提交于 2019-11-26 08:09:18
问题 I am a little puzzled with using src or background for an ImageView . I know the former means the content of this ImageView and the latter means the background of the ImageView . But how to detect which one to use? I don\'t see the difference. 回答1: All views can take a background image. The src to an ImageView has additional features: different scaling types adjustViewBounds for setting bounds to match image dimensions some transformations such as alpha-setting And more that you may find in

How To Display Border To Imageview?

我们两清 提交于 2019-11-26 08:05:08
问题 Friends How To Display Border To Imageview ? I Want To Result Like Mobile gallery all image display with border. plz give me ans thanks for advance.... 回答1: You can create a resource (layer drawable xml) for your ImageView 's "border" (actually background), and declare in your theme that the ImageView 's background resource is the drawable xml. If you need this "border" to be changed based on the ImageView 's state ( focused , selected , etc.), then you should create more layer drawables, and

IllegalArgumentException: width and height must be > 0 while loading Bitmap from View

被刻印的时光 ゝ 提交于 2019-11-26 07:47:04
问题 I\'m trying to draw on an ImageViewTouch, a library which enables pinch zooming. I\'m able to draw over the image using Canvas, but when I zoom the image, the drawing disappears. For this, I\'m trying to convert the view to a bitmap and set theImageBitmap for this same view. Here\'s the code: mImage.setDrawPath(true); mImage.setImageBitmap(loadBitmapFromView(mImage)); public static Bitmap loadBitmapFromView(View v) { Bitmap b = Bitmap.createBitmap( v.getWidth(), v.getHeight(), Bitmap.Config

Get the touch position inside the imageview in android

微笑、不失礼 提交于 2019-11-26 07:43:56
问题 I have a imageview in my activity and I am able to get the position where the user touch the imageview, through onTouchListener. I placed another image where the user touch over that image. I need to store the touch position(x,y), and use it in another activity, to show the tags. I stored the touch position in the first activity. In the first activity, my imageview at the top of the screen. In the second activity its at the bottom of the screen. If I use the position stored from the first

Android Drag and drop images on the Screen?

╄→尐↘猪︶ㄣ 提交于 2019-11-26 07:39:49
问题 I m working on project user to move the image in one position to Another position on the screen. I have written a sample code to move the image but the problem here is if I move one image the neighbouring image also starts moving.. Here is the sample code.any one Idea of this. Main.java public class MainActivity extends Activity { int windowwidth; int windowheight; ImageView ima1,ima2; private android.widget.RelativeLayout.LayoutParams layoutParams ; // private android.widget.RelativeLayout

How do you setLayoutParams() for an ImageView?

拟墨画扇 提交于 2019-11-26 07:29:54
问题 I want to set the LayoutParams for an ImageView but cant seem to find out the proper way to do it. I can only find documentation in the API for the various ViewGroups , but not an ImageView . Yet the ImageView seems to have this functionality. This code doesn\'t work... myImageView.setLayoutParams(new ImageView.LayoutParams(30,30)); How do I do it? 回答1: You need to set the LayoutParams of the ViewGroup the ImageView is sitting in. For example if your ImageView is inside a LinearLayout, then

android imageView: setting drag and pinch zoom parameters

你说的曾经没有我的故事 提交于 2019-11-26 07:26:48
问题 I am currently developing for Android (my first app) an application which lets users see the subway map and be able to pinch zoom and drag around. I am currently modifying the code found in Hello Android, 3rd Edition and got the pinch zooming and dragging to work. I\'m using Matrix as my layout scale. However I now have 3 problems: I tried many things to limit the drag parameters but I can\'t seem to stop it being dragged off the parent view (and can actually disappear from view). I\'ve tried

Full screen background image in an activity

笑着哭i 提交于 2019-11-26 06:52:32
问题 I see many applications that use a full-screen image as background. This is an example: I want to use this in a project, the best way I\'ve found so far to do this is to use an image with a large size, put it in a ImageView and use android: adjustViewBounds=\"true\" to adjust the margins The problem is that if a screen with a very high resolution, the image falls short. Another option I thought of is to use the image in a FrameLayout , with match_parent in width and height as background...

How to give hexagon shape to ImageView

心不动则不痛 提交于 2019-11-26 06:25:07
问题 How to give hexagon shape to ImageView . Is it possible to do in same way ? If so then how. If this is not possible through this then how this could be achieved ? <shape xmlns:android=\"http//schemas.android.com/apk/res/android\" android:shape=\"hexagon\"> <solid android:color=\"#ffffffff\" /> <size android:width=\"60dp\" android:height=\"40dp\" /> </shape> Screenshot Here I can\'t do masking image because I can not detect which portion of bitmap I should crop to get hexagon shape bitmap. So

Android: Generate random color on click?

一个人想着一个人 提交于 2019-11-26 06:19:03
问题 I have an ImageView , in which I am programmaticly creating drawables and presenting them to the user. My goal is to click on said ImageView and change the drawable\'s color. How would I go about the random color changing bit? I am currently tinkering with Random() , Color.argb() and a few other things, but I can\'t seem to get it to work! 回答1: Random rnd = new Random(); paint.setARGB(255, rnd.nextInt(256), rnd.nextInt(256), rnd.nextInt(256)); or Random rnd = new Random(); int color = Color