如何画椭圆的一些指针边缘 [英] How to draw oval with some pointer edge

查看:439
本文介绍了如何画椭圆的一些指针边缘的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我要画的东西椭圆形,一些指针的东西。我如何可以通过形状达到它的Andr​​oid?

I want to draw something oval with some pointer to something . How can I achieve it via shapes in Android?

推荐答案

如果我是做这样的事情,我会用附带的IDE中9patch抽奖工具。然而,在XML中我将定义可能包含code这样的绘制资源:

if i were to do something like this, i would use the 9patch draw tool provided with the IDE. However, in XML i would define a drawable resource that could contain code like this:

<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android" >

<item>
    <shape android:shape="rectangle">
        <size 
            android:width="100dp"
            android:height="100dp" />
        <solid android:color="#5EB888" />
        <corners android:radius="0dp"/>
    </shape>
</item>
<!-- default color for item at the top 5EB888 --> 
<item
    android:top="-40dp"
    android:bottom="65dp"
    android:right="-30dp">
    <rotate
        android:fromDegrees="45">
        <shape android:shape="rectangle">
            <solid android:color="#ffffff" />
        </shape>
    </rotate>
</item>

<item
    android:top="65dp"
    android:bottom="-40dp"
    android:right="-30dp">
    <rotate
        android:fromDegrees="-45">
        <shape android:shape="rectangle">
            <solid android:color="#ffffff" />
        </shape>
    </rotate>
</item>

</layer-list>

只需将此绘制为背景,以一个小部件,你会得到一个尖锐的矩形。在你的情况,你需要一个椭圆形。您只需切换的形状和大小的调整您的口味。希望这可以帮助。 结果你把它应用到一个按钮控件的外观像这样以后获取与此code:

Just apply this drawable as the background to a widget and you will get a pointed rectangle. In your case, you need an oval. You can just switch shapes and adjust sizes to your taste. Hope this helps. The result you get with this code after applying it to a button widget look like this:

更多关于ListLayer XML元素这里

more on ListLayer xml elements here

这篇关于如何画椭圆的一些指针边缘的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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