绘制多个形状与ShapeDrawable在XML与Android [英] Drawing multiple shapes with ShapeDrawable in xml with Android

查看:543
本文介绍了绘制多个形状与ShapeDrawable在XML与Android的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正在绘制在code自定义视图在画布上一些圆圈。圆是静态的,不会改变。我想用一个ShapeDrawable在XML中帮助清理我的code来吸引他们。我将有许多不同的可绘制,用户可从中选择,因此我并不想这样做,在code的。具有3个或4个XML可绘制大量的整洁,似乎给我。

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.

我已经创建了XML一个圆圈使用ShapeDrawable但我无法添加多个形状的XML。

I have created one circle in xml using a ShapeDrawable but am unable to add more than one shape to the xml.

如何添加多个形状使用ShapeDrawable XML文档。

How do I add multiple shapes to an xml document using ShapeDrawable.

推荐答案

我想我已经找到了解决多个图形添加到使用图层列表我的XML文件。 我还没有尝试过这还没有,但这似乎牛逼是正是我想要的形状将绘制他们的数组索引的顺序。

I think I have found a solution to add multiple shapes to my xml file using Layer-list. I havent tried this yet but this seems t be exactly what I want as the shapes will be draw in the order of their array index.

<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
   <item>
      <shape>
         <solid android:color="#FFF8F8F8" />
      </shape>
   </item>
   <item android:top="23px">
      <shape>
         <solid android:color="#FFE7E7E8" />
      </shape>
   </item>
</layer-list>

博客帖子

Android的文档

这篇关于绘制多个形状与ShapeDrawable在XML与Android的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆