drawable

How to programmatically create or alter a drawable made of lines of different colors

只愿长相守 提交于 2019-12-04 12:29:52
问题 I have to draw a 3dp line to represent a level completion in a quizz game. This line must be of 2 colors. For example, if user has completed 40% of the level, the line will be red for the first 40% of the line, the other 60% being grey. I have managed to do that with a drawable : <?xml version="1.0" encoding="utf-8"?> <layer-list xmlns:android="http://schemas.android.com/apk/res/android"> <item> <shape android:shape="line" > <size android:height="3dp" android:width="40dp"/> <stroke android

Android: Huge difference in memory consumption when using drawable vs drawable-nodpi folders

和自甴很熟 提交于 2019-12-04 11:53:01
I have basic Android application created with Android Studio with single image loaded in ImageView like this: ImageView iv = (ImageView)findViewById(R.id.imageView); iv.setScaleType(ImageView.ScaleType.CENTER_CROP); iv.setImageResource(R.drawable.g01); Image size is 1280x853 pix , nothing huge. When I store the image in drawable folder runtime memory consumed by app is 24.35 MB vs 11.85 MB when image is stored in drawable-nodpi folder. Tested on xhdpi device with resolution of 1280x720 pix . In my real life app, difference is even greater 75 MB vs 25 MB. Why the difference? I thought that

Highlight a button when it pressed without using two drawable?

僤鯓⒐⒋嵵緔 提交于 2019-12-04 11:20:35
before I use two drawable one when the button state is pressed and an another another as default. so I'm fabricating a hole new image just for simple effect ! So now I'm asking... is it possible to applicate (a color filter or any effect) on the button drawable when that button is pressed ? If your button is the standard gray background you can apply a filter in the onClick method for the button to change the color... import android.graphics.PorterDuff; button.getBackground().setColorFilter(0xFF00FF00, PorterDuff.Mode.MULTIPLY); //Green To clear the filter later: button.getBackground()

Drawable folders for different screen size and density combinations

送分小仙女□ 提交于 2019-12-04 10:42:05
What would be the drawable folders for low density,medium screen low density,large screen low density,Xlarge screen medium density,small screen medium density,large screen medium density,Xlarge screen and for tablets? Jainendra low density,medium screen drawable-ldpi low density,large screen drawable-large-ldpi low density,Xlarge screen drawable-xlarge-ldpi medium density,small screen drawable-small-mdpi medium density,large screen drawable-large-mdpi medium density,Xlarge screen drawable-xlarge-mdpi There are 14 drawables/layouts check this question 来源: https://stackoverflow.com/questions

Android: drawable resolutions

二次信任 提交于 2019-12-04 10:32:34
问题 I've been through this post (and others) as well as through the documentation about supporting different screen resolutions in Android, but I couldn't find a clear answer to a (simple) question: Is it ok to just use "res/drawable" for images in an android app? Background: The only images that are needed in this specific app are the app icon itself and an icon for a notification, there won't be any images in any layout. So in my understanding, if no "hdpi"-, "mdpi"- and "ldpi"-folders are

How do I create an ImageView in java code, within an existing Layout?

一世执手 提交于 2019-12-04 10:08:49
问题 I'm looking for an easy way for the user to see how many drinks they've had for a BAC calculator. Picture of the app: On button press, I would like an image to be added to the screen, directly under the spinner and with left alignment. When I press the button again, I want another image to be added to the screen. So if I pressed the add beer button, a drawable of a beer would appear below the spinner. If I pressed the add beer button again, I want there to be TWO drawables of beers under the

Create a progress drawable programmatically

家住魔仙堡 提交于 2019-12-04 08:45:10
问题 I have a scenario where i need to have a large number of progress bar drawables. I cant create xml resources for all of them because i want the user to choose a color that will then be used to dynamically create the drawable. Below is one such drawable in xml, how can i create this exact drawable programmatically? <layer-list xmlns:android="http://schemas.android.com/apk/res/android"> <item android:id="@android:id/background"> <shape> <solid android:color="@color/transparent" /> <stroke

Glide: load drawable but don't scale placeholder

浪尽此生 提交于 2019-12-04 08:20:38
问题 Is there a way to use Glide to assign a placeholder but keep this image to its original scale? I have an ImageView with variable size (depending on the incoming image) which I set before calling Glide.with().load().into() and I want to use a placeholder for it but don't want the placeholder to be resized to the size of the ImageView , I want it to keep its original size. So far I couldn't find a way to do this. 回答1: Re: Gregs comment: I gave it another shot (with almost a year of extra XP)

Unable to scale Drawable with ScaleDrawable

荒凉一梦 提交于 2019-12-04 07:23:25
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. You need to set the level : LayerDrawable layerDrawable = new LayerDrawable(layers); Drawable d = layerDrawable.getCurrent(); ScaleDrawable sd = new ScaleDrawable(d, 0, 0.01f, 0.01f); sd.setLevel(8000); return sd; The level ranges from 0 to 10000: at 10000 it is full size, at 0 it does

How to protect drawable resource in Android application

ぐ巨炮叔叔 提交于 2019-12-04 06:25:51
Please tell me how to protect our resource in a apk package. With a simple rename-extract process, any one can copy and thief application drawable resource like images or soundFX files. My question is, is there any way to protect drawable resource in a Android application? The drawable needs to be accessible to the operating system, so it has to be readable. If you really want to keep it secure, you could consider storing it encrypted as a raw asset, then load it, decrypt it into a ByteStream and pass it into the BitmapFactory. That, of course, has slight performance ramifications and will