[android] 왼쪽 상단이 둥근 모서리와 왼쪽 하단이 둥근 모서리로 모양을 만드는 방법은 무엇입니까?

왼쪽 상단 모서리가 둥근 모서리와 왼쪽 하단 모서리가 둥근 모양을 만들고 싶습니다.

<?xml version="1.0" encoding="UTF-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
    <solid android:color="#555555"/>

    <stroke android:width="3dp"
            android:color="#555555"
            />

    <padding android:left="1dp"
             android:top="1dp"
             android:right="1dp"
             android:bottom="1dp"
             />

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

그러나 위의 모양은 내가 원하는 것을 얻지 못했습니다. 둥근 모서리가없는 직사각형을 제공합니다.



답변

http://code.google.com/p/android/issues/detail?id=939 버그로 보입니다 .

마지막으로 다음과 같이 작성해야합니다.

 <stroke android:width="3dp"
         android:color="#555555"
         />

 <padding android:left="1dp"
          android:top="1dp"
          android:right="1dp"
          android:bottom="1dp"
          />

 <corners android:radius="1dp"
  android:bottomRightRadius="2dp" android:bottomLeftRadius="0dp"
  android:topLeftRadius="2dp" android:topRightRadius="0dp"/>

왼쪽 아래 둥근 모서리에 android : bottomRightRadius = “2dp”를 지정해야합니다 (여기에 또 다른 버그).


답변

이 질문은 이미 답변되었지만 (bottomLeftRadius 및 bottomRightRadius가 반전되는 버그),이 버그는 android 3.1 (api 레벨 12-에뮬레이터에서 테스트 됨)에서 수정되었습니다.

따라서 드로어 블이 모든 플랫폼에서 올바르게 보이도록하려면 앱의 res / drawable-v12 폴더에 드로어 블의 “수정 된”버전 (즉, xml에서 왼쪽 / 오른쪽 하단 반경이 실제로 올바른 위치)을 넣어야합니다. 이렇게하면 Android 버전> = 12를 사용하는 모든 기기는 올바른 드로어 블 파일을 사용하고, 이전 버전의 Android를 사용하는 기기는 res / drawables 폴더에있는 “해결 방법”드로어 블을 사용합니다.


답변

로부터 문서 :

참고 : 모든 모서리는 (처음에) 1보다 큰 모서리 반경을 제공해야합니다. 그렇지 않으면 모서리가 둥글 지 않습니다. 특정 모서리를 둥글게하지 않으려면 해결 방법은 android : radius를 사용하여 기본 모서리 반경을 1보다 크게 설정 한 다음 각 모서리를 원하는 값으로 재정의하고 0 ( “0dp”)을 제공하는 것입니다. ) 둥근 모서리를 원하지 않는 곳.

예를 들어 android:radius="<bigger than 1dp>"원하는 것을 할 수 있도록 설정 해야합니다.

<corners
    android:radius="2dp"
    android:bottomRightRadius="0dp"
    android:topRightRadius="0dp"/>


답변

반경에 매우 작은 숫자를 사용할 수도 있습니다. ‘

<corners
  android:bottomRightRadius="0.1dp" android:bottomLeftRadius="2dp"
 android:topLeftRadius="2dp" android:topRightRadius="0.1dp" />


답변

다른 경우에는 모든 API 수준에 대한 솔루션이 있습니다. 항목을 서로 위에 배치 할 수 있습니다. 예 :

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

<!-- my firt item with 4 corners radius(8dp)
 -->
    <item>
        <shape>
            <solid
                android:angle="270.0"
                android:color="#3D689A" />

            <corners android:topLeftRadius="8dp" />
        </shape>
    </item>
<!-- my second item is on top right for a fake corner radius(0dp)
 -->
    <item
        android:bottom="30dp"
        android:left="50dp">
        <shape>
            <solid android:color="#5C83AF" />
        </shape>
    </item>
<!-- my third item is on bottom left for a fake corner radius(0dp)
 -->
    <item
        android:right="50dp"
        android:top="30dp">
        <shape>
            <solid android:color="#5C83AF" />
        </shape>
    </item>

</layer-list>

세 가지 항목을 보여주는 밝은 색상의 결과 :

여기에 이미지 설명 입력

최종 결과 :

여기에 이미지 설명 입력

친애하는.


답변

이 버그는 여기에 있습니다 . 이것은 API 레벨이 12 미만인 Android 기기의 버그입니다. 올바른 버전의 레이아웃을 API 레벨 12 이상에 사용될 drawable-v12 폴더에 넣어야합니다. 그리고 동일한 레이아웃의 잘못된 버전 (코너 전환 / 반전)은 API 수준이 12 미만인 장치에서 사용할 기본 드로어 블 폴더에 저장됩니다.

예 : 오른쪽 하단에 둥근 모서리가있는 버튼을 디자인해야했습니다.

‘drawable’폴더-button.xml : 왼쪽 하단 모서리를 둥글게 만들어야했습니다.

<shape>
    <corners android:bottomLeftRadius="15dp"/>
</shape>

‘drawable-v12’폴더-button.xml : API 레벨 12 이상에서 사용할 수 있도록 올바른 버전의 레이아웃이 여기에 배치되었습니다.

<shape>
    <corners android:bottomLeftRadius="15dp"/>
</shape>


답변

이 시도

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<solid android:color="@color/upkia"/>
<corners android:radius="10dp"
    android:topRightRadius="0dp"
    android:bottomRightRadius="0dp" />
</shape>