Android - ClipDrawable, ScaleDrawable, how does it work?
I'm having quite a problem here and I hope for someone here to able to help me. let's go.
Let's say, I have quite a big image ( 1500x2000 ), i load it as a drawable, fine so far. Now I have a SurfaceView and I want to draw a certain region ( lets say the top-left-most region ) onto a canvas, in a non-scaled version. I thought using ClipDrawable would be just the right thing to use, but actually, I can't get it to do what I want to. It just displays a scaled-down image with the clip applied.
So basically my question is: how to draw a non-scaled drawable onto a surface, and how to clip that drawable?
any help appreciated, thank you :-)
Asked by: Lucas520 | Posted: 20-01-2022
To clip a drawable simply set the appropriate clip region on the Canvas prior to drawing the drawable. Don't forget to save()/restore() the Canvas!Answered by: Dainton586 | Posted: 21-02-2022
You can use these in XML Drawable.
Check this doc for more usage for
java - Unable to scale Drawable with ScaleDrawable
Scaling with ScaleDrawable is not working for me. The drawable is remained in the same size. LayerDrawable layerDrawable = new LayerDrawable(layers); Drawable d = layerDrawable.getCurrent(); ScaleDrawable sd = new ScaleDrawable(d, 0, 0.01f, 0.01f); return sd.getDrawable(); What i need to do to fix it? Thanks.
android - why isn't ScaleDrawable displayed?
I'm defining a ScaleDrawable in XML according to the Android developers site example: <?xml version="1.0" encoding="utf-8"?> <scale xmlns:android="http://schemas.android.com/apk/res/android" android:drawable="@drawable/sign_ui_text_line" android:scaleGravity="center_vertical|center_horizontal" android:scaleHeight="80%" android:scaleWidth="80%" />
android - ScaleDrawable has its own constant state?
I've seen the blogpost about how android handles drawables and how to save memory using mutations, creating different constant states. Lets say I have a bitmap pic1.jpg which I use it in some part of my app and I have a ScaleDrawable that scales down the resource pic1.jpg. Q1: Will they share the same consta...
android - ScaleDrawable doesn't seem to work
I've looked at a lot of threads on how to change the size of a drawable but none of them seem to work. Bitmaps throw me a class cast exception and even setting the level of the ScaleDrawable doesn't work. What's wrong? I'm not looking for an xml solution because I want to change the size in terms of how other items are sized based on how big the screen is. Thanks. //set seekbar thu...
Still can't find your answer? Check out these communities...
Android Google Support | Android Community | Android Community (Facebook) | Dev.io Android