Android 원 각 테두리 대화 상자 구현 방법
최근 에 원 각 테두리 의 대화 상자 디자인 도 를 실현 하려 면 인터넷 에서 여러 가지 실현 을 찾 아 보 았 는데 차이 가 많 지 않 습 니 다.그 중에서 영감 을 얻 고 다른 방식 을 실 현 했 습 니 다
layer-list
:먼저 실현 효 과 를 살 펴 보면 다음 과 같다.
우선 drawable 디 렉 터 리 에 원 각 배경 파일 dialog 를 정의 합 니 다.corner_bg.xml
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item>
<shape android:shape="rectangle">
<solid android:color="@color/dark_green" />
<corners android:radius="6dp" /> <!-- -->
</shape>
</item>
<item android:top="8dp" android:right="8dp" android:left="8dp" android:bottom="8dp"> <!-- -->
<shape android:shape="rectangle">
<solid android:color="@color/white"/>
<corners android:radius="6dp" />
<padding android:bottom="8dp" android:left="8dp" android:right="8dp" android:top="8dp"/>
</shape>
</item>
</layer-list>
styles.xml 파일 에서 대화 상자 테마 스타일 을 정의 합 니 다.
<style name="myCorDialog" parent="android:style/Theme.Dialog">
<item name="android:windowBackground">@drawable/dialog_corner_bg</item> <!-- -->
<item name="android:windowNoTitle">true</item> <!-- -->
<item name="android:backgroundDimEnabled">true</item> <!-- -->
</style>
실례 화 대화 상자 builder 에서 스타일 을 지정 하면 됩 니 다
AlertDialog.Builder builder = new AlertDialog.Builder(this, R.style.myCorDialog);
총결산이상 은 이 글 의 전체 내용 입 니 다.본 논문 의 내용 이 여러분 의 학습 이나 업무 에 어느 정도 도움 이 되 기 를 바 랍 니 다.궁금 한 점 이 있 으 면 댓 글 을 남 겨 주 십시오.
이 내용에 흥미가 있습니까?
현재 기사가 여러분의 문제를 해결하지 못하는 경우 AI 엔진은 머신러닝 분석(스마트 모델이 방금 만들어져 부정확한 경우가 있을 수 있음)을 통해 가장 유사한 기사를 추천합니다:
Kotlin의 기초 - 2부지난 글에서는 Kotlin이 무엇인지, Kotlin의 특징, Kotlin에서 변수 및 데이터 유형을 선언하는 방법과 같은 Kotlin의 기본 개념에 대해 배웠습니다. 유형 변환은 데이터 변수의 한 유형을 다른 데이터...
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
CC BY-SA 2.5, CC BY-SA 3.0 및 CC BY-SA 4.0에 따라 라이센스가 부여됩니다.