android-drawable

Android receipt/zigzag drawable/layout

让人想犯罪 __ 提交于 2019-11-30 05:18:24
I'm in need of creating a receipt layout in Android. The idea is very simple, a rectangle layout with a zigzag bottom edge. The best result would be a drawable/layout with a fixed zigzag size (meaning, fixed half-triangle size), which will multiply the amount of triangles according to the shape's actual width, in real time. With a clip maybe, to have clipped triangles if necessary. Here is a good example ( edit : I'm referring to the bottom zigzag line) : I actually have no solid idea of how to create it. Thought of 9 patch, but it seems unfitting. Thought of list-layer drawable with

Android's gradient drawables: poor quality of screenshots in Eclipse

Deadly 提交于 2019-11-30 04:56:51
问题 I'm using drawables like the following one for backgrounds with a gradient: <?xml version="1.0" encoding="utf-8"?> <shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle"> <gradient android:startColor="#ffffff" android:endColor="#cccccc" android:angle="-90" android:dither="true" /> </shape> This results in a banded gradient on the emulator, and when I take a screenshot of the emulator (using Eclipse), the result is even poorer: Why? And how to solve this

DrawableCompat setTint not working on API 19

女生的网名这么多〃 提交于 2019-11-30 04:55:32
I am using the DrawableCompat for tinting drawable as below, tinting doesn't seem to be working on API 19. I am using the support lib version 23.3.0 Drawable drawable = textView.getCompoundDrawables()[drawablePosition]; if (drawable != null) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { drawable.setTint(color); } else { DrawableCompat.setTint(DrawableCompat.wrap(drawable), color); } } hardysim I had the same problem. I combined the posts in https://stackoverflow.com/a/30928051 and tried the APIs 17, 19, 21, 22, 23 and N Preview 3 with SupportLib 23.4.0 to find a solution. Even

Get specific drawable from state list drawable

我是研究僧i 提交于 2019-11-30 02:56:21
问题 I have a state list drawable, and i want to get a specific drawable from the state list drawable: <?xml version="1.0" encoding="utf-8"?> <selector xmlns:android="http://schemas.android.com/apk/res/android" xmlns:kplus="http://schemas.android.com/apk/res-auto"> <item kplus:key_type_space_alt="true" android:state_pressed="true" android:drawable="@drawable/space_1_pressed" /> <item kplus:key_type_space_alt="true" android:drawable="@drawable/space_1_normal" /> <!-- TopNav keys. --> <item kplus

App crashes on startup on android API 10 but not on API 16 because of Resources$NotFoundException

安稳与你 提交于 2019-11-30 02:41:45
问题 My app launches and starts fine on my Samsung Galaxy S3 phone running Android 4.1.2, but when I try to test the same app on my Motorola Droid X running Android 2.3.4 the app crashes before anything is even displayed on my Droid X screen. My LogCat is below. Unfortunately, it does not point me to exactly what part of my code it is failing on, but it seems like something to do with my layout because of these exceptions: 08-09 10:43:39.686: E/AndroidRuntime(3192): FATAL EXCEPTION: main 08-09 10

Android button select and press drawable

情到浓时终转凉″ 提交于 2019-11-29 23:54:12
I'm trying to make a button with state press and select, I already did the same with tabs and it works but I don't know why here does not work. I have done it like this: button_sel.xml <shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle"> <gradient android:startColor="@color/azulado" android:endColor="@color/azulBrillante" android:angle="270" /> <corners android:radius="@dimen/corner_radius" /> <stroke android:width="2px" android:color="@color/blanco" /> </shape> button_unsel.xml <shape xmlns:android="http://schemas.android.com/apk/res/android" android

Using a rounded corners drawable

北城余情 提交于 2019-11-29 20:42:09
There is a nice post made by the popular Google developer Romain Guy that shows how to use a rounded corners drawable (called "StreamDrawable" in his code ) on a view efficiently. The sample itself works very well on my Galaxy S3 when in portrait mode, but I have a few issues with it: if the screen is small (for example on qvga screens), the shown images get cropped. if I have an input bitmap that is too small than how I wish to show it, the output image has its edges smeared. Even on the Galaxy S3, when you run the sample code and it's on landscape, it looks awful: I'm still not sure about it

How to use RoundedBitmapDrawable

拜拜、爱过 提交于 2019-11-29 20:20:13
Has anyone managed to use RoundedBitmapDrawable ? Correct me if I'm wrong, but to my understanding, it makes a circular image from a regular rectangular image. What I've tried so far is this RoundedBitmapDrawable.createRoundedBitmapDrawable(getResources(), BitmapFactory.decodeResource(getResources(), iconResource)) What I tried to achieve: transform any image to a circular image and show it using an ImageView. In case I mixed things up and all that I said is non-sense. Is it possible (or simpler) to do it with any of the new framework? (Android L or new Support Library) alanv You need to set

Android shape with gradient border and shadow

守給你的承諾、 提交于 2019-11-29 20:13:03
问题 I have a png drawable for the buttons. But it image drawable has gradient and it looks bad when applying 9patch (gradient & 9patch non compatible). I want to do this with a shapes. But I can't drawing with android shapes because it's hard to me to understand it. Can you help me to draw this image with a shapes? It's contain a border gradient, orange rectangle inside with a rounded corners and shadow 120° 回答1: Here you go Create your layout <?xml version="1.0" encoding="utf-8"?>

How to draw a dot circle inside a square drawable in android?

久未见 提交于 2019-11-29 17:53:24
I want a small dot inside a square button , this is what i have tried till now as answered by azizbekian: <?xml version="1.0" encoding="utf-8"?> <layer-list xmlns:android="http://schemas.android.com/apk/res/android"> <item> <shape android:shape="rectangle"> <size android:width="100dp" android:height="100dp"/> <solid android:color="#38b0ef"/> </shape> </item> <item android:bottom="45dp" android:left="45dp" android:right="45dp" android:top="45dp"> <shape android:shape="oval"> <stroke android:width="1dp" android:color="#0c5069"/> <size android:width="20dp" android:height="20dp"/> <solid android