본문 바로가기

AndroidStudio

9. quiz app / Linear layout / 코딩

반응형

Linear layout  ?  수평나열  default : horizontal

SRC : recousce 거 쓰는거임.

 

 

1. new project create

   contraint layout 지우고 Linear layuot 설정

 
2. layout ->  background color 변경 <layout.......
3.  ImageView. TextView ->    image 추가 / text 추가(@string으로 설정 다음강의서 할거임.) <ImageView>     /   <TextView>
4. layout- > vertical로 설정 <layout.............. android orientaton="vertical"
5 layout->gravity : "center" <layout.......
6. text 블럭 크기 설정 : padding  

 

 

activity_main.xml (디자인 text버전)

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"      //V layout 설정

    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"				//V   vertical
    android:gravity="center"					//V   gravity
    tools:context=".MainActivity"
    tools:ignore="ExtraText"
    android:background="@color/colorPrimaryDark">    //V   color설정

    <ImageView                                               //V    이미지 추가
        android:src="@drawable/ic_launcher_foreground"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"/>

    <TextView                                                //V   텍스트 추가
        android:id="@+id/answer_text_view"
        android:text="My test Question"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:padding="8dp" />					//V padding 텍스트블럭 크기 조절

</LinearLayout>