android-shape

Android - make an arrow shape with xml

女生的网名这么多〃 提交于 2019-11-27 12:12:20
I want to make a button for my shape like this one Is there a way to do this with xml ? Like setting some points, in my case I have 5.. What you need is to create a shape xml file in your project's drawable-xxx folder and then use this shape as background for a button. Here is the shape file called arrow_shape.xml : <?xml version="1.0" encoding="UTF-8"?> <layer-list xmlns:android="http://schemas.android.com/apk/res/android" > <!-- Colored rectangle--> <item> <shape android:shape="rectangle"> <size android:width="100dp" android:height="40dp" /> <solid android:color="#5EB888" /> <corners android

How to display Text in Android Canvas ShapeDrawable with in the RectShape or OvalShape?

那年仲夏 提交于 2019-11-27 09:36:29
I'm trying to display Text in RectShape which uses ShapeDrawable to display in Canvas. I'm able to display RectShape in this code, but looking for how to display the String on that! public class CustomDrawableView extends View { private ShapeDrawable mDrawable; public CustomDrawableView(Context context) { super(context); int x = 10; int y = 10; int width = 300; int height = 50; mDrawable = new ShapeDrawable(new OvalShape()); mDrawable.getPaint().setColor(0xff74AC23); mDrawable.setBounds(x, y, x + width, y + height); } protected void onDraw(Canvas canvas) { mDrawable.draw(canvas); } } or public

Defined custom shape for button in xml. Now I want to change the color dynamically. How?

自古美人都是妖i 提交于 2019-11-27 07:33:17
问题 I have this: round_button.xml <xml version="1.0" encoding="utf-8"?> <selector xmlns:android="http://schemas.android.com/apk/res/android"> <item android:state_pressed="true"> <shape android:shape="oval"> <solid android:color="#dec60000"/> <size android:width="150dp" android:height="150dp"/> </shape> </item> <item android:state_pressed="false"> <shape android:shape="oval"> <solid android:color="#860000"/> <size android:width="150dp" android:height="150dp"/> </shape> </item> My Button: <Button

How to draw a circle inside a circle using Android xml shapes?

*爱你&永不变心* 提交于 2019-11-27 07:12:54
I'm trying to make a thumb for a seekbar for my app, and I want to have an inner circle surrounded by a different, larger (semi-transparent) outer circle. I'm trying to use layer-list , but I'm having issues. Below is my 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="#00f" /> <size android:height="15dp" android:width="15dp" /> </shape> </item> <item> <shape android:shape="oval" > <solid android:color="#f00" /> <size android:height="10dp" android:width="10dp" /> <

angle attribute in android gradient

本小妞迷上赌 提交于 2019-11-27 05:06:02
问题 I am going through test example. Where for some Image background they are using gradient, the code goes like this <?xml version="1.0" encoding="utf-8"?> <shape xmlns:android="http://schemas.android.com/apk/res/android"> <gradient android:startColor="#ff0000" android:centerColor="#00ff00" android:endColor="#0000ff" android:angle="180"/> <corners android:radius="5dp" /> </shape> In the above xml I didn't get angle attribute. but when I change the value of angle slightly the pattern slants. Can

filling a circle gradually from bottom to top android

房东的猫 提交于 2019-11-27 03:28:11
I have created a circle with a stroke and white background using xml. How can this be filled gradually from bottom to top on user actions(e.g. on successive button press)? Is there any free library which can be used to achieve similar thing? I created a Custom View class that will do what you want. There are four custom attributes that can be set in your layout xml: fillColor , color - Sets the color of the fill area. Default is Color.WHITE . strokeColor , color - Sets the color of the bounding circle. Default is Color.BLACK . strokeWidth , float - Sets the thickness of the bounding circle.

Open-sided Android stroke?

拜拜、爱过 提交于 2019-11-26 23:49:41
Is it possible to create an Android shape object with stroke on only certain sides? Eg I have: <stroke android:width="3dip" android:color="#000000" android:dashWidth="10dip" android:dashGap="6dip" /> Which is similar to this CSS: border: 3px dashed black; How can I set the stroke on just one side? This is how I would do it in CSS: border-left: 3px dashed black; How do you do this in Android XML? I achieved a good solution with this one: <?xml version="1.0" encoding="utf-8"?> <layer-list xmlns:android="http://schemas.android.com/apk/res/android"> <!-- This is the line --> <item android:top="

How to draw a circle inside a circle using Android xml shapes?

霸气de小男生 提交于 2019-11-26 22:16:12
问题 I'm trying to make a thumb for a seekbar for my app, and I want to have an inner circle surrounded by a different, larger (semi-transparent) outer circle. I'm trying to use layer-list , but I'm having issues. Below is my 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="#00f" /> <size android:height="15dp" android:width="15dp" /> </shape> </item> <item> <shape

How to make a view in android with rounded corners

╄→尐↘猪︶ㄣ 提交于 2019-11-26 19:37:46
I am trying to make a view in android with rounded edges. The solution I found so far is to define a shape with rounded corners and use it as the background of that view. Here is what I did,define a drawable as given below <padding android:top="2dp" android:bottom="2dp"/> <corners android:bottomRightRadius="20dp" android:bottomLeftRadius="20dp" android:topLeftRadius="20dp" android:topRightRadius="20dp"/> Now I used this as the background for my layout as below <LinearLayout android:orientation="vertical" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout

Android - make an arrow shape with xml

时间秒杀一切 提交于 2019-11-26 17:38:41
问题 I want to make a button for my shape like this one Is there a way to do this with xml ? Like setting some points, in my case I have 5.. 回答1: What you need is to create a shape xml file in your project's drawable-xxx folder and then use this shape as background for a button. Here is the shape file called arrow_shape.xml : <?xml version="1.0" encoding="UTF-8"?> <layer-list xmlns:android="http://schemas.android.com/apk/res/android" > <!-- Colored rectangle--> <item> <shape android:shape=