android-drawable

Programmatically Modify ActionBarDrawerToggle Drawable

我的梦境 提交于 2019-12-11 02:33:39
问题 Does anyone know a way to get the drawable that is used for the ActionBarDrawerToggle after setting it in the constructor by resource ID? I am using a navigation drawer and I want to apply a color filter to the icon programmatically, but I can't figure out how to access it as a drawable. Any help would be appreciated. Thanks! 回答1: As the framework's ID for that View is hidden, the only way I've found to access it is by walking through the hierarchy based on the Home View's position in it.

Click event on EditText's drawableRight not working properly?

感情迁移 提交于 2019-12-11 01:58:20
问题 I need to open phone's contact book on the click of EditText 's drawableRight . Click event on drawableRight is working fine But the problem is, when I click/touch on anywhere on EditText it is also execute click event and open contact list. I take help for manage click event on drawableRight from here Please check this link. I don't want to open contact list when I click on EditText , I only want to open it when I click drawableRight (image). So how solve this problem? Here is my code:

Why doesn't this argument of the LinearGradient constructor seem to work?

天大地大妈咪最大 提交于 2019-12-11 00:39:44
问题 I want to set a custom drawable with a linear gradient as the background drawable of the bar in my SeekBar . I am creating the LinearGradient in the second statement in the following snippet, and doing it like so: // Creating the drawable: ShapeDrawable shapeDrawable = new ShapeDrawable(new RectShape()); Shader linearGradientShader = new LinearGradient(0, 0, 300, 20, new int[] { Color.RED, Color.BLUE }, new float[] { 0, 1 }, Shader.TileMode.CLAMP); shapeDrawable.getPaint().setShader

Android: Button background XML sometimes loses alpha when setting color filter

旧时模样 提交于 2019-12-10 23:47:43
问题 I've run into a really strange issue that might be a bug. I've got a drawable resource that I use as the background for buttons in my app. Here is the XML, pretty simple: <?xml version="1.0" encoding="utf-8"?> <shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle"> <stroke android:color="@color/white" android:width="5dp" /> <padding android:left="10dp" android:right="10dp" /> <corners android:radius="8dp" /> </shape> I'm experimenting with letting the user

Reducing BitmapDrawable size

痞子三分冷 提交于 2019-12-10 22:23:24
问题 I am reducing size of images with this function: Drawable reduceImageSize (String path) { BitmapDrawable bit1 = (BitmapDrawable) Drawable.createFromPath(path); Bitmap bit2 = Bitmap.createScaledBitmap(bit1.getBitmap(), 640, 360, true); BitmapDrawable bit3 = new BitmapDrawable(getResources(),bit2); return bit3; } And its working fine, the only problem is when I call this function multiple time the app is getting slow, is there any way to optimize this function? Maybe reducing size via matrix?

What is wrong with my layer-list drawable?

女生的网名这么多〃 提交于 2019-12-10 22:16:25
问题 I wanted to set a custom drawable to be the android:src of FloatingActionButton in this layout: <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:sscce="http://schemas.android.com/apk/res-auto" android:orientation="vertical" android:layout_width="match_parent" android:layout_height="match_parent" > <android.support.design.widget.FloatingActionButton android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center" sscce

drawable/ic_launcher_foreground not found. How to find that xml file

…衆ロ難τιáo~ 提交于 2019-12-10 21:51:48
问题 Gradle build is not successful because it cannot find ic_launcher_foreground.xml in drawable. 回答1: It is because you have accidentally deleted ic_launcher_forground or it is missing due to some reason Its genererally present in your drawable folder A quick fix is you can add this file and rebuild your project again ic_launcher_forground 回答2: If at all you delete the ic_launcher_foreground.xml or ic_launcher_background.xml files from your android project then no need to worry. Simply, right

How to setup night mode drawables to work as expected

不羁的心 提交于 2019-12-10 21:39:34
问题 I what to change background as night mode changes. I have /values and /values-night folder, that contain "colors.xml" with different values. ` <color name="grey1">#ebebeb</color> <color name="grey2">#c7c7c7</color> <color name="grey3">#999999</color> <color name="hover1">#8bb065</color> <color name="red1">#ba0000</color> <color name="red2">#ff0000</color> <color name="green1">#336600</color> <color name="text1">#000000</color> and other is <color name="grey1">#999999</color> <color name=

What's differences between 'drawable' folder and 'drawable-hdpi-ldpi-mdpi-xhdpi' folders?

会有一股神秘感。 提交于 2019-12-10 20:37:13
问题 To have just 'drawable' folder(if doesn't exist, I create) is enough to create suitable image size rate for all devices? or Should I create image size rate for each folder(hdpi, mdpi, ldpi, xhdpi) ? 回答1: res/drawable/ is equivalent to res/drawable-mdpi/ . The suffix-less name is there for backwards compatibility, before the densities were added in Android 1.5 or thereabouts. is enough to create suitable image size rate for all devices? If you do not mind Android scaling your images up and

Efficient way of creating Bitmap out of Drawable from res (BitmapFactory vs Type Casting)

自作多情 提交于 2019-12-10 20:33:23
问题 Which method is more efficient for creating Bitmap out of Drawable from resources? Bitmap myBitmap = BitmapFactory.decodeResource(context.getResources(), R.drawable.icon_resource); Vs Drawable myDrawable = getResources().getDrawable(R.drawable.icon_resource); Bitmap myBitmap = ((BitmapDrawable) myDrawable).getBitmap(); since API 22 above method is deprecated so use following Drawable myDrawable = ContextCompat.getDrawable(context, R.drawable.icon_resource) 回答1: You can take a look at the