Search Results

Search found 641 results on 26 pages for 'imageview'.

Page 2/26 | < Previous Page | 1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >

  • ImageView scale type not working in list activity

    - by Justin
    I have used ImageView's before and understand the different scale types that can be set... However I am having an incredibly difficult time trying to get an ImageView to scale properly in the row of a ListActivity or an ExpandableListActivity. I have tried setting the android:scaleType property to every single value but the image never scales down. I have set the min and max sizes as well and they don't seem to have any effect. I have done both of these things in both the XMl and in code to no avail... Does anyone have any ideas or perhaps a workaround? Thanks in advance!

    Read the article

  • Full size image in ImageView

    - by Kilnr
    Hi, I'm trying to draw an image in an ImageView, but i want it to be unscaled, with scrollbars as necessary. How can I accomplish this? Right now I just have a drawable set as the android:src of the ImageView in the XML. This autoscales the image to fit the screen width. I read that this might be because of the compatibility mode (developing for 1.5, testing on 2.1), but then I added <uses-sdk android:minSdkVersion="3" android:targetSdkVersion="4" /> to my manifest, and nothing changed. Any clues?

    Read the article

  • Android serialization: ImageView

    - by embo
    I have a simple class: public class Ball2 extends ImageView implements Serializable { public Ball2(Context context) { super(context); } } Serialization ok: private void saveState() throws IOException { ObjectOutputStream oos = new ObjectOutputStream(openFileOutput("data", MODE_PRIVATE)); try { Ball2 data = new Ball2(Game2.this); oos.writeObject(data); oos.flush(); } catch (Exception e) { Log.e("write error", e.getMessage(), e); } finally { oos.close(); } } But deserealization private void loadState() throws IOException { ObjectInputStream ois = new ObjectInputStream(openFileInput("data")); try { Ball2 data = (Ball2) ois.readObject(); } catch (Exception e) { Log.e("read error", e.getMessage(), e); } finally { ois.close(); } } fail with error: 03-24 21:52:43.305: ERROR/read error(1948): java.io.InvalidClassException: android.widget.ImageView; IllegalAccessException How deserialize object correctly?

    Read the article

  • Rotating an ImageVIew along with its original position in android in below HoneyComb versions

    - by candy
    I am trying rotate an ImageView along with its original location (rotating the image aswell as the view). So that After rotation, when I click on the rotated Image in its current position, it should be able clicked in the rotated location only. For this solution I am trying the following code. However it is rotating is going fine. After the rotation end I need to place the ImageView and Image in the rotated Location to make it able click over there only. But it is not going successfully. I am unable to rotated Image location axis points to place correctly. Can any one please suggest a way to resolve this issue. fyi-It should work on Gingerbread version android-9 aniView1.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Log.e("", "Clicked on IMAGE VIEW - 1"); } }); RotateAnimation rotate5 = new RotateAnimation(0, 150, Animation.INFINITE, 100, Animation.INFINITE, 250); //rotate5.setFillAfter(true); rotate5.setDuration(2000); rotate5.setInterpolator(new LinearInterpolator()); aniView1.setAnimation(rotate5); rotate5.setAnimationListener(new Animation.AnimationListener() { @Override public void onAnimationStart(Animation animation) { } @Override public void onAnimationRepeat(Animation animation) { } @Override public void onAnimationEnd(Animation animation) { int newTop = (int) (aniView1.getTop() + aniView1.getWidth()); aniView1.layout(aniView1.getLeft()-200, newTop, aniView1.getRight(), aniView1.getBottom() + aniView1.getMeasuredWidth()); // aniView1.setLayoutParams(new // RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WRAP_CONTENT,RelativeLayout.LayoutParams.WRAP_CONTENT)); } });

    Read the article

  • Android: Scrolling an Imageview

    - by luca
    I have an ImageView that is twice the height of a normale screen ( 960 dip). I would like to scroll it nicely up and down on the screen. The bottom of the screen should contain a bottom. I have tried various combinations of ScrollView and Imageviews without any success. I have also thinkered with the :isScrollContainer attribute without results. Anyone knows how to do this? Cheers, Luca

    Read the article

  • zooming imageview

    - by M.A. Cape
    Can anyone help on how to use the matrix scaletype to zoom an imageview and also how to use the translate method so that it can be focused at the center? I have tried using webview to be able to use the zooming and scrolling functionalities i needed but it is not nice to look at.

    Read the article

  • android imageview onClickListener animation

    - by Javadid
    hi. I guess this is kind of a idiotic question but i have tried setting onClicklistener on an ImageView and it has worked. But the problem is that the user cannot sense the click. I mean if some of u have worked on other mobile environs(like apple iphone) then wen we click on a Image in other environs then it gives an effect on the image so that the user can understand that the image has been clicked. I have tried setting alpha using "setalpha" method but it doesnt work. Though the same thing is working fine on onFocusListener implementation. Can some1 suggest a different way to modify the image on click... I am new to android so havent learnt the nuances of simple animation also... if there is any simple animation i can use for the same then plzz plzzz let me know... Thanx...

    Read the article

  • ImageView bounds are larger than expected in android layout

    - by Hamy
    Hey all, This is a layout that I have defined in an app. As you can see, I would like the TextView "@details/image_time_counter" to be aligned with the bottom right of the image. Unfortunately, this is currently what shows - app - hierarchy viewer all - HV part 2. HierarchyViewer reports that the ImageView has bounds much bigger than what I am expecting. Can anyone explain these bounds, or just tell me how to make the bounds be the same as the image size? Thanks, Hamy <RelativeLayout android:id="@+id/RelativeLayout01" android:layout_width="fill_parent" android:layout_height="fill_parent" xmlns:android="http://schemas.android.com/apk/res/android"> </RelativeLayout>

    Read the article

  • Android ImageView clickable overlays

    - by Gernot
    Hello, I have a ImageView and draw some things on that view. Now I want to have the position of the click in the onClickListener. Although I think that's not really possible (storing the position in the onTouchListener is not working), I want to ask, if there is any other way to accomplish that? The goal is to have a image with some overlays, that should be clickable. I thought about AbsolutLayout, but that is depracated, so what now? Thx for any help.

    Read the article

  • setting picture captured by built-in camera into an ImageView

    - by MAkS
    in my app i m calling built in camera for capturing picture but i want to set that picture into an image view following is the code . so what code should i add to it to set the picture into imageview. public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); Intent intent = new Intent("android.media.action.IMAGE_CAPTURE"); startActivityForResult(intent, 0); } @Override public void onActivityResult(int requestCode, int resultCode, Intent data) { if (resultCode == Activity.RESULT_OK && requestCode == 0) { String result = data.toURI(); // ... } } Thanks in advance

    Read the article

  • Android GridView Custom BaseAdapter ImageView ImageButton OnItemClick doesn´t work

    - by Marek
    i have a problem using a GridView with a CustomAdapter (extends BaseAdapter). any Activity implements the OnItemClickListener. if i use ImageView as item everything works fine, OnItemClick-Events will be fired/catched I have not found a useful example for a GridView with a custom BaseAdapter using ImageButton. Has anyone an idea? Many thanks in advantage! Snippets: class MyActivity extends Activity implements OnItemClickListener { ... @Override public void onCreate() { ... GridView gridview = (GridView) findViewById(R.id.gridview); gridview.setOnItemClickListener(this); gridview.setAdapter(new ImageButtonAdapter(this)); } ... @Override public void onItemClick(AdapterView<?> adapter, View view, int arg2, long arg3) { Log.e("onItemClick()", "arg2=" + arg2 + ", arg3=" + arg3); } } public class ImageButtonAdapter extends BaseAdapter { private Context mContext; public LayoutMenuAdapter(Context c) { mContext = c; } public int getCount() { return mThumbIds.length; } public Object getItem(int position) { return null; } public long getItemId(int position) { return 0; } public View getView(int position, View convertView, ViewGroup parent) { /* IF I USE THIS PART EVERYTHING WORKS FINE */ // ImageView imageView; // if (convertView == null) { // imageView = new ImageView(mContext); // imageView.setLayoutParams(new GridView.LayoutParams(100, 100)); // imageView.setScaleType(ImageView.ScaleType.CENTER_CROP); // imageView.setPadding(0, 0, 0, 0); // imageView.setFocusable(false); // } else { // imageView = (ImageView) convertView; // } // imageView.setImageResource(mThumbIds[position]); // return imageView; /* IF I USE THIS PART NO THE ACTIVITY/LISTENER RECEIVES NO EVENT */ ImageButton imageButton; if (convertView == null) { imageButton = new ImageButton(mContext); imageButton.setLayoutParams(new GridView.LayoutParams(100, 100)); imageButton.setScaleType(ImageView.ScaleType.CENTER_CROP); imageButton.setPadding(0, 0, 0, 0); imageButton.setFocusable(false); } else { imageButton = (ImageButton) convertView; } imageButton.setImageResource(mThumbIds[position]); return imageButton; } // references to images private Integer[] mThumbIds = { R.drawable.media}; }

    Read the article

  • How to change one Button background in a gridview? -- Android

    - by Tstop Studios
    I have a GridView with 16 ImageView buttons. My program makes a random number and when the user clicks a button in the gridview, i want it to take the random number (0-15) and set the background of the tile with the same position as the random number (0-15) to a different image. How can I just change one of the buttons background? Here's my code so far: public class ButtonHider extends Activity { Random random = new Random(); int pos; @Override protected void onCreate(Bundle savedInstanceState) { // TODO Auto-generated method stub super.onCreate(savedInstanceState); setContentView(R.layout.button_hider); pos = random.nextInt(15); GridView gridview = (GridView) findViewById(R.id.gvBH); gridview.setAdapter(new ImageAdapter(this)); gridview.setOnItemClickListener(new OnItemClickListener() { public void onItemClick(AdapterView<?> parent, View v, int position, long id) { pos = random.nextInt(16); if (position == pos) { Toast.makeText(ButtonHider.this, "Found Me!", Toast.LENGTH_SHORT).show(); } else { Toast.makeText(ButtonHider.this, "Try Again!!", Toast.LENGTH_SHORT).show(); } } }); } public class ImageAdapter extends BaseAdapter { private Context mContext; public ImageAdapter(Context c) { mContext = c; } public int getCount() { return 16; } public Object getItem(int position) { return null; } public long getItemId(int position) { return 0; } // create a new ImageView for each item referenced by the Adapter public View getView(int position, View convertView, ViewGroup parent) { ImageView imageView; if (convertView == null) { // if it's not recycled, initialize some // attributes imageView = new ImageView(mContext); imageView.setLayoutParams(new GridView.LayoutParams(100, 100)); imageView.setScaleType(ImageView.ScaleType.CENTER_CROP); imageView.setPadding(15, 15, 15, 15); } else { imageView = (ImageView) convertView; } imageView.setImageResource(R.drawable.bh_b); return imageView; } } }

    Read the article

  • HTC Incredible displaying blank ImageView

    - by Todd
    HI, I have an app that displays an an image in an ImageView using the setImageDrawable(Drawable) method. However, with the release of the Droid Incredible the images are coming up as a blank screen. I am using Drawable.createFromPath(Environment.getExternalStorageDirectory() + "\imagefile") to access the image from the SD card. I don't get any sort of error, just a black screen. I will get a null pointer exception if after trying to load the image I try to access a property of the Drawable. This makes me believe that the Drawable wasn't loaded, but I don't know why or how to make it work. This code as been working on all other Android devices, so I'm not sure what is different with the Incredible. Unfortunately I don't have access to an Incredible to test on, so I've got to rely on others to test and send me the log files. Any help you can offer would be greatly appreciated. If anyone knows how to replicate this issue on the emulator, that would be helpful too. I've configured an emulator with firmware 7 and the correct screen resolution, but I was unable to replicate the issue. Thanks.

    Read the article

  • Redundant margins when adding ImageView to ScrollView in Android.

    - by Shmuel Meymann
    Hi.. I have been trying to use a ScrollView on a single ImageView with a JPG (~770 x 1024) over an AVD that's 600x800. My main.xml is: <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent" > <ScrollView android:id="@+id/scroller" android:layout_width="fill_parent" android:layout_height="wrap_content" /> </LinearLayout> Now, I add a single ImageView with setContentView(R.layout.main); ScrollView sv = (ScrollView)findViewById( R.id.scroller ); ImageView iv = new ImageView(this); iv.setImageDrawable( new BitmapDrawable( "/sdcard/770x1024.jpg" ) ); // same happens with ScaleDrawable. iv.setScaleType( ScaleType.CENTER_INSIDE ); sv.addView( sv ); // and it does not go any better if I use Linear Layout between the ScrollView and the ImageView. The result is The image was displayed in a middle of a ScrollView, wrapped with background area on top and bottom as following: ##### ##### image . . . ##### ##### Where ##### stands for background area I tried to set the background of the ImageView red, and it verified that the blank margins were ImageView background. iv.setBackgroundColor( color.Red ); Where I would expect the image to take no more than its size (scaled to the AVD size) and I expect the ScrollView to let me scroll over the remainder (if any). For some reason, I see that the drawable size is 600x1024. Moreover I tried to add a LinearLayout with a dummy text view such as the linear layout is a parent to the ImageView and the TextView, and the ScrollView is a parent to the LinearLayout. LinearLayout dummy = new LinearLayout( this ); dummy.addView(iv); TextView someTextView = new TextView( this ); someTextView.setLayoutParams(new LayoutParams( LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT )); dummy.addView( someTextView ); sv.addView( dummy ); The result was very peculiar: The entire layout was set into the width of a text-less text view (19). It is important for me to avoid stretching the image. What is the recommended way to implement a display of a page that can be potentially scrolled? Do I have to do it manually with a plain layout and scrolling upon OnMove events? Thanks Shmuel

    Read the article

  • How do I scale a UIButton's imageView?

    - by vcLwei
    Hey guys! I create a UIButton instance(named "button") with a image use [UIButton setImage:forState:] function, the button.frame is larger than the image's size. Now I want to scale this button's image smaller. I had tried to change button.imageView.frame, button.imageView.bounds and button.imageView.contentMode, but all seem ineffective. Hopefully someone can help me how to scale a UIButton's imageView.Thanks! my create UIButton instance code: UIButton *button = [[UIButton alloc] init]; [button setImage:image forState:UIControlStateNormal]; my try to scale the image code: button.imageView.contentMode = UIViewContentModeScaleAspectFit; button.imageView.bounds = CGRectMake(0, 0, 70, 70); and: button.imageView.contentMode = UIViewContentModeScaleAspectFit; button.imageView.frame = CGRectMake(0, 0, 70, 70);

    Read the article

  • How do I get the raw dimensions of a bitmap in an ImageView?

    - by potatoe
    It seems like I might be overlooking something obvious, but I can't figure out how to retrieve the raw (unscaled) dimensions of a bitmap being displayed in an ImageView. For example, if I load a bitmap using Bitmap b = BitmapFactory.decodeResource(...), I can get those dimensions from b.getWidth() and b.getHeight(), and I could pass the bitmap into an ImageView using setImageBitmap(b). But if I have a subclass of ImageView, is there any way to retrieve those dimensions without having to pass them in explicitly? I guess I'm looking for a getImageBitmap() analog of ImageView's setImageBitmap() method, which would retrieve a Bitmap object that I can call getWidth() and getHeight() on. Any other way to retrieve the original dimensions would work too, though.

    Read the article

  • Safe, standard way to load images in ListView on a different thread?

    - by Po
    Before making this question, I have searched and read these ones: http://stackoverflow.com/questions/541966/android-how-do-i-do-a-lazy-load-of-images-in-listview http://stackoverflow.com/questions/1409623/android-issue-with-lazy-loading-images-into-a-listview My problem is I have a ListView, where: Each row contains an ImageView, whose content is to be loaded from the internet Each row's view is recycled as in ApiDemo's List14 What I want ultimately: Load images lazily, only when the user scrolls to them Load images on different thread(s) to maintain responsiveness My current approach: In the adapter's getView() method, apart from setting up other child views, I launch a new thread that loads the Bitmap from the internet. When that loading thread finishes, it returns the Bitmap to be set on the ImageView (I do this using AsyncTask or Handler). Because I recycle ImageViews, it may be the case that I first want to set a view with Bitmap#1, then later want to set it to Bitmap#2 when the user scrolls down. Bitmap#1 may happen to take longer than Bitmap#2 to load, so it may end up overwriting Bitmap#2 on the view. I solve this by maintaining a WeakHashMap that remembers the last Bitmap I want to set for that view. Below is somewhat a pseudocode for my current approach. I've ommitted other details like caching, just to keep the thing clear. public class ImageLoader { // keeps track of the last Bitmap we want to set for this ImageView private static final WeakHashMap<ImageView, AsyncTask> assignments = new WeakHashMap<ImageView, AsyncTask>(); /** Asynchronously sets an ImageView to some Bitmap loaded from the internet */ public static void setImageAsync(final ImageView imageView, final String imageUrl) { // cancel whatever previous task AsyncTask oldTask = assignments.get(imageView); if (oldTask != null) { oldTask.cancel(true); } // prepare to launch a new task to load this new image AsyncTask<String, Integer, Bitmap> newTask = new AsyncTask<String, Integer, Bitmap>() { protected void onPreExecute() { // set ImageView to some "loading..." image } protected Bitmap doInBackground(String... urls) { return loadFromInternet(imageUrl); } protected void onPostExecute(Bitmap bitmap) { // set Bitmap if successfully loaded, or an "error" image if (bitmap != null) { imageView.setImageBitmap(bitmap); } else { imageView.setImageResource(R.drawable.error); } } }; newTask.execute(); // mark this as the latest Bitmap we want to set for this ImageView assignments.put(imageView, newTask); } /** returns (Bitmap on success | null on error) */ private Bitmap loadFromInternet(String imageUrl) {} } Problem I still have: what if the Activity gets destroyed while some images are still loading? Is there any risk when the loading thread calls back to the ImageView later, when the Activity is already destroyed? Moreover, AsyncTask has some global thread-pool underneath, so if lengthy tasks are not canceled when they're not needed anymore, I may end up wasting time loading things users don't see. My current design of keeping this thing globally is too ugly, and may eventually cause some leaks that are beyond my understanding. Instead of making ImageLoader a singleton like this, I'm thinking of actually creating separate ImageLoader objects for different Activities, then when an Activity gets destroyed, all its AsyncTask will be canceled. Is this too awkward? Anyway, I wonder if there is a safe and standard way of doing this in Android. In addition, I don't know iPhone but is there a similar problem there and do they have a standard way to do this kind of task? Many thanks.

    Read the article

  • ImageView source scaling done right. How?

    - by Aleksey Malevaniy
    Scope Image bitmap have to be shown as imageView.setImageBitmap(bitmap) and scaled to fit UI. This could be done via: bitmap = Bitmap.createScaledBitmap(bitmap, newWidth, newHeight, true); xml's ImageView attributes such as android:layout_width="newWidth" android:layout_height="newHeight" android:adjustViewBounds="true" android:scaleType="fitCenter" Problem Which way is better for performance? I prefer xml 'cause this is UI specific problem and I prefer to use xmls for UI definition. Also we set width/height values in dp, it means we have the same UI for different screens. Thanks!

    Read the article

  • How to load an ImageView from a png file?

    - by Peter vdL
    I take a picture with the camera using Intent intent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE ); startActivityForResult( intent, 22 ); When the activity completes, I write the bitmap picture out to a PNG file. java.io.FileOutputStream out = openFileOutput("myfile.png", Context.MODE_PRIVATE); bmp.compress(Bitmap.CompressFormat.PNG, 90, out); That goes OK, and I can see the file is created in my app private data space. I'm having difficulty when I later want to display that image using an ImageView. Can anyone suggest code to do this? If I try to create a File with path separators in, it fails. If I try to create a Uri from a name without separators, that fails. I can open the file OK using: java.io.FileInputStream in = openFileInput("myfile.png"); But that doesn't give me the Uri I need to set an image with iv.setImageURI(u) Summary: I have the picture in a png file in private app data. What's the code to set that into an ImageView? Thanks.

    Read the article

  • Android: How to prevent image from being scaled in ImageView or ImageButton?

    - by user277827
    Hi, How can I prevent my bitmap from being scaled automatically in an ImageView or ImageButton if the view or button is stretched using "fill_parent" or using "weight"? This will be useful, for example, to create a 4-button toolbar at the top of the screen where the buttons are equally spaced, but the images inside the buttons keep getting streched even if I use scaleType="center", which should prevent scaling according to the doc, but it doesn't. Any insight is appreciated! Thanks,

    Read the article

  • How to use ColorDrawable with ImageView?

    - by user246114
    Hi, I have a layout with an ImageView defined like: <ImageView android:layout_width="45dip" android:layout_height="45dip" android:scaleType="fitXY" /> now I just want to set the imageview to be a static color, like red or green. I'm trying: ColorDrawable cd = new ColorDrawable("FF0000"); cd.setAlpha(255); ImageView iv = ...; iv.setImageDrawable(cd); the imageview is just empty though, no color. The 45dip space is being used up though. What do I need to do to get the color to be rendered? Thanks

    Read the article

< Previous Page | 1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >