2012-11-30 95 views
3

我正在做一個遊戲應用程序。在那個應用程序中,一個硬幣必須通過視圖。但我不知道該怎麼做。如何在橢圓形狀內繪製一個點

我的代碼是:

<?xml version="1.0" encoding="utf-8"?> 
<shape xmlns:android="http://schemas.android.com/apk/res/android" 
android:shape="oval" > 
<gradient 
    android:angle="135" 
    android:centerColor="#C4A5A5" 
    android:endColor="#875050" 
    android:startColor="#875050" /> 
<stroke 
    android:width="1dp" 
    android:color="#781A1A" 
    /> 
</shape> 

而我的UI是:

enter image description here

我想通過這個影像移動硬幣。

回答

0

使用此代碼........

RoundRectShape rs = new RoundRectShape(new float[] { 15, 15, 15, 15, 15, 15, 15, 15 }, null, null); 
    ShapeDrawable sd = new ShapeDrawable(rs); 


    Button btnlogin = new Button(NativeCosmosActivity.this); 
    btnlogin.setBackgroundDrawable(sd);// this line converts Button to Ovel shape.. If you increase value 15 to 30, 
// you will get more Ovel shape.