Programing

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

crosscheck 2020. 10. 14. 07:29
반응형

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


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

<?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>

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


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

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


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"를 지정해야합니다 (여기에 또 다른 버그).


로부터 문서 :

참고 : 모든 모서리는 (처음에) 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>

밝은 색상의 결과는 세 가지 항목을 보여줍니다.

enter image description here

최종 결과 :

enter image description here

친애하는.


This bug is filed here. This is a bug of android devices having API level less than 12. You've to put correct versions of your layouts in drawable-v12 folder which will be used for API level 12 or higher. And an erroneous version(corners switched/reversed) of the same layout will be put in the default drawable folder which will be used by the devices having API level less than 12.

For example: I had to design a button with rounded corner at bottom-right.

In 'drawable' folder - button.xml: I had to make bottom-left corner rounded.

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

In 'drawable-v12' folder - button.xml: Correct version of the layout was placed here to be used for API level 12 or higher.

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

try this

<?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>

참고URL : https://stackoverflow.com/questions/3056232/how-to-make-a-shape-with-left-top-round-rounded-corner-and-left-bottom-rounded-c

반응형