如何画椭圆的一些指针边缘椭圆、指针、边缘

由网友(你是我右手边的流年)分享简介:我要画的东西椭圆形,一些指针的东西。我如何可以通过形状达到它的Andr​​oid?I want to draw something oval with some pointer to something . How can I achieve it via shapes in Android?推荐答案如果我是做这样...

我要画的东西椭圆形,一些指针的东西。我如何可以通过形状达到它的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

阅读全文

相关推荐

最新文章