android:load svg file from web and show it on image view

Update: For newer version please checkout the Glide Samples (https://github.com/bumptech/glide/tree/master/samples/svg) – You can use Glide (https://github.com/bumptech/glide/tree/v3.6.0) and AndroidSVG (https://bitbucket.org/paullebeau/androidsvg). There is also a sample from Glide: https://github.com/bumptech/glide/tree/v3.6.0/samples/svg/src/main/java/com/bumptech/svgsample/app Setup GenericRequestBuilder requestBuilder = Glide.with(mActivity) .using(Glide.buildStreamModelLoader(Uri.class, mActivity), InputStream.class) .from(Uri.class) .as(SVG.class) .transcode(new SvgDrawableTranscoder(), PictureDrawable.class) .sourceEncoder(new StreamEncoder()) .cacheDecoder(new FileToStreamDecoder<SVG>(new SvgDecoder())) .decoder(new SvgDecoder()) .placeholder(R.drawable.ic_facebook) .error(R.drawable.ic_web) .animate(android.R.anim.fade_in) .listener(new SvgSoftwareLayerSetter<Uri>()); Use RequestBuilder with … Read more

How To Display Border To Imageview?

You can create a resource (layer drawable xml) for your ImageView‘s “border” (actually background), and declare in your theme that the ImageView‘s background resource is the drawable xml. If you need this “border” to be changed based on the ImageView‘s state (focused, selected, etc.), then you should create more layer drawables, and put them together … Read more

How to prevent onClick method on transparent portion of a PNG-loaded ImageView

This one sample makes ImageView’s transparent area not clickable. ImageView: ImageView imgView= (ImageView) findViewById(R.id.color_blue); imgView.setDrawingCacheEnabled(true); imgView.setOnTouchListener(changeColorListener); OnTouchListener: private final OnTouchListener changeColorListener = new OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { Bitmap bmp = Bitmap.createBitmap(v.getDrawingCache()); int color = bmp.getPixel((int) event.getX(), (int) event.getY()); if (color == Color.TRANSPARENT) return false; else { //code to execute … Read more

How to place an imageview on top of another imageview in android

<RelativeLayout xmlns:android=”http://schemas.android.com/apk/res/android” android:layout_width=”fill_parent” android:layout_height=”fill_parent” android:background=”@color/white” > <ImageView android:id=”@+id/inside_imageview” android:layout_width=”wrap_content” android:layout_height=”wrap_content” android:layout_marginBottom=”5dip” android:layout_marginTop=”5dip” android:src=”https://stackoverflow.com/questions/11959841/@drawable/frame” /> <ImageView android:id=”@+id/outside_imageview” android:layout_width=”wrap_content” android:layout_height=”wrap_content” android:layout_alignTop=”@id/inside_imageview” android:layout_alignBottom=”@id/inside_imageview” android:layout_alignLeft=”@id/inside_imageview” android:layout_alignRight=”@id/inside_imageview” android:scaleType=”fitXY” /> </RelativeLayout> The layout_align[Top|Bottom|Left|Right] attribute in RelativeLayout is used to align views based on their respective x and y values within the margin. The second ImageView will now be aligned to the … Read more