imageview

Rotating ImageView in Android < API Level 11

本小妞迷上赌 提交于 2019-11-29 14:11:47
So in API Level 11 Google introduced the ability to rotate an ImageView (Yay, after they introduced the possibility to Animate such a rotation, yay smart thinking, yay!) But how should I go about to rotate an ImageView using e.g. API level 8? I can't use setRotation() as described above. RotationAnimation was present since Api level 1 RotateAnimation animation = new RotateAnimation(from, to, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f); animation.setInterpolator(new LinearInterpolator()); animation.setDuration(1); animation.setFillAfter(true); imageView.startAnimation

Image download code works for all image format, issues with PNG format rendering

家住魔仙堡 提交于 2019-11-29 12:52:45
I am using the code below to download and show image from server to my ImageView import java.io.IOException; import java.io.InputStream; import java.net.HttpURLConnection; import java.net.MalformedURLException; import java.net.URL; import java.util.HashMap; import java.util.Map; import java.util.Random; import android.app.Activity; import android.graphics.Bitmap; import android.graphics.BitmapFactory; import android.os.Bundle; import android.util.Log; import android.view.View; import android.widget.Button; import android.widget.EditText; import android.widget.ImageView; public class HTTPTest

Android firing onTouch event for multiple ImageViews

时光毁灭记忆、已成空白 提交于 2019-11-29 12:37:00
I have several ImageViews, and I want the onTouch event to fire for each of them when I drag my finger across multiple images. At present the onTouch event is only firing on the first ImageView (or actually on multiple ImageViews but only when multitouching the screen). Pseudo code: for(int i=0;i<5;i++){ ImageView img=new ImageView(this); LinearLayout.LayoutParams layoutParams=new LinearLayout.LayoutParams(width,height); img.setImageResource(R.drawable.cell); img.setOnTouchListener(this); mainLayout.addView(img,layoutParams); } ... public boolean onTouch (View v, MotionEvent event){ Log.d("MY

Transparent part of image in ImageView become black

纵然是瞬间 提交于 2019-11-29 11:09:54
问题 I have problem when displaying image with transparency in Android KitKat (Nexus 7), it is OK in nexus 4 (KitKat) and other previous Android OS, here the image: and ImageView layout: <ImageView android:id="@+id/avatar" android:layout_width="35dp" android:layout_height="35dp" android:layout_gravity="center_vertical" android:layout_marginLeft="21dp" android:padding="3dp" android:src="@drawable/icon_button_profile_new" android:tag="@string/avatar" /> and here the screenshot when running on Nexus

external allocation too large for this process

…衆ロ難τιáo~ 提交于 2019-11-29 11:06:21
I posted a question last night about this issue, but I dont think I explained it well enough to get the proper help. So basically, I have an application where you can press a button which will let you select an image from your gallery and show it in an ImageView I have displayed in the app. This all works great. However, when I press the button again and choose a different picture the app force closes. UPDATE Now, if I take a photo from my downloads photo folder in the gallery it works fine, can switch photos as often as I like. But when I go back to my camera photo folder to change the

How do I save an ImageView as an image?

半腔热情 提交于 2019-11-29 09:38:26
I have an ImageView with a share intent( which works great, brings up all the apps I can share the image with), however, I can not share the photo because it has no path on my phone. How do I go about saving the ImageView on my phone? Below is my code. public void taptoshare(View v) { View content = findViewById(R.id.myimage); content.setDrawingCacheEnabled(true); Bitmap bitmap = content.getDrawingCache(); File file = new File("/DCIM/Camera/image.jpg"); try { file.createNewFile(); FileOutputStream ostream = new FileOutputStream(file); bitmap.compress(CompressFormat.JPEG, 100, ostream); ostream

BitmapFactory.decodeFile returns null even image exists

☆樱花仙子☆ 提交于 2019-11-29 09:35:08
Saving the file: FileOutputStream fo = null; try { fo = this.openFileOutput("test.png", Context.MODE_WORLD_READABLE); } catch (FileNotFoundException e) { e.printStackTrace(); } bitmap.compress(CompressFormat.PNG, 100, fo) Loading the file: String fname = this.getFilesDir().getAbsolutePath()+"/test.png"; Bitmap bMap = BitmapFactory.decodeFile(fname); i.setImageBitmap(bMap); The last line gives a null pointer exception, why is BitmapFactory.decodeFile returning null? I can verify that the file is getting saved correctly as I can pull it using adb and see the png displaying properly. If the

Making image full screen on android tutorial app

时光怂恿深爱的人放手 提交于 2019-11-29 09:34:41
问题 Using the Hello, World Gridview tutorial example, I am attempting to make the image fullscreen on click instead of display the position of the image in the array. As I am unfamilar with Android and this is my first development attempt with it, I'm at a loss. I am familiar with Java though, and I've tried doing things like this (that don't work obviously): public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); GridView gridview =

How to set random images to ImageView's?

≡放荡痞女 提交于 2019-11-29 08:21:12
i am using 9 image view's i want set images to imageview randomly , when I click on refresh button, but I tried like this it's working for random allocation of images but it's repeating the same image in two (or) three imageview's at a time. where is the problem in my code.. final int[] imageViews = { R.id.imgview11, R.id.imgview12, R.id.imgview13, R.id.imgview21, R.id.imgview22, R.id.imgview23, R.id.imgview31, R.id.imgview32, R.id.imgview33 }; final int[] images = { R.drawable.i1, R.drawable.i2, R.drawable.i3, R.drawable.i4, R.drawable.i5, R.drawable.i6, R.drawable.i7, R.drawable.i8, R

Centering an image in an ImageView

那年仲夏 提交于 2019-11-29 07:33:58
I am currently trying to center an image in an ImageView using JavaFX. So I load the image in the view : Image img = new Image("..."); imageView.setImage(img); and let's suppose the image is huge (2000x3000) and not the ImageView (400x100) The rendered image will be aligned on the left, and I would like to put in the center of the ImageView : Is there anyway to perform that ? So, after days of calculation, I managed to find a good way to do it. I post it here in case of someone would like to achieve it. I created a method that only needs access to the imageView : public void centerImage() {