android-drawable

How to get a Drawable that's a mirrored version of a different Drawable?

会有一股神秘感。 提交于 2021-01-27 04:29:10
问题 Background I know it's possible to create a rotated version of a Drawable (or Bitmap), as such (written about it here) : @JvmStatic fun getRotateDrawable(d: Drawable, angle: Int): Drawable { if (angle % 360 == 0) return d return object : LayerDrawable(arrayOf(d)) { override fun draw(canvas: Canvas) { canvas.save() canvas.rotate(angle.toFloat(), (d.bounds.width() / 2).toFloat(), (d.bounds.height() / 2).toFloat()) super.draw(canvas) canvas.restore() } } } The problem I wanted to have

How to make round corners for a ring shape in Android drawable

三世轮回 提交于 2021-01-27 02:26:08
问题 I have a custom progress bar that looks like this: Here's the .xml code I've used to create it: background_drawable.xml <?xml version="1.0" encoding="UTF-8"?> <shape xmlns:android="http://schemas.android.com/apk/res/android" android:innerRadius="@dimen/progress_bar_radial_inner_radius" android:thickness="@dimen/progress_bar_radial_thickness" android:shape="ring" android:useLevel="false" > <solid android:color="@color/main_color_alpha"/> </shape> progress_drawable.xml <?xml version="1.0"

android Drawable - getConstantState.newDrawable() vs mutate()

倾然丶 夕夏残阳落幕 提交于 2021-01-21 12:32:11
问题 in android i have read a few articles on how drawables share a constant state. so if you make a change to a drawable it affects all the same bitmaps. for example lets say you had a list of star drawables. changing the alpha on one will change all the star drawables alpha. but you can use mutate to get your own copy of a drawable with no shared state. The article i was reading is here Now onto my question: What is the difference between the following two calls in android: Drawable clone =

To draw rounded rectangle in Android

家住魔仙堡 提交于 2021-01-04 04:23:30
问题 I have found this question and the solution was this code : <shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle" > <solid android:color="#ffffff" /> <corners android:bottomLeftRadius="8dp" android:bottomRightRadius="8dp" android:topLeftRadius="8dp" android:topRightRadius="8dp" /> </shape> This code doesn't work on my PC (no rounded corners). And you ? There has been changes ? EDIT 1: I have an error when I build the project : AAPT: error: XML or text

To draw rounded rectangle in Android

寵の児 提交于 2021-01-04 04:19:10
问题 I have found this question and the solution was this code : <shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle" > <solid android:color="#ffffff" /> <corners android:bottomLeftRadius="8dp" android:bottomRightRadius="8dp" android:topLeftRadius="8dp" android:topRightRadius="8dp" /> </shape> This code doesn't work on my PC (no rounded corners). And you ? There has been changes ? EDIT 1: I have an error when I build the project : AAPT: error: XML or text

Android combine Drawable and Shape into a single Drawable (programatically)

被刻印的时光 ゝ 提交于 2020-12-29 13:24:09
问题 I'm setting android:drawable of a RadioButton programatically like this: Drawable unchecked = getResources().getDrawable(R.drawable.ic_room_car); Drawable d= getResources().getDrawable(R.drawable.ic_room_car); Shape circle = ?????; ??? checked = combine circle and d SateListDrawable states= new StateListDrawable(); states.addState(new int[] {android.R.attr.state_checked}, checked); states.addState(new int[] {}, unchecked); ((RadioButton)findViewById(R.id.icon_1)).setButtonDrawable(states);

How to get image name from Drawable Object?

我们两清 提交于 2020-12-16 06:59:28
问题 Somehow I have Drawable image from Drawable folder like as Drawable thumb = mContext.getResources().getDrawable(R.drawable.image_name); i try like this String image_name =thumb.getCurrent().toString(); But my need image name that means image_name from thumb; How it is possible? Any suggestion, comment, consults; provide useful links are highly appreciate. Advance Thanks 回答1: You can try like this: int imageid = getResources().getIdentifier("image_name", "drawable", getPackageName()); String

How to get image name from Drawable Object?

时光怂恿深爱的人放手 提交于 2020-12-16 06:57:44
问题 Somehow I have Drawable image from Drawable folder like as Drawable thumb = mContext.getResources().getDrawable(R.drawable.image_name); i try like this String image_name =thumb.getCurrent().toString(); But my need image name that means image_name from thumb; How it is possible? Any suggestion, comment, consults; provide useful links are highly appreciate. Advance Thanks 回答1: You can try like this: int imageid = getResources().getIdentifier("image_name", "drawable", getPackageName()); String

Drawable V21 vs V24 vs custom folders for hdpi,mdpi,xhdpi etc.. ? In which folder should I put my images for multi-device support?

喜欢而已 提交于 2020-12-16 02:52:18
问题 I have an android application, In which home page comprises of 8 ImageViews, they act as menu options for users, So where should I put the multi-density images for these ImageViews in custom drawable folders(ldpi,mdpi,hdpi,xhdpi,xxhdpi,xxxhpi) or drawableV21 or drawableV24 ? 回答1: It changes due to your need. For images you can design it for the highest resolution and put it in xxxhpi folder. Android will automatically downscale of resolution for other devices. Also you can put different

Drawable V21 vs V24 vs custom folders for hdpi,mdpi,xhdpi etc.. ? In which folder should I put my images for multi-device support?

心不动则不痛 提交于 2020-12-16 02:51:32
问题 I have an android application, In which home page comprises of 8 ImageViews, they act as menu options for users, So where should I put the multi-density images for these ImageViews in custom drawable folders(ldpi,mdpi,hdpi,xhdpi,xxhdpi,xxxhpi) or drawableV21 or drawableV24 ? 回答1: It changes due to your need. For images you can design it for the highest resolution and put it in xxxhpi folder. Android will automatically downscale of resolution for other devices. Also you can put different