imageview

Android hide and removing the image in imageview

白昼怎懂夜的黑 提交于 2019-12-05 16:23:39
问题 How to remove a image in imageview in android and also how to hide the entire image. Here I have placed an image in imageview by the below code. answerState1.setBackgroundResource(R.drawable.correct); I don't know how to remove or hide the image. Also I am entirely new to android development. 回答1: You can set the visibility of an image with the following method calls: answerState1.setVisibility(View.GONE); // hide image (make the view gone) answerState1.setVisibility(View.VISIBLE); // make

Find the position of a bitmap in android imageview when container view scaled centerInside

怎甘沉沦 提交于 2019-12-05 16:22:04
I have an RelativeLayout that contains a custom ImageView, the scaleType="centerInside", I load in a bitmap (usually smaller than the imageView). How can I get the top/left position of where the bitmap was drawn? I need to be able addView's on top a positions relative to the bitmap. RelativeLayout view = (RelativeLayout) inflater.inflate(R.layout.scroll_scaled, container, false); ContentImageView image = (ContentImageView) view.findViewById(R.id.base_page); Bitmap bm = mInterfaceActivity.getPageImage(mPageNumber); image.setImageBitmap(bm);` The layout file scrolled_scaled <?xml version="1.0"

How can I create multiple context menus?

久未见 提交于 2019-12-05 16:12:57
I have 1 activity, but would like to have multiple context menu's for different UI components. For example, I have a ListView which will react to: @Override public void onCreateContextMenu(ContextMenu menu, View v,ContextMenuInfo menuInfo) { super.onCreateContextMenu(menu, v, menuInfo); menu.setHeaderTitle("Selection Options"); menu.add(0, v.getId(), 0, "Remove"); } How can I create another context menu for the onClick event for an ImageView I have? Actually, this method is to change the option menu dynamically. To create several context menus, you have to define them in your method

How do I add an image in the drawable folder to an ImageView in Android Studio 1.2?

…衆ロ難τιáo~ 提交于 2019-12-05 14:29:27
Since Google added the mipmap folder for the launcher icons, I have had issues using the drawables folder. I manually added the hdpi folders in the drawable folder, but when I try and add the src path, the images won't allow me to view and select them. How do I add an image in the drawable folder to an ImageView in Android Studio 1.2? try with this way of code there are three ways to set image on ImageView imageView.setImageResource(R.drawable.play); or <ImageView android:id="@+id/ivProfileBg" android:src="@drawable/image_name" android:layout_width="wrap_content" android:layout_height="wrap

Add view to constraintLayout with constraints similar to another child

☆樱花仙子☆ 提交于 2019-12-05 13:30:36
I have a constraint layout (alpha9) with views spread all over it, and I have one particular ImageView that I need to replicate and add more of like it. The layout is like so : The main purpose is to animate 5 of those "coin" imageViews when the button is pressed. The imageViews i need to generated sha'll have exact properties of the the imageView behind the Button down below (with same constraints) What i tried to do is the following : private ImageView generateCoin() { ImageView coin = new ImageView(this); constraintLayout.addView(coin,-1,originCoinImage.getLayoutParams());//originCoinImage

Android 4.0 ImageView setImageBitmap does not work

☆樱花仙子☆ 提交于 2019-12-05 13:16:36
I develop a App with ffmpeg to decode a media frame. I filled a Bitmap object with the decode result and use ImageView.setImageBitmap to display the bitmap. In Android 2.3 it works well, but in Android 4.0 or up it doesn't work. The code is simply : imgVedio.setImageBitmap(bitmapCache);//FIXME:in 4.0 it displays nothing Then I tried write the Bitmap to a file and reload the file to display. String fileName = "/mnt/sdcard/myImage/video.jpg"; FileOutputStream b = null; try { b = new FileOutputStream(fileName); bitmapCache.compress(Bitmap.CompressFormat.JPEG, 100, b);// write data to file } catch

Image showing in Android Studio but not on phone

淺唱寂寞╮ 提交于 2019-12-05 10:24:37
As you can see below this is what Android Studio shows: However, when I run this app on my phone the List View shows with just a blank image (i.e - a space) above it where the "somewhere over the rainbow" should be. The List View is working fine. It consists of one image view and 2 text views. (This image view is working if it helps). If any of this is possibly interfering then I will post the code here, but I find that hard to believe. The one thing that I was unsure of was whether I could use relative view when defining the cells for the list view in the separate xml file. I don't see why

ListView - Images shuffle while scrolling

孤街浪徒 提交于 2019-12-05 09:36:47
I have a ListView with two TextViews and one ImageView. The images are loaded from the Internet and are cached by LruCache. While scrolling through the ListView the images are getting shuffled for a few seconds. Ther just shouldn't be any image until the right image is fully loaded. I found a few questions with the same problem but no one helped me :/. Here's my code: public class NewsAdapter extends BaseAdapter { private static LayoutInflater inflater; private List<Item> items = new LinkedList<Item>(); private LruCache<String, Bitmap> mMemoryCache; public NewsAdapter(Context context) {

How to find intersect between two ImageView when drag and drop?

孤人 提交于 2019-12-05 09:25:37
I have two ImageView One is fixed at a position On Second I need to apply drag an drop functionality. What I need: Drag second ImageView to the another ImageView and when they intersect than I need to call a method. EDIT 1: Intersect b/w two imageView is DONE but on the drag n drop it's not happening. Edit 2 : How can I achieve this thing on Drag and drop ? interrupt I assume that you need this functionality for Android. The easiest way is to use intersects method found in Rect class. Link to documentation. import android.graphics.Rect; ... Rect rc1 = new Rect(); imageView1.getDrawingRect(rc1)

how to half overlap imageview on another imageview in android

自闭症网瘾萝莉.ら 提交于 2019-12-05 06:40:13
how can I overlap images half on one another from layout XML file like this image. Simply you can use RealtiveLayout and negative margins <?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/activity_landing" android:layout_width="match_parent" android:layout_height="match_parent" android:background="@color/screen_background"> <ImageView android:background="@color/black" android:id="@+id/img_background" android:layout_width="match_parent" android:layout_height="wrap_content" android:src="@mipmap/ic_launcher" />