imageview

Android set image as wallpaper

只愿长相守 提交于 2019-11-27 16:58:33
问题 Please show me an example code on how to set image as wallpaper using Android WallpaperManager. I have shortened and edited my question. Hopefully you guys could understand my question. I will show some attempts I have made. HomeActivity.class public class HomeActivity extends BaseActivity { String[] imageUrls; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.ac_home); ArrayList<String> url = new ArrayList<String>(); try {

InflateException with custom View class

我们两清 提交于 2019-11-27 16:29:20
I want to simply draw a rectangle over an ImageView . Here is the ImageViewHighlight class: public class ImageViewHighlight extends ImageView { Paint paint = new Paint(); public ImageViewHighlight(Context context) { super(context); } @Override protected void onDraw(Canvas canvas) { super.onDraw(canvas); paint.setColor(Color.BLUE); canvas.drawRect(30, 20, 60, 40, paint); } } MainActivity : public class MainActivity extends Activity { @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); } } XML: <com.example

How set imageview scaletype to topCrop

老子叫甜甜 提交于 2019-11-27 16:10:39
问题 I'm coding android and I have a imageview. I want to set scaletype of this to topcrop. I could find centercrop in options, but it's not my request. How do I do? 回答1: Custom Android ImageView for top-crop scaling of the contained drawable. import android.content.Context; import android.graphics.Matrix; import android.widget.ImageView; /** * ImageView to display top-crop scale of an image view. * * @author Chris Arriola */ public class TopCropImageView extends ImageView { public

Put a button over an ImageView

*爱你&永不变心* 提交于 2019-11-27 14:36:18
问题 I'm newbie in Android. I would like to know if it's possible to put a button or another component over an ImageView. I've tried setting the image as a background image of a LinearLayout, but when I change between landscape and portrait mode, the image porportions are changed. Thanks a lot. 回答1: Don't put the image as a background, you don't have any control on how the image is scaled. Instead, create a RelativeLayout, and put an ImageView as one of the child, and you can place anything

Android ImageView ScaleType and item height

放肆的年华 提交于 2019-11-27 14:35:37
问题 Things looked quite simple first but in the end the result is not good. I have an image which has a width larger than screen's width. So I need to scale it down in my imageview. I looked over the ScaleType options and tried them all but none is ok. First "center" only displays the image centered on the layout, no scaling done. "fitCenter" scales the image to fit in my layout but has a major drawback: the height of the item remains as it would have the large image in it. Take a look at the

Universal-Image-Loader | SSLHandshakeException: Handshake failed

末鹿安然 提交于 2019-11-27 14:14:43
I have a ListView with some content (TextViews, ImageView...) in the items. I'm using UIL by Nostra to load the images in the items but some of them fail to load. This is what do I get, when i call Log.v(String.valueOf(failReason.getCause()); : 11-16 23:52:20.447: V/javax.net.ssl.SSLHandshakeException: Handshake failed(17467): failz 11-16 23:52:20.657: V/NativeCrypto(17467): SSL handshake aborted: ssl=0x15fd758: Failure in SSL library, usually a protocol error 11-16 23:52:20.657: V/NativeCrypto(17467): error:14077410:SSL routines:SSL23_GET_SERVER_HELLO:sslv3 alert handshake failure (external

Add text to image in android programmatically

此生再无相见时 提交于 2019-11-27 14:02:18
问题 I want to make an application just like opening screen of android.I am dynamically adding images to the rows of tableLayout. I have only defined tableLayout in xml file and remaining code is in java. I have added images successfully but i am not getting any help with setting text of that image (I want to display a text under image) and image to be a specific padding.How to do it?Thanks in advance. 回答1: What you can instead do is to put a TextView in overlay to a ImageView using a

Draw round corners on top left top right bottom left bottom right using Path and RectF in Android

◇◆丶佛笑我妖孽 提交于 2019-11-27 13:21:28
问题 By making a custom ImageView and override the onDraw method with the following will make the ImageView to have rounded corners. Reference @Override protected void onDraw(Canvas canvas) { float radius = getContext().getResources().getDimension(R.dimen.round_corner_radius); Path path = new Path(); RectF rect = new RectF(0, 0, this.getWidth(), this.getHeight()); path.addRoundRect(rect, radius, radius, Path.Direction.CW); canvas.clipPath(path); super.onDraw(canvas); } How can I selectively make

ImageView fit without stretching the image

旧时模样 提交于 2019-11-27 13:14:32
is it possible that my ImageView will fit to all screen sizes without the image look stretched? i tried all scale types changing it to background and src with fill_parent > wrap_content but still. if the image is not smaller it just looks stretched.. example: <ImageView android:layout_width="fill_parent" android:layout_height="wrap_content" android:scaleType="centerInside" android:adjustViewBounds="true" android:background="@drawable/background" /> <ImageView android:layout_width="fill_parent" android:layout_height="wrap_content" android:scaleType="fitXY" android:adjustViewBounds="true"

Android ScrollView adds extra padding on top and bottom of child imageview

南笙酒味 提交于 2019-11-27 13:01:51
问题 I have a problem with rendering a ScrollView. Essentially, the layout is fixed header and footer with a scrollview in the middle. The idea is that when the screen keyboard is activated for the content EditText the image can be scrolled if the height of the image is longer than the middle view. In testing the layout, I've found that on my Android phone (Xperia X10 Android 1.6) there is a whole heap of padding added to the top and bottom of the ImageView. I'd appreciate any suggestions as to