안드로이드 개발 질문/답변
(글 수 45,052)
layout에서 버튼1개와 이미지뷰1개를 겹쳐놓고 버튼을 눌렀을경우 invisible 이미지가 visible로되어 저장되게 하는법을 알고싶습니다.
해당버튼이있는 액티비티에서 어떤 구문을 사용하여야하는지 알고싶습니다.
레이아웃에 버튼과 이미지를 겹쳐놓았습니다.
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity"
android:background="#eb773f"
>
<TextView
android:id="@+id/title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Mobile Stamp"
android:textColor="#552b0f"
android:background="#00000000"
android:layout_marginLeft="24dp"
android:layout_marginTop="14dp"
android:textSize="24dp"
android:layout_centerHorizontal="true"
/>
<Button
android:id="@+id/stampline1"
android:layout_width="55dp"
android:layout_height="55dp"
android:background="@drawable/stamp1"
android:layout_below="@id/title"
android:layout_marginTop="25dp"
android:layout_marginLeft="4dp"
/>
<ImageView
android:id="@+id/stampview1"
android:layout_width="55dp"
android:layout_height="55dp"
android:background="@drawable/stamp2"
android:layout_below="@id/title"
android:layout_marginTop="25dp"
android:layout_marginLeft="4dp"
android:visibility="invisible"
/>
읽어주셔서 감사합니다.
이렇게 까지 해야 되는 이유가 있나요?
그냥 ImageButton 을 이용해서 백그라운드에 네모 이미지를 넣고
별도의 boolean 값을 통해서 imagebutton 이 클릭 될때 마다 boolean 값을 변경하고 이를 바탕으로
true 면 setImage~() 메서드를 통해 이미지를 삽입했다가 false 면 다시 이미지를 없애는 방향으로 하시면 되지 않을까 싶네요.