GURU/AndroidStudio

[AndroidStudio] imageView

myejinni 2022. 7. 16. 00:31

실습 4-01 : 이미지를 출력하고 아래에는 이미지에 대한 정보를 출력

  • 위젯의 여백=10dp
  • 이미지 최대 가로, 세로 크기=200dp
  • 이미지와 이미지 설명=중앙에 배치
  • 글자 크기=20sp

 

<activity_main.xml>

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout 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"
    android:orientation="vertical"
    tools:context=".MainActivity">

    <ImageView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:src="@drawable/starry_night"
        android:maxHeight="200dp"
        android:maxWidth="200dp"
        android:layout_gravity="center_horizontal"
        android:layout_margin="10dp" />

    <TextView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_margin="10dp"
        android:gravity="center"
        android:text="Starry Night : 빈센트 반 고흐"

        android:textSize="20sp" />

</LinearLayout>

 

 

<실행결과>