왼쪽 상단이 둥근 모서리와 왼쪽 하단이 둥근 모서리로 모양을 만드는 방법은 무엇입니까?
왼쪽 상단 모서리가 둥근 모서리와 왼쪽 하단 모서리가 둥근 모양을 만들고 싶습니다.
<?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>
밝은 색상의 결과는 세 가지 항목을 보여줍니다.
최종 결과 :
친애하는.
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>
'Programing' 카테고리의 다른 글
ENTRYPOINT 배열에서 Docker 환경 변수를 어떻게 사용합니까? (0) | 2020.10.14 |
---|---|
Netbeans에서 이상한 "상자"커서 및 선택 동작을 끄는 방법은 무엇입니까? (0) | 2020.10.14 |
JSLint 오류 : 모든 'var'선언을 함수의 맨 위로 이동 (0) | 2020.10.14 |
int (C #)의 첫 번째 숫자를 어떻게 얻을 수 있습니까? (0) | 2020.10.13 |
nodejs에서 node-sass를 사용할 때 libsass 바인딩을 찾을 수 없습니다. (0) | 2020.10.13 |