ImageButton을 생성하고 버튼의 이미지를 설정할 때 이미지가 버튼의 크기보다 큰 경우에 이미지가 전체가 아니라 일부만 짤려서 보이는 경우가 발생한다
<ImageButton
android:layout_width="250dp"
android:layout_height="250dp"
android:src="@drawable/image"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent" />
이렇게 이미지가 짤려서 나올 때는
android:scaleType = " "
android:padding = " "
위의 코드를 통해 이미지를 조절하면 됩니다.
ex) 이미지를 버튼에 딱 맞게 조절
android:scaleType="centerCrop"
android:padding="0dp"
ex)이미지 버튼의 중앙에 위치하게 조절
android:scaleType="fitCenter"
android:padding="10dp"
'Android' 카테고리의 다른 글
Android] Button 클릭 이벤트 처리 (0) | 2022.01.24 |
---|---|
Android] Intent (0) | 2022.01.24 |
Android] Button 배경 색 설정 시 변경 안되는 경우 (0) | 2022.01.16 |
Android] Button 모양 설정 (0) | 2022.01.16 |
Android] Button 클릭 시 화면 전환(Intent사용) (0) | 2022.01.12 |