본문 바로가기

안드로이드

두 종류의 버튼 모양 만들기

반응형

 

 

activity_main

<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".MainActivity">

    <Button
        android:id="@+id/button"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginTop="224dp"
        android:background="@drawable/dr01"
        android:text="Button"
        android:textColor="#9FC93C"
        app:backgroundTint="#0000"
        app:backgroundTintMode="add"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintHorizontal_bias="0.498"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent" />

    <Button
        android:id="@+id/button2"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginBottom="356dp"
        android:background="@drawable/dr02"
        android:text="Button"
        app:backgroundTint="#0000"
        app:backgroundTintMode="add"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintHorizontal_bias="0.498"
        app:layout_constraintStart_toStartOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>

 

 

res/drawable/dr01.xml

<?xml version="1.0" encoding="utf-8"?>

<shape xmlns:android="http://schemas.android.com/apk/res/android"
    android:shape="rectangle">
    <stroke
        android:width="4dp"
        android:color="#ff9FC93C"></stroke>

    <solid android:color="#0000"></solid>
</shape>

 

 

res/drawable/dr02.xml

<?xml version="1.0" encoding="utf-8"?>

<shape xmlns:android="http://schemas.android.com/apk/res/android"
    android:shape="rectangle">

    <solid android:color="#9FC93C"></solid>

    <corners android:radius="15dp"></corners>
</shape>
반응형

'안드로이드' 카테고리의 다른 글

부분 화면  (0) 2021.10.13
시크바와 프로그레스바 보여주기  (0) 2021.10.12
프로그레스바  (0) 2021.10.12
알림 대화상자  (0) 2021.10.12
토스트 모양과 위치 바꾸기, 스낵바 띄우기  (0) 2021.10.12