development

모양 xml의 테두리

big-blog 2020. 6. 11. 07:51
반응형

모양 xml의 테두리


버튼에 사용할 드로어 블을 만들려고합니다. 주위에 2px 테두리가있는이 채색을 원합니다.

테두리를 표시 할 수 없다는 것을 제외하고는 모든 것이 잘 작동합니다 ...

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

    <gradient android:startColor="@color/bar_clicked_dark"
        android:endColor="@color/bar_clicked_light"
        android:angle="90"/>

    <corners android:bottomLeftRadius="0dp"
        android:topLeftRadius="15dp"
        android:bottomRightRadius="15dp"
        android:topRightRadius="0dp" />

    <stroke android:width="2dp" 
        color="#ff00ffff" />

</shape>

color 속성의 접두사를 잊어 버린 것 같습니다. 시험

 <stroke android:width="2dp" android:color="#ff00ffff"/>

모양 xml로 테두리를 만들려면 다음을 사용해야합니다.

외부 경계의 경우 다음을 사용해야합니다.

<stroke/>

내부 배경의 경우 다음을 사용해야합니다.

<solid/>

모서리를 설정하려면 다음을 사용해야합니다.

<corners/>

테두리와 내부 요소 사이에 패딩을 원하면 다음을 사용해야합니다.

<padding/>

위의 항목을 사용한 shape xml 예제는 다음과 같습니다. 그것은 나를 위해 작동

<shape xmlns:android="http://schemas.android.com/apk/res/android"> 
  <stroke android:width="2dp" android:color="#D0CFCC" /> 
  <solid android:color="#F8F7F5" /> 
  <corners android:radius="10dp" />
  <padding android:left="2dp" android:top="2dp" android:right="2dp" android:bottom="2dp" />
</shape>

아래와 같이 drawable .xml을 추가 할 수 있습니다

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


    <stroke
        android:width="1dp"
        android:color="@color/color_C4CDD5"/>

    <corners android:radius="8dp"/>

    <solid
        android:color="@color/color_white"/>

</shape>

참고 URL : https://stackoverflow.com/questions/6698927/border-in-shape-xml

반응형