[Android]안드로이드 스튜디오 image(이미지) 출력해보기

    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"
    android:weightSum="10"                           //전체 10
    tools:context=".MainActivity"
    >
    
    <TextView
    android:id="@+id/textView"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:text="Kakao"
    android:layout_weight="1"                     //전체 10중의 1
    android:background="#FFFF00"
    android:gravity="center"
    android:textSize="28dp"
    android:textColor="#FF9999"
    />
    
    <ImageView
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_weight="9"                     //전체 10중의 9
    android:background="#0000FF"
    android:src="@drawable/kakao"
    android:scaleType="fitXY"                                  //이미지 최대로 맞추기
    
    />
    
    </LinearLayout>

     

     

    자바 파일

    package com.example.imageprint;
    
    import android.support.v7.app.AppCompatActivity;
    import android.os.Bundle;
    
    public class MainActivity extends AppCompatActivity {
    
    	@Override
    	protected void onCreate(Bundle savedInstanceState) {
    		super.onCreate(savedInstanceState);
    		setContentView(R.layout.activity_main);
    	}
    }

     

    출력 이미지

    댓글

    Designed by JB FACTORY