2013-07-11 3 views
0

Android : & 높이를 ShapeDrawable xml로 지정하는 방법이 있습니까? 이것은 놀랍게도 어려워 보인다. <size> 자식을 사용하면 작동하지 않으며 <shape>을 레이어 목록 항목으로 묶고 android:heightandroid:weight 특성을 설정하지 않습니다. shape 태그에서 항상 사용할 수xml에서 ShapeDrawable의 너비와 높이를 지정하는 방법이 있습니까?

<layer-list xmlns:android="http://schemas.android.com/apk/res/android" > 

<!-- 
How do you set shape size? 
The top/bottom attributes allow setting size via an inset 
from the parent element, but isn't there way to explicitly 
set width and height??? 
--> 
    <item 
     android:bottom="0dp" 
     android:left="0dp" 
     android:right="0dp" 
     android:top="0dp"> 
     <shape android:shape="rectangle" > 
      <solid android:color="#f00" /> 
      <stroke 
       android:width="1dp" 
       android:color="#0f0" /> 
     </shape> 
    </item> 

</layer-list> 

답변

0

sizepadding 태그입니다. 코드를 다시 확인하십시오.

<item> 
    <shape android:shape="rectangle"> 
     <solid android:color="#FFFFFF" /> 
     <size android:height="4dp" android:width="15dp" /> 
     <padding android:left="2dp" android:top="2dp" android:right="2dp" android:bottom="2dp" /> 
    </shape> 
</item> 
관련 문제