drawable

Compare names of every resource with the content of a variable of sqlite database

旧巷老猫 提交于 2019-11-29 04:37:14
I hope you can help me, I already researched my case but didn't found a good answer. I want to compare the content of a variable with the names of all existing resources (if possible only with drawable resources). The question in short: How to compare the String content of an variable with a list of all resource names, preferential only with drawable resources? Or in other words: How to get a list (containing Strings) of all resource names, preferential only drawable resources? The Case: I want to display a symbol based on a given type. This type is retrieved from a SQLite Database. There are

Set the Background Image of a SurfaceView

谁都会走 提交于 2019-11-29 04:28:06
Is there a way to set the background image of a SurfaceView? Does it have to be done in xml or can I do it all in Java - I've got something that looks like this in my constructor: Drawable sky = (getResources().getDrawable(R.drawable.sky)); this.setBackgroundDrawable(sky); But it still doesn't show anything. You cannot set a background drawable on a SurfaceView. You'll have to draw the background onto the surface yourself. Try this public void surfaceCreated(SurfaceHolder arg0) { Bitmap background = BitmapFactory.decodeResource(getResources(), R.drawable.background); float scale = (float

android - adding a String over a Drawable image?

六眼飞鱼酱① 提交于 2019-11-29 03:52:21
问题 I'm trying to add a String to a Drawable image. I'm currently not using a Panel to draw and I'd like to keep it that way. Any ideas or do I need to invoke an onDraw() method? My image is showing up with this code: Drawable image = getResources().getDrawable(tile_types[tileType]); setImageDrawable(image); I'd like to add a String over this image. Thanks. 回答1: Sam's answer was my starting point, but the image didn't show up, only the text (I use it on a Google Map). Finally I got it working

Performance wise, what is typically better, using an image or a xml created shape as a drawable?

拈花ヽ惹草 提交于 2019-11-29 03:48:09
For example, if each row in a list had a background that was a gradient, would it be better to use a image of a gradient or to define that gradient in a shape drawable in xml? Is there is significant performance difference between the two methods? I just asked a similar question and it sounded like that using an image drawable is more efficient computationally than using a vector.(but i'm not expert so don't quote me on that) It really depends on what your trying to set out to achieve in the first place. If you have completed creative assets that aren't going to change then it would make sense

Consequences of drawable.setCallback(null);

牧云@^-^@ 提交于 2019-11-29 01:06:17
问题 While trying to implement small in-memory cache of Drawables, I learned that to avoid memory leaks after closing activity I need to unbind those Drawables: set their callback to null. Because maintaining Drawables cached in each activity would require extra code, I tried to unbind them immediately after setImageDrawable(drawable) and I don't see any consequences so far. This is code from MyImageView class ( extends ImageView ): setImageDrawable(drawable); d.setCallback(null); In debugger I

Is it possible to have an animated drawable?

半腔热情 提交于 2019-11-29 01:00:43
问题 Is it possible to create a drawable that has some sort of animation, whether it is a frame by frame animation, rotation, etc, that is defined as a xml drawable and can be represented by a single Drawable object without having to deal with the animation in code? How I am thinking to use it: I have a list and each item in this list may at sometime have something happening to it. While it is happening, I would like to have a spinning progress animation similar to a indeterminate ProgressBar.

Masking a Drawable/Bitmap on Android

巧了我就是萌 提交于 2019-11-29 00:58:11
问题 I'm currently looking for a way to use a black and white bitmap to mask the alpha channel of another bitmap or Drawable on Android. I'm curious as to what the best way to do this is. I certainly have a couple of ideas for how to do this, but they are not optimal. I need to be able to apply a new mask to the image every so often (the black and white bitmap will change every few seconds). Any feedback on how to achieve this would be greatly appreciated. 回答1: I got it working, so it's something

Android, Drawable.createFromStream(is, srcname): what's the 2nd parameter meaning?

拥有回忆 提交于 2019-11-29 00:53:41
Which is the meaning of the second parameter of Drawable.createFromStream() method? From Android APIs I only get: public static Drawable createFromStream (InputStream is, String srcName) Create a drawable from an inputstream In all examples I have read I see they use the string "src": is it the name of the directory where the drawable is cached, relative to my application's root dir? One parallel question: where am I supposed to find Android core sources (for example of Drawable.createFromStream() method...), to avoid such silly questions, in future? It's basically useless : Based on Froyo

Drawable shape not showing when used in combination with android:drawableBottom attribute.

安稳与你 提交于 2019-11-28 23:31:21
XML file saved at res/drawable/gradient_box.xml: <?xml version="1.0" encoding="utf-8"?> <shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle"> <gradient android:startColor="#FFFF0000" android:endColor="#80FF00FF" android:angle="45"/> <padding android:left="7dp" android:top="7dp" android:right="7dp" android:bottom="7dp" /> <corners android:radius="8dp" /> </shape> (The above shape definition is is taken from then Android developer guide. There's no errors in it.). Let's try to use it together with a TextView: <TextView android:layout_width="match_parent"

how to get the source of ImageView in order to change it?

不羁岁月 提交于 2019-11-28 23:25:10
I know that changing the ImageView resource is not big deal just using myImageView.setImageResource(mynewImageDrawable) but what I want to do is to check the current ImageSource before changing it. basically, I want to implement my own group radio buttons using imageViews. so every time any imageView is clicked, the oncliked event method will change the Image Resources of my group. and sorry for my poor English. regards, redsea There is no getDrawableId function so you'll need to do something like set a tag for the ImageView when you change its drawable. For instance, set the drawable id as a