shapedrawable

Color State List not recognized in Shape Drawable

落花浮王杯 提交于 2019-11-27 02:50:27
问题 I define following drawable my_background_drawable.xml : <?xml version="1.0" encoding="utf-8"?> <layer-list xmlns:android="http://schemas.android.com/apk/res/android" > <item> <shape android:gravity="center" android:shape="rectangle"> <solid android:color="@color/color_stateful" /> </shape> </item> <item android:drawable="@drawable/selector_png_drawable" /> </layer-list> And I also define following color state list resource color_stateful.xml : <?xml version="1.0" encoding="utf-8"?> <selector

Create borders on a android view in drawable xml, on 3 sides?

久未见 提交于 2019-11-27 01:40:02
问题 I want to make a drawable for my Android button, defined as drawable. I found I could set all the borders by using a rectangle, but I got kinda stuck when I wanted it on three sides. I want for example have either the top or the bottom open. Could anyone show me how to do this? 回答1: Try doing this, though I saw it on some other post <?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 how to create triangle and rectangle shape programmatically?

牧云@^-^@ 提交于 2019-11-27 00:35:24
How can we create ballon drawable shape as below. where we can change the color of it dynamically. Here it is XML for triangle and rectangle . save it inside drawable folder. triangle.xml <?xml version="1.0" encoding="utf-8"?> <layer-list xmlns:android="http://schemas.android.com/apk/res/android" > <item > <rotate android:fromDegrees="45" android:toDegrees="45" android:pivotX="-40%" android:pivotY="87%" > <shape android:shape="rectangle" > <stroke android:color="@android:color/transparent" android:width="10dp"/> <solid android:color="#000000" /> </shape> </rotate> </item> </layer-list>

Applying ColorFilter to ImageView with ShapedDrawable

浪尽此生 提交于 2019-11-26 22:06:50
I have an ImageView with android:src set to a ShapedDrawable , namely a white circle. What I want is to colorize this ImageView in runtime responding to some events. imgView.setColorFilter seems to be solution, but after using this (tried different parameters) the image becomes invisible (I don't see it at the screen). How to solve this? And are there better ways to have color circles? Alright, I had a quick play with this and noticed your issue of the circles disappearing. Without you describing what exactly you tried, I assume you haven't tried setting the color filter to the Drawable itself

How to create parallelogram shape background?

二次信任 提交于 2019-11-26 11:12:02
问题 I am trying to make parallelogram background for my textview but it is not displaying properly...it display following output <layer-list > <item> <rotate android:fromDegrees=\"10\" android:toDegrees=\"10\" android:pivotX=\"-40%\" android:pivotY=\"87%\" > <shape android:shape=\"rectangle\" > <stroke android:color=\"#000000\" android:width=\"10dp\"/> </shape> </rotate> </item> </layer-list> i need output like this........ 回答1: As alternative to @mmlooloo's answer, whom a credit goes to, I

Android how to create triangle and rectangle shape programmatically?

二次信任 提交于 2019-11-26 09:25:00
问题 How can we create ballon drawable shape as below. where we can change the color of it dynamically. 回答1: Here it is XML for triangle and rectangle . save it inside drawable folder. triangle.xml <?xml version="1.0" encoding="utf-8"?> <layer-list xmlns:android="http://schemas.android.com/apk/res/android" > <item > <rotate android:fromDegrees="45" android:toDegrees="45" android:pivotX="-40%" android:pivotY="87%" > <shape android:shape="rectangle" > <stroke android:color="@android:color