I've been trying to implement simple (I think) thing in my app. I thought it would be simple, but somehow it doesn't work as I would wanted it to.
What I'm trying to do is:
My layout
<ImageView
android:id="@+id/add_photo_left"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="20dp"
android:layout_weight="1"
android:adjustViewBounds="true"
android:src="@drawable/add_photo_button" />
<ImageView
android:id="@+id/add_photo_right"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:adjustViewBounds="true"
android:src="@drawable/add_photo_button" />
</LinearLayout>
My code - after getting picture path
BitmapFactory.Options bmpFactoryOptions = new BitmapFactory.Options();
bmpFactoryOptions.inSampleSize = 8;
Bitmap bitmap = BitmapFactory.decodeFile("/sdcard/5.png",bmpFactoryOptions);
lastClicked.setImageBitmap(bitmap);
//lastClicked.setImageResource(R.drawable.green_circle);
What I wanted to do is to read the resized file (using inSampleSize) from sdcard, and then fill ImageView (or ImageButton) with it. But after using setImageBitmap function, the view disappears - like it just loaded empty image (commented line works properly - it's just green dot).
Maybe someone has approached similar problem? I would much appreciate any kind of help.
Greetz, scana
EDIT: ofc lastClicked:
lastClicked = (ImageView)findViewById(R.id.add_photo_left);
Why don't you try lastClicked.invalidate()
?
I do so in my code at least and it works this way ;)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With