drawable

Is it possible to rotate a drawable in the xml description?

坚强是说给别人听的谎言 提交于 2019-11-28 17:20:57
I am creating an app, with resources that can be reused (because buttons are always the same, but mirrored or rotated). I do want to use the same resource so I don't have to add 3 more resources that are exactly like the original but rotated. But I also don't want to mix the code with things that can be declared in the XML or make transformations with a matrix that will cost processing time. I've got a two state button declared in an XML. <?xml version="1.0" encoding="utf-8"?> <selector xmlns:android="http://schemas.android.com/apk/res/android"> <item android:state_pressed="true" android

Find out if resource is used

别来无恙 提交于 2019-11-28 17:03:20
I am looking for an efficient way to find out if a resource (mostly a drawable) is used in Java or in an XML file. The problem is, that on my current project the drawables are changed often and now I have some drawables, which might never be used. Is there a tool/way to find those unused drawables without search each filename in the whole project? I wrote a tool based on python to solve this problem. As this is not the place to share it directly, I created a project page which is now offline. UPDATE: The development has stopped since Lint can do the same and is already included in the Android

android drawable from file path

社会主义新天地 提交于 2019-11-28 16:40:09
I have a file path String of the form "e:\...\xxx.jpg" How do I create a drawable from it? You can create a Drawable or Bitmap from a string path like this: String pathName = "/path/to/file/xxx.jpg"; Drawable d = Drawable.createFromPath(pathName); For a Bitmap: String pathName = "/path/to/file/xxx.jpg"; bitmap b = BitmapFactory.decodeFile(pathName); 来源: https://stackoverflow.com/questions/5834221/android-drawable-from-file-path

Navigation drawer (menudrawer) Android 5 (lollipop) style

大城市里の小女人 提交于 2019-11-28 15:52:57
问题 I'm using menudrawer library in my project (this one: https://github.com/SimonVT/android-menudrawer). I'm updating my app to be compatible with API21 (Android 5 Lollipop) and Material Design. When you use this library with API21 menudrawer icon looks bad. I want to achieve transition you can see in the new Play Store (new menudrawer icon transition to arrow). What's the best way to do that? Is it possible with this library? The only solution I'm thinking at the moment is custom drawable. But

Shape drawable as background, a line at the bottom

天涯浪子 提交于 2019-11-28 15:52:38
I am using a drawable as a background of a TextView just to have a divider line below the text. A achivied it with this drawable-xml: <?xml version="1.0" encoding="utf-8"?> <layer-list xmlns:android="http://schemas.android.com/apk/res/android" > <item> <shape android:shape="rectangle"> <solid android:color="#FFDDDDDD" /> <gradient android:angle="0" android:startColor="#FFAAAAAA" android:endColor="#FFEEEEEE" /> </shape> </item> <item android:bottom="2dp"> <shape android:shape="rectangle"> <solid android:color="#FF000000" /> </shape> </item> </layer-list> But this method draws a colored

How do you obtain a Drawable object from a resource id in android package?

杀马特。学长 韩版系。学妹 提交于 2019-11-28 15:50:14
I need to get a Drawable object to display on an image button. Is there a way to use the code below (or something like it) to get an object from the android.R.drawable.* package? for example if drawableId was android.R.drawable.ic_delete mContext.getResources().getDrawable(drawableId) Pete Houston Drawable d = getResources().getDrawable(android.R.drawable.ic_dialog_email); ImageView image = (ImageView)findViewById(R.id.image); image.setImageDrawable(d); Muhammad Soliman As of API 21 , you should use the getDrawable(int, Theme) method instead of getDrawable(int) , as it allows you to fetch a

Add transition to an AnimationDrawable

六眼飞鱼酱① 提交于 2019-11-28 12:04:52
I have a set of 10 images, and I want to create an animation where I cross fade between them. I've been looking into built-in Drawable to achieve such a thing, but no luck on that part. There is the AnimationDrawable, that switch between pictures, but it doesn't animate the switch. There is the TransitionDrawable, that cross fade between two pictures, but no more than two. Hell. I looked for some solution on Google, but no luck on that part. So I'm thinking about implementing my own drawable to achieve such a thing. Would any of you have any pointers ? Thanks in advance. Not sure if you found

Get URI from drawable image

送分小仙女□ 提交于 2019-11-28 12:03:56
How can I get the URI of image saved in drawable. I have tried following formats, but everytime it cannot load the image. imageURI= Uri.parse("android.resource://" + getPackageName() + "/" + R.drawable.indoor_thumbnail1); imageURI=Uri.parse("android.resource://"+getPackageName()+"/drawables/imageName"); imageURI=Uri.parse("android.resource://"+getPackageName()+"/drawables/imageName.png"); imageURI = Uri.parse("android.resource://"+ getResources().getResourceTypeName(R.drawable.indoor_thumbnail1)+"/" +getResources().getResourceEntryName(R.drawable.indoor_thumbnail1)+".png" ); Don't know why I

how to add animation to textView drawable

半腔热情 提交于 2019-11-28 12:01:50
I have used this line too add image in my textView : android:drawableLeft="@drawable/ic_launcher" in my xml file. <TextView android:id="@+id/textView1" android:layout_width="match_parent" android:layout_height="wrap_content" android:drawablePadding="5dp" android:gravity="center_vertical" android:text="@string/hello_world" android:textSize="14sp" android:textStyle="bold" android:drawableLeft="@drawable/ic_launcher" > </TextView> Now I want to add animation to this drawable. I dont know how can I access this image. Any help? thanks in advance Sanders if you set the drawable in the XML, you won't

Retrieving xhdpi app icons from packageManager?

泄露秘密 提交于 2019-11-28 11:36:19
I have an activity in my app wherein a ListView of all installed apps is generated. In addition to the app name, the app icon appears as well. I had created an array of objects containing all the information about the application, among this the icon, and retrieved the icon using: drawableAppIcon = mPackageManager.getApplicationIcon(apps.applicationInfo); Where application is a <PackageInfo> object. The problem with this is that while I readily have access to all the drawables, various apps seem to pull various quality drawables; one app icon will be extremely high res while another will be