drawable

How can I set the color of android rating bar's stroke? (Not the color of the stars but the BORDER)

余生颓废 提交于 2019-11-28 21:09:07
I am an android beginner and I want to make my custom ratingBar. Disclaimer: it's not a duplicate. because all the posts I have read asks about how to change colors of the star and how to remove the stroke. That is NOT what I want. I want to have the stroke and to be able to change the color of the border. With a transparent and yellow stroke while empty, and yellow background and stroke for half and filled. I do NOT want to use pngs. I have my own already but they are too small. I just dont want to ask the designer to make new ones if I can make the stars using only XML attributes and

Vector Drawable in Layer List on Older Android Versions

拜拜、爱过 提交于 2019-11-28 21:08:23
On newer Android versions, the following code: <?xml version="1.0" encoding="utf-8"?> <layer-list xmlns:android="http://schemas.android.com/apk/res/android"> <item> <shape android:shape="oval"> <solid android:color="#bdbdbd" /> <size android:width="60dp" android:height="60dp" /> </shape> </item> <item android:drawable="@drawable/ic_library_books_black_24dp" android:gravity="center" android:width="40dp" android:height="40dp" > </item> </layer-list> produces this flawlessly: However, earlier Android versions (API 16 and 19, from what I've tested) do not like this at all and I get E

How to reset AnimationDrawable

坚强是说给别人听的谎言 提交于 2019-11-28 21:07:27
I have to animate a circular count down timer and I'm doing it by animating the background of an ImageView using AnimationDrawable (each image has the according slice of the circle removed). The problem is that the user has the ability to pause this animation, so I have to reload the animation but then a problem appears. I've tried setting the the animation to null, setting the background of the ImageView to null, setting the visibility of the animation, but practically nothing helped, because number of frames remains the same. I have to find a workaround for deleting all frames and adding new

DrawableCompat tinting does not work on pre-Lollipop

馋奶兔 提交于 2019-11-28 19:42:16
问题 I'm using the new TextInputLayout to wrap an EditText. When I determine a field has an error I do the following: Drawable drawable = DrawableCompat.wrap(getEditText().getBackground()); DrawableCompat.setTintList(drawable, ColorStateList.valueOf(Color.RED)); This works on 5.0 and turns the underline red, but does nothing on 4.4 or 4.1 test devices. What am I missing here? Seems so simple and according to google "just works"... pretty sure I have the latest version of it as well: compile 'com

Is there a way to set drawable's Alpha using XML?

左心房为你撑大大i 提交于 2019-11-28 19:33:53
问题 Easy like itself . I wanna make an alpha button , which would have a selected drawable this way: <?xml version="1.0" encoding="utf-8"?> <selector xmlns:android="http://schemas.android.com/apk/res/android"> <!-- Play/Pause --> <item android:state_selected="false" android:drawable="@drawable/item" /> <item android:state_selected="true" android:drawable="@drawable/item" /> </selector> I would wanna make something like this: <?xml version="1.0" encoding="utf-8"?> <selector xmlns:android="http:/

How to draw text on canvas?

生来就可爱ヽ(ⅴ<●) 提交于 2019-11-28 19:10:41
i'm trying to develop a simple pie chart class for android. For now, it can take a map of labels and values and draw the pie chart. I'm yet to add the legends for the pie, which is where i need to place the texts near small rectangles on the screen corner. Any help appreciated, since i'm new to Android dev. You will have to use the drawText method of the Canvas class. Paint paint = new Paint(); canvas.drawPaint(paint); paint.setColor(Color.BLACK); paint.setTextSize(16); canvas.drawText("My Text", x, y, paint); Here's the relevant documentation about it: http://developer.android.com/reference

Android round edges on ring shaped progressbar

徘徊边缘 提交于 2019-11-28 18:42:43
I'm trying to make a circular progress bar on android and it seems pretty straightforward task , but I'm struggling with rounding the edges of the progress and secondary progress. Is there a way to do that without making a custom view ? Using a corners radius ? or nine patch drawable ? For this view (see attachement) I'm using a simple xml file <item android:id="@android:id/progress"> <shape android:useLevel="true" android:innerRadius="@dimen/sixty_dp" android:shape="ring" android:thickness="@dimen/seven_dp"> <solid android:color="#477C5B"/> <stroke android:width="1dip" android:color="#FFFF"/>

error: cannot find symbol variable abc_ic_ab_back_mtrl_am_alpha

六眼飞鱼酱① 提交于 2019-11-28 18:05:55
I added a Fragment to my Android Studio project using New > Fragment > Fragment (Blank) . As a result when I try to run, the project won't compile because it cannot resolve R.drawable.abc_ic_ab_back_mtrl_am_alpha in toolbar.setNavigationIcon(R.drawable.abc_ic_ab_back_mtrl_am_alpha); Any ideas how to solve this? It looks like I also lost access to android:buttonTint The name of the resource was changed in the 23.2.0 support library. Modify abc_ic_ab_back_mtrl_am_alpha to abc_ic_ab_back_material Edit: In 23.2.1 the name of the component was changed back to abc_ic_ab_back_mtrl_am_alpha Edit: In

Drawable Rotating around its center Android

一个人想着一个人 提交于 2019-11-28 17:52:59
I am getting strange results with the following code: iv = (ImageView) findViewById(R.id.iv); iv.setImageResource(R.drawable.spinner_white_76); Animation a = new RotateAnimation(0.0f, 360.0f, Animation.RELATIVE_TO_SELF, iv.getDrawable() .getIntrinsicWidth() / 2, Animation.RELATIVE_TO_SELF, iv.getDrawable().getIntrinsicHeight() / 2); a.setRepeatCount(-1); a.setDuration(1000); iv.startAnimation(a); Whats the right way to specify the axis point (center of the drawable)? Feel stupid! Got it to work after spending some time closely reading the documentation: Animation a = new RotateAnimation(0.0f,

Drawing multiple shapes with ShapeDrawable in xml with Android

会有一股神秘感。 提交于 2019-11-28 17:22:29
问题 I am currently drawing a number of circles on a canvas in a custom view in code. the circles are static and do not change. I would like to draw them using a ShapeDrawable in xml to help clean up my code. I will have a number of different drawables which the user can select and therefore I don't want to do this in code. having 3 or 4 xml drawables seems a lot neater to me. I have created one circle in xml using a ShapeDrawable but am unable to add more than one shape to the xml. How do I add