카테고리 없음
버튼(Button) 커스터마이징 / MaterialButton 포함
나계환ga4
2021. 5. 23. 23:11
1. drawable 폴더에 xml 생성
1-1 곡선만
ex) rounded button
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:padding="10dp" android:shape="rectangle" >
<solid android:color="#ebbdc5" />
<corners android:bottomLeftRadius="50dp"
android:bottomRightRadius="50dp"
android:topLeftRadius="50dp"
android:topRightRadius="50dp" />
</shape>
2. 버튼 클릭시 이펙트 주기
2-1 ripple effect
[안드로이드/JAVA] Error inflating class com.google.android.material.button.MaterialButton - JooTC
2-2 리플효과없는 버튼효과 주기
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_pressed="false">
<shape
android:padding="10dp"
android:shape="rectangle" >
<solid android:color="#ebbdc5" />
<corners
android:bottomLeftRadius="50dp"
android:bottomRightRadius="50dp"
android:topLeftRadius="50dp"
android:topRightRadius="50dp" />
</shape>
</item>
<item android:state_pressed="true">
<shape
android:padding="10dp"
android:shape="rectangle" >
<solid android:color="#fff4eb" />
<corners
android:bottomLeftRadius="50dp"
android:bottomRightRadius="50dp"
android:topLeftRadius="50dp"
android:topRightRadius="50dp" />
</shape>
</item>
</selector>
* Material Button의 그림자 없애기
xml 속성에 추가
android:stateListAnimator="@null"