프로젝트에서 drawable 디렉토리 우클릭 → New → Drawable resource file → Available qualifiers에서 Locale 선택
세 디렉토리에 각각 다른 사진을 같은 이름으로 바꿔서 넣어 준다.
cats라는 디렉토리가 생성되고 세 가지 이미지가 모두 들어 있다.
프로젝트에서 res 우클릭 → New → Android Resource Directory → Available qualifiers에서 Locale 선택
아까와 똑같이 언어 및 국가를 다르게 선택해 두 가지를 만든다.
values\string.xml
<resources>
<string name="app_name">My Application</string>
<string name="text">My Sightseeing Area</string>
</resources>
en\strings.xml
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="app_name">Sightseeing Application</string>
<string name="text">US Sightseeing</string>
</resources>
ko-rKR\strings.xml
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="app_name">관광명소 소개</string>
<string name="text">남대문 관광명소</string>
</resources>
activity_main.xml
<?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">
<TextView
android:id="@+id/textView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/app_name"
android:textSize="30sp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.498"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.2" />
<ImageView
android:id="@+id/imageView"
android:layout_width="248dp"
android:layout_height="221dp"
android:layout_marginStart="80dp"
android:layout_marginTop="120dp"
android:scaleType="fitXY"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/textView"
app:layout_constraintVertical_bias="0.161"
app:srcCompat="@drawable/cats" />
<TextView
android:id="@+id/textView3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="108dp"
android:layout_marginTop="48dp"
android:text="@string/text"
android:textSize="24sp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/imageView" />
</androidx.constraintlayout.widget.ConstraintLayout>
'안드로이드 Android' 카테고리의 다른 글
[모바일프로그래밍] 9-3 MediaPlayer 사용하는 방법 (0) | 2020.11.08 |
---|---|
[모바일프로그래밍] 9-2 멀티미디어 데이터 (0) | 2020.11.08 |
[모바일프로그래밍] 8-3 암시적 인텐트 (0) | 2020.10.29 |
[모바일프로그래밍] 8-2 명시적 인텐트 (0) | 2020.10.28 |
[모바일프로그래밍] 7-5 서피스 뷰 (0) | 2020.10.16 |