android-shape

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

安稳与你 提交于 2019-11-26 14:47:44
问题 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,

filling a circle gradually from bottom to top android

萝らか妹 提交于 2019-11-26 10:29:29
问题 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? 回答1: 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

How to make a view with rounded corners?

房东的猫 提交于 2019-11-26 08:58:51
问题 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

Open-sided Android stroke?

三世轮回 提交于 2019-11-26 08:49:36
问题 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? 回答1: I achieved a good solution with this one: <?xml version="1.0" encoding="utf-8"?>