240402 TIL - 앞으로의 TIL, Theme과 context, adjustViewBounds, 권한 요청

DoDoBest

·

2024. 4. 2. 23:59

앞으로의 TIL

앞으로 문서로써 작성할만큼의 내용을 새롭게 배우지 않은 경우, TIL을 작성하지 않을 계획입니다.

TIL을 작성하지 않는다고 해서 제가 학습을 하지 않는 것은 아닙니다. 다만, 블로그에 내용이 없는 글의 빈도를 줄이고자 합니다.

 

Theme과 Context

Context에는 Theme에 대한 정보가 없습니다. 그래서 Theme 정보를 필요로 하는 곳에 baseContext나 applicationContext를 전달하면 아래와 같은 에러가 발생합니다.

 

MaterialAlertDialogBuilder(baseContext)
            .setTitle("이미지 권한 안내")
            .setMessage("갤러리에 있는 이미지에 접근하려면 저장소 권한이 필요합니다.")

 

java.lang.IllegalArgumentException: The style on this component requires your app theme to be Theme.AppCompat (or a descendant)

 

따라서 Context를 상속하며, Theme에 대한 정보가 있는 Activity를 전달해야 합니다.

MaterialAlertDialogBuilder(this)
            .setTitle("이미지 권한 안내")
            .setMessage("갤러리에 있는 이미지에 접근하려면 저장소 권한이 필요합니다.")

 

https://stackoverflow.com/questions/61108374/material-alert-dialog-the-style-on-this-component-requires-your-app-theme-to-be/61108467#61108467

 

Material Alert Dialog, The style on this component requires your app theme to be Theme.AppCompat

I'm trying to make a MaterialAlertDialog but I keep getting the following error no matter what java.lang.IllegalArgumentException: The style on this component requires your app theme to be Theme.

stackoverflow.com

 

ImageView에 scaleType 이용시 주의사항

scaleType을 지정하더라도, View는 원래 이미지 크기만큼 영역을 차지합니다. scaleType으로 조정된 이미지 크기와 View의 영역을 일치시키려면 adjustViewBounds를 true로 설정해야 합니다.

 

왼쪽은 default(false), 오른쪽은 true로 설정할 때를 보여줍니다.

 

https://stackoverflow.com/a/26002830/11722881

 

android imageview wrap_content

Hello everyone and thanks for your help. I have a project in Android Studio. I am using an ImageView inside vertical LinearLayout. Here are my parameters; <ImageView android:layout_width="

stackoverflow.com

 

권한 요청 관련 구현

Android에서 SDK 버전에 따른 권한 요청을 처리하고 이미지를 불러오는 기능을 구현했습니다.

https://dodobest.tistory.com/92

 

Android 이미지 읽기 권한 다루기

권한 없이 이미지 파일을 사용자로부터 입력 받는 방법 Photo picker를 이용하거나 https://developer.android.com/training/data-storage/shared/photopicker 사진 선택 도구 | Android Developers DataStore offers a more modern way of

dodobest.tistory.com