2011-10-21 6 views
1

私はAndroidで丸い角の四角形を定義しようとしていますが、角の丸い四角形しか得られません。Android drawable shape:Rectangleを正方形にします

/resを/このような描画可能なルックスで私のxml:

<?xml version="1.0" encoding="utf-8"?> 
<selector 
xmlns:android="http://schemas.android.com/apk/res/android" 
xmlns:app="http://schemas.android.com/apk/res/uk.co.alexlydiate.sequencer"> 

<item android:state_pressed="true" 
     app:state_playing = "true" > 
    <shape> 
     <stroke 
      android:width="2dp" 
      android:color="@color/red" /> 
     <corners 
      android:radius="3dp" /> 
     <padding 
      android:left="10dp" 
      android:top="10dp" 
      android:right="10dp" 
      android:bottom="10dp" /> 
     <solid 
      android:color="@color/blue" /> 
     <size 
      android:width="3dp" 
      android:height="3dp" /> 
    </shape>   
</item> 
</selector> 

そして、すべては私が事の広場が、そのような幸運を作っ期待していると思います

<size android:width="3dp" android:height="3dp" /> 

除いて正常に動作します。

私のレイアウトは次のようになります。

<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:id="@+id/grid8x8" 
    android:gravity="center" 
     android:layout_width="fill_parent" 
     android:layout_height="fill_parent"> 

<uk.co.alexlydiate.sequencer.Key android:background="@drawable/key"   
    android:id="@+id/keyA1" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_weight="1" android:layout_margin="2px" 
/> 
<uk.co.alexlydiate.sequencer.Key android:background="@drawable/key"   
    android:id="@+id/keyA2" 
    android:layout_below="@+id/keyA1" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_weight="1" android:layout_margin="2px" 
/> 
</RelativeLayout> 

誰もが任意の鮮やかなアイデアを得ましたか。ありがとう!

答えて

0

AFAIK:shapesは、Viewのレイアウトに従って伸縮します。 代わりにの正方形Viewを定義し、shapeの背景を設定することができます。

OR

背景

などの画像を使用します
関連する問題