imageview

Set image width and height in ImageView

最后都变了- 提交于 2019-12-06 01:46:03
问题 No matter what I try, I cannot set the width and height of my image that is passed from a soap service to my android emulator. I'm using an ImageView as follows: byte[] bloc = Base64.decode(result, Base64.DEFAULT); Bitmap bmp = BitmapFactory.decodeByteArray(bloc,0,bloc.length); ImageView image = new ImageView(this); image.setImageBitmap(bmp); image.setLayoutParams( new LinearLayout.LayoutParams( LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT)); image

Jumping ImageView while dragging. getX() and getY() values are jumping

我的未来我决定 提交于 2019-12-06 00:46:13
问题 I've created an onTouchListener for dragging Views. Images drag smoothly if I use getRawX() and getRawY() . The problem with that is the image will jump to the second pointer when you place a second pointer down then lift the first pointer. This onTouchListener attempts to fix that issue by keeping track of the pointerId . The problem with this onTouchListener is while dragging an ImageView, the ImageView jumps around pretty crazily. The getX() and getY() values jump around. I feel like I'm

creating a scaled bitmap in onCreate() according to the Imageviews height and width

前提是你 提交于 2019-12-06 00:12:42
Here is the problem im having, in the onCreate() i would like to initially set the imageview to the first image in the list of files but with the ImageViews width and height, when it flips back and forth it sets the image to the ImageViews dimentions no problem but in the onCreate() i get IllegalArgumentException width and height must be greater than 0. i tried to make the start method if as it wasnt happening in the onCreate(), idk, any help is greatly appreciated, thank you for your time public class ViewFlipperActivity extends Activity { ViewFlipper page; Animation animFlipInForeward;

How to display external storage image in imageview

只谈情不闲聊 提交于 2019-12-05 21:58:40
I want to display external storage image like: "storage/sdcard0/image.jpg" in my android application. can any one guide me how to achieve this? If your image is in the root folder of sdcard then access it through Bitmap bmp = BitmapFactory.decodeFile(Environment.getExternalStorageDirectory().toString + File.separator + "yourimage.jpg"); webImage.setImageBitmap(bmp); Try this function: Bitmap bitmap = BitmapFactory.decodeFile(Environment.getExternalStorageDirectory()+File.separator+"image.png"); Set this bitmap to imageview: imageView.setImageBitmap(bitmap); this is the right way to do this:

How to open an image in drawable folder using android imageview applications?

谁说胖子不能爱 提交于 2019-12-05 21:53:28
I want to open an image in my drawable folder via default imageview applications of my phone (Gallery, etc.). My image location: drawable/image.png Code: Intent intent = new Intent(); intent.setAction(Intent.ACTION_VIEW); intent.setDataAndType(Uri.parse(""), "image/*"); startActivity(intent); What do I need to write in Uri.parse function to see the image file? To do that you have to copy your image in drawable folder to SD card and then give the path of the file in SD card to intent. Here is the code: Bitmap bitmap = BitmapFactory.decodeResource(getResources(), R.drawable.imagename);

Android how to get bounds of imageview with matrix

妖精的绣舞 提交于 2019-12-05 21:21:57
I have an ImageView with scaletype set to matrix, and would like to get a Rect with the bounds of the image after the transformation of the matrix. How do I get such a rect? thanks. ImageView imageView = (ImageView)findViewById(R.id.imageview); Drawable drawable = imageView.getDrawable(); Rect imageBounds = drawable.getBounds(); Then use Matrix.mapRect. 来源: https://stackoverflow.com/questions/8590693/android-how-to-get-bounds-of-imageview-with-matrix

Rotate Frame layout which contains dynamic buttons

放肆的年华 提交于 2019-12-05 20:09:33
问题 I have a Framelayout which add four imageview at runtime as well in center it contains main image with which user can perform different action but i face the problem with rotate layout view currently on touch of rotate button i'm doing this public void setRotateListener() { mRotateImage.setOnTouchListener(new OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { float x = event.getX(0); float y = event.getY(0); float theta = getTheta(x, y); switch (event.getAction(

Android drag and drop issue not displaying

有些话、适合烂在心里 提交于 2019-12-05 19:24:09
I'm working on a drag and drop application, everything is working fine but I saw an issue. I have 3 ImageViews, two of them are draggable objects and the other one is the drop target. Every time I drop the object in any location other than the drop target, it's totally disappearing! Below is the code I used: ImageView iv1, iv2, iv3; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); initControls(); } private void initControls() { // TODO Auto-generated method stub iv1 = (ImageView) findViewById (R.id

Changing image view background dynamically

﹥>﹥吖頭↗ 提交于 2019-12-05 17:30:50
I have a a set of 10 imageviews in my layout. I have given them sequential id's also as android:id="@+id/pb1" android:id="@+id/pb2" Now I want to change background dynamically. int totalPoi = listOfPOI.size(); int currentPoi = (j/totalPoi)*10; for (i=1;i<=currentPoi;i++) { imageview.setBackgroundResource(R.drawable.progressgreen); } Now inside the for loop I want to set the image view background dynamically. i,e if the currentpoi value is 3, background of 3 image views should be changed. What ever the times the for loop iterates that many image view's background should be changed. Hope the

Android - Save ImageView to file with full resolution image

ⅰ亾dé卋堺 提交于 2019-12-05 16:37:15
I put an image inside an ImageView and have multitouch implemented to resize and move the image inside the ImageView. Now I need to save the resized image to a image file. I have tried the .getDrawingCache() but that image have the size of the ImageView. I want the image to show what the ImageView shows but with full resolution (larger than the ImageView). Any ideas? You could hold a Bitmap Object in Background, which you can resize with this piece of code: Matrix matrix = new Matrix(); matrix.postScale(scaledWidth, scaledHeight); Bitmap resizedBitmap = Bitmap.createBitmap(originalBitmap, 0, 0