imageview

What is default scale type of ImageView?

落花浮王杯 提交于 2019-11-27 08:08:55
问题 I can set options for scaling the bounds of an image to the bounds of an ImageView using setScaleType(ImageView.ScaleType) . What is default ImageView.ScaleType ? 回答1: Looks to be ScaleType.FIT_CENTER: private void initImageView() { mMatrix = new Matrix(); mScaleType = ScaleType.FIT_CENTER; } Links to GrepCode ImageView.java: (Android 1.5r4), (Android 4.1.1r1) 来源: https://stackoverflow.com/questions/13828720/what-is-default-scale-type-of-imageview

Create imageView programmatically in Watch Kit

ぃ、小莉子 提交于 2019-11-27 07:48:32
问题 i'm trying to create an image view for a watch app, i'm trying to create programmatically but the code used in a classic view controller doesn't work. let imageName = "yourImage.png" let image = UIImage(named: imageName) let imageView = UIImageView(image: image!) imageView.frame = CGRect(x: 0, y: 0, width: 50, height: 50) view.addSubview(imageView) how i can do the same thing for watch kit? thanks 回答1: You can't dynamically create views in WatchKit. You need to create your entire interface in

Setting Android images from string value

点点圈 提交于 2019-11-27 07:39:16
Currently I'm drawing a PNG image in my Android application like so: ImageView image = new ImageView(context); image.setImageDrawable(context.getResources().getDrawable(R.drawable.testimage)) If I have a list of image names in a database, is there a way to set the drawable above using the image name? I already have the code to go through the database, I'm just looking to draw the image based on the value taken from here. For example, a record for the DB: ID: Name: ImageName: - Test testimage So when I'm reading this record, I have a string with the value of "testimage" and I'd then want to set

How To Display Random images on image view

丶灬走出姿态 提交于 2019-11-27 07:24:21
问题 Could someone please help me out with a code to randomly display a picture from the my drawings folder? i am new to java so i have no idea how to do it. Any help will be appreciated. My Requirements are:- 1.Display Random image (image should change on each start up) 2.that's all import java.util.Random; import java.util.Random; import android.app.Activity; import android.content.Context; import android.content.Intent; import android.os.Bundle; import android.view.View; import android.widget

ImageView without xml definition

ⅰ亾dé卋堺 提交于 2019-11-27 07:00:09
问题 I want to create a dynamic number of ImageViews in Android. But to display these ImageViews I have to create them in the main.xml (Am I right?) Is there a way to display the ImageViews without creating them in the main.xml? 回答1: You can create them dynamically like this: ImageView image=new ImageView(this); and to set image in this dynamically created view use: image.setImageResource(R.drawable.yourimage); 回答2: Put your image my_image.jpg into res/drawable/my_image.jpg and use: import android

How to align TextView around an ImageView?

馋奶兔 提交于 2019-11-27 06:55:46
I am trying to align the TextView around ImageView. I am using the following code: private void createSpannableText(){ TextView myTextView = (TextView) findViewById(R.id.textView); SpannableStringBuilder builder = new SpannableStringBuilder(); builder.append(this.getText(R.string.loren__ipsum__max)); int lengthOfPart1 = builder.length(); builder.append(" "); builder.append(this.getText(R.string.lorem__ipsum)); Drawable d = getResources().getDrawable(R.drawable.myImage); d.setBounds(0, 0, d.getIntrinsicWidth(), d.getIntrinsicHeight()); // <---- Very important otherwise your image won't appear

View Pager + ImageView +Pinch Zoom + Rotation

╄→гoц情女王★ 提交于 2019-11-27 06:55:34
I want to implement Pinch Zoom on Imageview, with in View Pager similar to Default Android Gallery. I have found multiple source over GitHub, But the zoom and sliding just work for only first image. What I have tried: 1.) TouchImageView 2.) PhotoView 3.) Android Touch Gallery All the above links works fine for single image view. But when it comes to Images in View pager, They have some glitches and only works fine for first image in the View Pager. When we scroll over to 3rd 4th image in view pager, Dragging functionality not working as expected if the image is zoomed. Please if any one knows

ImageView adjustViewBounds not working

随声附和 提交于 2019-11-27 06:44:29
I have an ImageView with android:layout_width=100dp , android:layout_height=wrap_content and android:adjustViewBounds=true It's source is a 50 x 50 px picture. But the aspect ratio is not preserved - height of the ImageView is 50px, not 100px (i.e. adjustViewBounds is not working). If I have a 200x200px picture it works - width and height are 100px. This code results in a 100px wide and 50px tall picture but the src image is square: <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout

How to make an image fit into a circular frame in android

混江龙づ霸主 提交于 2019-11-27 06:38:09
I have a ListView in which there is an ImageView , the image in the ImageView gets loaded dynamically after its fetched from the server. Now, I want these images, of any size, to fit into a circular frame, how to do that? Here's a sample pic of what I want Sanghita With the help of previous answer I came up with this solution.Hope it help others: import android.app.Activity; import android.graphics.Bitmap; import android.graphics.BitmapFactory; import android.graphics.Canvas; import android.graphics.Paint; import android.graphics.PorterDuff.Mode; import android.graphics.PorterDuffXfermode;

Glide listener doesn't work

别来无恙 提交于 2019-11-27 06:33:42
问题 I'm using Glide to load images and I added a listener to know when resource is ready or if there was an error of any type: Glide.with(mContext) .load(url) .placeholder(R.drawable.glide_placeholder) // use dontAnimate and not crossFade to avoid a bug with custom views .dontAnimate() .diskCacheStrategy(DiskCacheStrategy.ALL) .listener(new RequestListener<String, GlideDrawable>() { @Override public boolean onException(Exception e, String model, Target<GlideDrawable> target, boolean