android-drawable

Mipmap drawables for icons

女生的网名这么多〃 提交于 2019-11-26 03:27:17
问题 Since Android 4.3 (Jelly Bean) we can now make use of the res/mipmap folders to store \"mipmap\" images. For example, Chrome for Android stores its icons in these folders instead of the more normal res/drawable folders. How are these mipmap images different from the other familiar drawable images? I see that in my manifest, we use the @mipmap/ qualifier, instead of @drawable/ , which makes sense given the resource folder name: <activity android:name=\".MipmapDemp\" android:icon=\"@mipmap/ic

Using android vector Drawables on pre Lollipop crash

落花浮王杯 提交于 2019-11-26 03:08:24
问题 I\'m using vector drawables in android prior to Lollipop and these are of some of my libraries and tool versions: Android Studio : 2.0 Android Gradle Plugin : 2.0.0 Build Tools : 23.0.2 Android Support Library : 23.3.0 I added this property in my app level Build.Gradle android { defaultConfig { vectorDrawables.useSupportLibrary = true } } It is also worth mentioning that I use an extra drawable such as LayerDrawable(layer_list) as stated in Android official Blog (link here) for setting

How to fix: android.app.RemoteServiceException: Bad notification posted from package *: Couldn&#39;t create icon: StatusBarIcon

半腔热情 提交于 2019-11-26 02:18:46
问题 I\'m seeing the following exception in crash logs: android.app.RemoteServiceException: Bad notification posted from package com.my.package: Couldn\'t create icon: StatusBarIcon(pkg=com.my.package user=0 id=0x7f02015d level=0 visible=true num=0 ) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1456) at android.os.Handler.dispatchMessage(Handler.java:102) at android.os.Looper.loop(Looper.java:146) at android.app.ActivityThread.main(ActivityThread.java:5487) at java.lang

How to reference style attributes from a drawable?

試著忘記壹切 提交于 2019-11-26 02:17:32
问题 I want to have 2 selectable themes for my application. In order to do that, I defined some attributes, like this: <attr format=\"color\" name=\"item_background\" /> Then, I created both themes, like this: <style name=\"ThemeA\"> <item name=\"item_background\">#123456</item> </style> <style name=\"ThemeB\"> <item name=\"item_background\">#ABCDEF</item> </style> This method works great, allowing me to create and modify several themes easily. The problem is that it seems that it can be used only

Storing R.drawable IDs in XML array

℡╲_俬逩灬. 提交于 2019-11-26 01:57:01
问题 I would like to store drawable resources\' ID in the form of R.drawable.* inside an array using an XML values file, and then retrieve the array in my activity. Any ideas of how to achieve this? 回答1: You use a typed array in arrays.xml file within your /res/values folder that looks like this: <?xml version="1.0" encoding="utf-8"?> <resources> <integer-array name="random_imgs"> <item>@drawable/car_01</item> <item>@drawable/balloon_random_02</item> <item>@drawable/dog_03</item> </integer-array>

How to change colors of a Drawable in Android?

元气小坏坏 提交于 2019-11-25 23:35:57
问题 I\'m working on an android application, and I have a drawable that I\'m loading up from a source image. On this image, I\'d like to convert all of the white pixels to a different color, say blue, and then cache the resultant Drawable object so I can use it later. So for example say I have a 20x20 PNG file that has a white circle in the middle, and that everything outside the circle is transparent. What\'s the best way to turn that white circle blue and cache the results? Does the answer

Mipmaps vs. drawable folders [duplicate]

淺唱寂寞╮ 提交于 2019-11-25 23:21:16
问题 This question already has answers here : Mipmap drawables for icons (11 answers) Closed 4 years ago . I\'m working with Android Studio 1.1 Preview 1. I noticed that when I create a new project I\'m getting the following hierarchy: Mipmap folders for different DPIs, no more different DPIs drawable folders. Should I put all my resources in the mipmap folders, or just the app icon? 回答1: The mipmap folders are for placing your app/launcher icons (which are shown on the homescreen) in only. Any

Android getResources().getDrawable() deprecated API 22

我是研究僧i 提交于 2019-11-25 23:15:20
问题 With new android API 22 getResources().getDrawable() is now deprecated. Now the best approach is to use only getDrawable() . What changed? 回答1: You have some options to handle this deprecation the right (and future proof ) way, depending on which kind of drawable you are loading: A) drawables with theme attributes ContextCompat.getDrawable(getActivity(), R.drawable.name); You'll obtain a styled Drawable as your Activity theme instructs. This is probably what you need. B) drawables without

Different resolution support android

偶尔善良 提交于 2019-11-25 22:36:32
问题 Edited Question: Mobile Resolution: I would like to design different screen dpi like following resolutions. 320x480, 480×800, 540x960, 720x1280 (Samsung S3), 1080x1920 (S4, Nexus5,Nexus 5x, Moto G4), 2560 x 1440 (Nexus 6, Nexus 6p, Samsung edge) Tablet Resolution: 480x800 (micromax) , 600x1024 (samsung tab2), 800x1280 (nexus 7), 1200x1920 (new nexus 7), 2048x1536 (nexus 9) I want to use different font sizes depending on the device display resolution. Q1) What is the best way to solve this

How to convert a Drawable to a Bitmap?

送分小仙女□ 提交于 2019-11-25 22:23:12
问题 I would like to set a certain Drawable as the device\'s wallpaper, but all wallpaper functions accept Bitmap s only. I cannot use WallpaperManager because I\'m pre 2.1. Also, my drawables are downloaded from the web and do not reside in R.drawable . 回答1: This piece of code helps. Bitmap icon = BitmapFactory.decodeResource(context.getResources(), R.drawable.icon_resource); Here a version where the image gets downloaded. String name = c.getString(str_url); URL url_value = new URL(name);