1. 일반 버튼에 이미지.xml 을 백그라운드로 적용한 경우 효과가 좋다.
텍스트를 자유롭게 버튼에서 변경이 가능하다.
2. 버튼에 xml 이 아닌 이미지 적용시 버튼 효과가 나타나지 않는다. 또한 xml 을 적용한 다 할 지라도 android 에서
제공하는 이미지 적용은 효과가 없다.
3. 이미지 버튼 텍스트를 이미지와 함께 변경후 적용 해야 하기때문에 텍스트 변경이 어렵다.
R.layout.activity_main
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.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="kr.co.dothome.braverokmc.tutorial8.MainActivity">
<ImageButton
android:id="@+id/imageButton4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/b1"
app:srcCompat="@drawable/button1"
android:layout_marginRight="8dp"
app:layout_constraintRight_toRightOf="parent"
android:layout_marginLeft="8dp"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintTop_toTopOf="parent"
android:layout_marginTop="172dp"
app:layout_constraintBottom_toBottomOf="parent"
android:layout_marginBottom="8dp"
app:layout_constraintVertical_bias="0.282" />
<Button
android:id="@+id/button3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="37dp"
android:background="@drawable/star_btn"
android:text="1"
app:layout_constraintBottom_toTopOf="@+id/imageButton4"
tools:layout_editor_absoluteX="256dp" />
<Button
android:id="@+id/button4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
android:layout_marginLeft="46dp"
android:layout_marginRight="8dp"
android:background="@drawable/button2"
android:text="1"
android:textSize="36sp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintHorizontal_bias="0.05"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent" />
<ImageButton
android:id="@+id/imageButton5"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@android:drawable/btn_star_big_on"
app:srcCompat="@drawable/star_btn"
app:layout_constraintTop_toTopOf="parent"
android:layout_marginTop="8dp"
android:layout_marginBottom="8dp"
app:layout_constraintBottom_toTopOf="@+id/imageButton4"
android:layout_marginRight="8dp"
app:layout_constraintRight_toRightOf="parent"
android:layout_marginLeft="8dp"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintHorizontal_bias="0.27" />
</android.support.constraint.ConstraintLayout>
button1.xml
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_pressed="true" android:drawable="@drawable/b2" />
<item android:state_hovered="true" android:drawable="@drawable/q1" />
<item android:drawable="@drawable/b1" />
</selector>
button2.xml
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_pressed="true" android:drawable="@drawable/q1" />
<item android:drawable="@drawable/q2" />
</selector>
str_btn.xml
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@android:drawable/btn_star_big_on" />
<item android:state_pressed="true" android:drawable="@android:drawable/btn_star_big_off" />
</selector>
댓글 ( 4)
댓글 남기기