파이썬 플라스크 서버(가장 간단한 서버 )

템플레이트를 html로 사용한다

 

 

 

 

 

 

res폴더 안의 폴더명은 이미 정해져 있다

 

 

위처럼 하지 않고 res에서 바로 뉴리소스파일을 선택해도 아래와 같이 가능

 

 

 

 

menu_main.xml

꺾쇠를 닫아놓고 작업해야 에러를 확인 할 수 있다

 

 

 

 

 

 

인플레이터 (메모리에 띄워주는 역할)

- xml파일을 자바코드로 바꾸고 메모리에 올리고, new 해준 것을 그림을 그린다

 

 

 

 

기본 제공 메뉴

액션바는 기본제공 메뉴를 쓰지않고 직접만들어 쓰는 것이 많다고 한다

 

 

 

 

 

 

라이브러리는 androidx 로 되어있는 것을 꼭 쓰자

 

 

androidx가 아닌 라이브러리를 쓰면 플레이스토어에 배포가 되지 않는다

 

 

툴바의 고질적인 문제 왼쪽에 빈공간이 생기는 점

공간 없애는 방법이 있다

 

 

 

 

빈공간이 사라졌다

 

 

이러한 빈공간을 inset이라고 한다

카메라구멍이나 통화 스피커나 키보드 등 화면이 안그려도되는 빈공간을 인셋이라고 한다

 

 

레이아웃이나 일반 컴포넌트면 merge 안에 넣는것이 좋고 Toolbar는 굳이 넣을 필요 없다

 

 

<?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"
    tools:context=".MainActivity">

    <include layout="@layout/toolbar_main"/>

</LinearLayout>

include 하여 툴바를 추가한다

 

 

메인과 합쳐졌다

 

 

 

 

https://material.io/develop/android/components/navigation-view

 

Material Design

Build beautiful, usable products faster. Material Design is an adaptable system—backed by open-source code—that helps teams build high quality digital experiences.

material.io

 

 

옆으로 슬라이딩 되는 메뉴가 있다면 draw layout이라고 보면된다

 

 

 

 

 

 

----------------------

롬복 설치하는 법 file setting 검색

 

 

그래들 디펜던시 추가

--------------------

 

 

머터리얼 api 추가하는 법

 

 

 

 

 

----------------

 

 

 

 

 

----------------------

 

package com.jaybon.app2;

import androidx.appcompat.app.AppCompatActivity;

import android.os.Bundle;
import android.util.Log;
import android.view.Menu;
import android.view.View;
import android.widget.ImageView;

public class MainActivity extends AppCompatActivity {

    private static final String TAG = "Main_Activity";

    private ImageView ivMenu;
    
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        
        ivMenu = findViewById(R.id.iv_menu);
        
        ivMenu.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Log.d(TAG, "onClick: 클릭됨");
            }
        });
    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {

        getMenuInflater().inflate(R.menu.menu_main, menu);
        return false;
    }
}

 

 

 

 

슬라이딩 뷰에 접근하려면 드로우 레이아웃의 id가 필요하다

 

 

 

 

ctrl + Q 하면

 

 

 

 

 

 

------------------

툴바를 커스텀해서 넣으면 그 툴바는 액션바로 인식하지 못한다

액션바로 인식하도록 만들어야함

------------------

 

 

 

 

 

 

--------------------------

땡땡땡1

 

 

 

 

 

menu_side로 바꾸기

---------------------------

 

나중에 해보기

https://material.io/components/menus

 

Material Design

Build beautiful, usable products faster. Material Design is an adaptable system—backed by open-source code—that helps teams build high quality digital experiences.

material.io

 

 

http://i5on9i.blogspot.com/2013/12/action-bar-option-menu-icon.html

 

[컴][안드로이드] action bar 위의 option menu icon 바꾸는 방법

option menu icon 바꾸는 방법 / 옵션 메뉴 아이콘 변경 / 액션바의 옵션 메뉴 아이콘 변경 option menu 가 존재하면 action bar 에 icon 이 보여진다. 보통 아래와 같은 모양으로 나타난다. 이 보양을 다른 아.

i5on9i.blogspot.com

 

----------------------------

 

옵션메뉴 버튼 색깔 바꾸기

https://blog.naver.com/PostView.nhn?blogId=greatsk553&logNo=221038610508&parentCategoryNo=&categoryNo=33&viewDate=&isShowPopularPosts=true&from=search

 

안드로이드 옵션 메뉴 버튼 색상 바꾸기

안드로이드 옵션 메뉴 버튼 색상 바꾸기.안드로이드 액티비티 툴바에 보면 화살표로 가리킨 아이콘이 있다....

blog.naver.com

----------------------------

 

 

 

--------------------

 

액티비티를 여러개 만들어서 이동해야하는데

 

액티비티 전환없이 사용

 

화면하나에 여러개의 프래그먼트를 넣고

프래그먼트를 이동하면서 사용하면 하나의 페이지로 여러가지 화면을 사용할 수 있다

-------------------------------

탭 레이아웃

 

 

 

 

 

 

 

https://material.io/develop/android/components/tabs

 

Material Design

Build beautiful, usable products faster. Material Design is an adaptable system—backed by open-source code—that helps teams build high quality digital experiences.

material.io

 

 

 

 

탭레이아웃으로 프래그먼트를 쓰면 해당 아이템들만 뜬다

 

----

자바코드로도 가능

 

 

-----------------

 

뷰페이저는 탭레이아웃과 연결시킬 수 있다

 

 

이 3개는 메모리에 안뜬다 (코드로 띄워야함)

 

 

 

 

프래그먼트도 자기만의 자바파일이 필요하다

 

 

 

 

 

 

프래그먼트를 바꿔주는 어댑터가 필요하다

 

 

ctrl + o

 

 

 

 

 

 

 

 

-------------

안드로이드에서는 데이터를 이용할 때에는 무조건 어댑터를 쓰게되어있다

------------

 

책 287 프래그먼트 확인

--------------

 

프래그먼트 쉬운버전

 

 

 

어댑터를 안만들것이기 때문에 메모리에 띄워줄 애가 필요하다

onCreateView

 

 

자바파일만들기

 

 

 

 

MainActivity.java

package com.jaybon.frag2;

import androidx.appcompat.app.AppCompatActivity;
import androidx.fragment.app.Fragment;

import android.os.Bundle;
import android.view.View;
import android.widget.Button;

public class MainActivity extends AppCompatActivity {

    private Button btn1, btn2;
    private Fragment fragment1, fragment2;


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        fragment1 = new Frag1();
        fragment2 = new Frag2();

        btn1 = findViewById(R.id.btn1);
        btn2 = findViewById(R.id.btn2);

        btn1.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {

                // commit이 호출될때 onCreateView가 실행된다
                // onCreateView에 R.id.frame_container가 들어간다
                getSupportFragmentManager().beginTransaction().replace(R.id.frame_container, fragment1).commit();
            }
        });

        btn2.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {

                // commit이 호출될때 onCreateView가 실행된다
                // onCreateView에 R.id.frame_container가 들어간다
                getSupportFragmentManager().beginTransaction().replace(R.id.frame_container, fragment2).commit();
            }
        });

    }
}

 

 

 

 

간단한것은 비긴트랜잭션 // 다양한건 뷰페이저와 어댑터

 

--------------

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

타입에 따라 기본 키보드가 달라지기 때문에 잘 맟추어서 설정하는 것이 좋다

 

 

----------------

(나중에)

 

 

-----------------

 

 

 

 

 

 

 

 

웹뷰 - 앱안의 웹 브라우저라고 생각하면 된다

 

 

------------

자바코드로만 앱을 만들면 [네이티브 앱]

반응형 웹으로 앱을 만들면 [웹앱]

웹뷰를 이용해서 웹을 보이도록 만들면 [하이브리드 앱]

---------------

 

 

프로그래스바 //별점

 

 

사진이나 영상을 올릴 때 사용

 

 

spinner - flash메시지?

 

 

 

 

 

 

저기들어가면 라이브러리를 어떻게 사용하는지 나옴

 

 

 

 

 

 

 

 

책 189페이지

drawable 상태드로어블 만들어보기

 

 

 

 

 

눌렸을시 꽉찬 하트모양

 

 

버튼 배경에 드로어블설정

 

 

 

 

----------------

 

 

 

xml 규칙 변수명 언더바

 

 

모서리가 둥근버튼

 

 

드로어블

soild 버튼 안의 색깔

stroke 버튼 테두리 색깔

corners 모서리 둥글기

 

 

더보기
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
    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">

    <LinearLayout
        android:paddingTop="80dp"
        android:paddingLeft="25dp"
        android:paddingRight="25dp"
        android:orientation="vertical"
        android:layout_width="match_parent"
        android:layout_height="match_parent">


        <ImageView
            android:id="@+id/iv_logo"
            android:layout_width="match_parent"
            android:layout_height="155dp"
            android:layout_marginBottom="10dp"
            app:srcCompat="@drawable/instagram_logo" />

        <com.google.android.material.textfield.TextInputLayout
            android:id="@+id/tf_email"
            android:layout_marginTop="8dp"
            android:layout_marginBottom="8dp"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:hint="Email">

            <com.google.android.material.textfield.TextInputEditText
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:inputType="textEmailAddress"
                />

        </com.google.android.material.textfield.TextInputLayout>

        <com.google.android.material.textfield.TextInputLayout
            android:id="@+id/tf_password"
            android:layout_marginTop="8dp"
            android:layout_marginBottom="8dp"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:hint="Password">

            <com.google.android.material.textfield.TextInputEditText
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:inputType="textPassword"
                />

        </com.google.android.material.textfield.TextInputLayout>

        <androidx.appcompat.widget.AppCompatButton
            android:layout_width="match_parent"
            android:layout_height="60dp"
            android:layout_marginTop="10dp"
            android:background="@drawable/white_rounded_button"
            android:text="Login" />


    </LinearLayout>

</RelativeLayout>

 

 

 

 

 

 

 

 

 

 

 

 

다른 것은 그대로 메인만 언더바 주자(검색 용이)

 

 

 

 

 

 

 

 

메인쓰레드는 UI 쓰레드와 이벤트 분배 쓰레드를 호출하고 죽는다

UI 쓰레드 - 

이벤트 분배 쓰레드 - 버튼 클릭 등 할 때 UI 쓰레드에 콜백

 

다운로드시에도 UI쓰레드는 그림을 그려야 하기 때문에 새로운 쓰레드로 다운로드 해야한다

 

 

더보기
package com.jaybon.myapplication;

import androidx.appcompat.app.AppCompatActivity;

import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.ProgressBar;

public class MainActivity extends AppCompatActivity {

    private static final String TAG = "Main_Activity"; // 다른 것은 그대로 메인만 언더바 주자(검색 용이)
    // 제일 위에 전역으로 적는 것은~
    // 컴포넌트들을 모두 전역으로 올려서 선언한다

    private ProgressBar pgbDownload;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        initComponent(); // 컴포넌트 초기화 (개발자 임의 작명)

        imageDownload();

        Log.d(TAG, "onCreate: 테스트1");
    }

    private void  initComponent(){ // 여기서 컴포넌트들을 찾아주고 프로그래밍 한다

        pgbDownload = findViewById(R.id.pgb_download);
        // 화면에 그리지 않으면 연산을 하지 않는다
    }

    private void imageDownload(){
        new Thread(new Runnable() {
            @Override
            public void run() {
                Log.d(TAG, "run: 다운로드 쓰레드 시작");
                try {
                    Thread.sleep(5000);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
                Log.d(TAG, "run: 다운로드 쓰레드 종료");
                pgbDownload.setVisibility(View.INVISIBLE);
            }
        }).start();
    }



}

 

 

 

 

setOn이 안드로이드의 리스너 추가 함수이다

 

 

레벨8 설치햐야 람다식을 사용할 수 있다

 

 

숫자 증감

더보기
<?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/tv_count"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="0"
        android:textSize="36sp"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintHorizontal_bias="0.498"
        app:layout_constraintLeft_toLeftOf="parent"
        app:layout_constraintRight_toRightOf="parent"
        app:layout_constraintTop_toTopOf="parent"
        app:layout_constraintVertical_bias="0.329" />

    <Button
        android:id="@+id/btn_add"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="증가"
        app:layout_constraintBottom_toTopOf="@+id/guideline"
        app:layout_constraintEnd_toStartOf="@+id/btn_minus"
        app:layout_constraintHorizontal_bias="0.477"
        app:layout_constraintStart_toStartOf="parent" />

    <Button
        android:id="@+id/btn_minus"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginEnd="68dp"
        android:text="감소"
        app:layout_constraintBottom_toTopOf="@+id/guideline"
        app:layout_constraintEnd_toEndOf="parent" />

    <androidx.constraintlayout.widget.Guideline
        android:id="@+id/guideline"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:orientation="horizontal"
        app:layout_constraintGuide_end="248dp" />

</androidx.constraintlayout.widget.ConstraintLayout>

 

 

더보기
package com.jaybon.countingapp;

import androidx.appcompat.app.AppCompatActivity;

import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;

public class MainActivity extends AppCompatActivity {

    private static final String TAG = "Main_Activity";
    private Button btnAdd, btnMinus;
    private TextView tvCount;
    private int count = 0;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        tvCount = findViewById(R.id.tv_count);
        tvCount.setText(count+"");

        btnAdd = findViewById(R.id.btn_add);
        btnMinus = findViewById(R.id.btn_minus);

        btnAdd.setOnClickListener((View view)->{
            count++;
            tvCount.setText(count+"");
        });

        btnMinus.setOnClickListener((View view)->{
            if(count > 0){
                count--;
                tvCount.setText(count+"");
            }
        });

//        btnAdd.setOnClickListener(new View.OnClickListener() {
//            @Override
//            public void onClick(View view) {
//                count++;
//                tvCount.setText(count);
//            }
//        });
//
//        btnMinus.setOnClickListener(new View.OnClickListener() {
//            @Override
//            public void onClick(View view) {
//                count--;
//                tvCount.setText(count);
//            }
//        });

    }

}

 

 

 

----------------

 

모든 객체(버튼이나 라디오 박스 등)는 View 를 상속받는다 (View의 자식 )

View는 context를 가지고 있고 context는 OS가 보내준다

 

Button btnTemp = (Button)view; // 버튼의 context를 가져올 수 있다 

 

----------------

계산기 만들기

eval 함수(자바스크립트)

안드로이드에서 자바스크립트 함수를 땡겨 올 수 있다

 

https://github.com/APISENSE/rhino-android

 

APISENSE/rhino-android

Give access to RhinoScriptEngine from the JSR223 interfaces on Android JRE. - APISENSE/rhino-android

github.com

 

build.gradle

더보기
apply plugin: 'com.android.application'

android {
    compileSdkVersion 29
    buildToolsVersion "30.0.0"

    defaultConfig {
        applicationId "com.jaybon.countingapp"
        minSdkVersion 21
        targetSdkVersion 29
        versionCode 1
        versionName "1.0"

        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
    }

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }
}

dependencies {
    implementation fileTree(dir: "libs", include: ["*.jar"])
    implementation 'androidx.appcompat:appcompat:1.1.0'
    implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'androidx.test.ext:junit:1.1.1'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'

    implementation 'io.apisense:rhino-android:1.0'

}

 

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">

    <!--    <LinearLayout-->
    <!--        android:layout_width="wrap_content"-->
    <!--        android:layout_height="wrap_content">-->


    <!--    </LinearLayout>-->


    <EditText
        android:id="@+id/pt_result"
        android:layout_width="358dp"
        android:layout_height="62dp"
        android:layout_marginBottom="40dp"
        android:ems="10"
        android:inputType="textPersonName"
        android:text=""
        android:textSize="30sp"
        app:layout_constraintBottom_toTopOf="@+id/tableLayout"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent" />

    <TableLayout
        android:id="@+id/tableLayout"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_margin="20dp"
        android:orientation="vertical"
        android:stretchColumns="0, 1, 2"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent">

        <TableRow>

            <Button
                android:id="@+id/num1"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="1" />

            <Button
                android:id="@+id/num2"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="2" />

            <Button
                android:id="@+id/num3"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="3" />

            <Button
                android:id="@+id/btn_add"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="+" />

        </TableRow>

        <TableRow>

            <Button
                android:id="@+id/num4"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="4" />

            <Button
                android:id="@+id/num5"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="5" />

            <Button
                android:id="@+id/num6"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="6" />

            <Button
                android:id="@+id/btn_minus"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="-" />

        </TableRow>

        <TableRow>

            <Button
                android:id="@+id/num7"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="7" />

            <Button
                android:id="@+id/num8"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="8" />

            <Button
                android:id="@+id/num9"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="9" />

            <Button
                android:id="@+id/btn_multi"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="*" />

        </TableRow>

        <TableRow>

            <Button
                android:id="@+id/num0"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="0" />

            <Button
                android:id="@+id/btn_clear"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="C" />

            <Button
                android:id="@+id/btn_devide"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="/" />

            <Button
                android:id="@+id/btn_cal"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="=" />

        </TableRow>


    </TableLayout>


</androidx.constraintlayout.widget.ConstraintLayout>

 

eval.java

더보기
package com.jaybon.countingapp;

import javax.script.ScriptEngine;
import javax.script.ScriptEngineManager;
import javax.script.ScriptException;

public class eval {
    public static String cal (String result) throws ScriptException {
        ScriptEngineManager manager = new ScriptEngineManager();
        ScriptEngine engine = manager.getEngineByName("js");
        try {
            return engine.eval(result).toString();
        }catch(Exception e) {
            e.getStackTrace();
        }
        return null;
    }
}

 

MainActivity.java

더보기
package com.jaybon.countingapp;

import androidx.appcompat.app.AppCompatActivity;

import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;

import javax.script.ScriptException;


public class MainActivity extends AppCompatActivity {

    private static final String TAG = "Main_Activity";

    private EditText ptResult;
    private Button btn[] = new Button[16];
    private int i;


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        init();
        initListener();



//        btnAdd.setOnClickListener((View view)->{
//
//            Log.d(TAG, "onCreate: btnAdd:"+view.getId());
//
//            count++;
//            tvCount.setText(count+"");
//        });
//
//        btnMinus.setOnClickListener((View view)->{
//            if(count > 0){
//                count--;
//                tvCount.setText(count+"");
//            }
//        });
    }

    private void init(){
        btn[0] = findViewById(R.id.num0);
        btn[1] = findViewById(R.id.num1);
        btn[2] = findViewById(R.id.num2);
        btn[3] = findViewById(R.id.num3);
        btn[4] = findViewById(R.id.num4);
        btn[5] = findViewById(R.id.num5);
        btn[6] = findViewById(R.id.num6);
        btn[7] = findViewById(R.id.num7);
        btn[8] = findViewById(R.id.num8);
        btn[9] = findViewById(R.id.num9);
        btn[10] = findViewById(R.id.btn_add);
        btn[11] = findViewById(R.id.btn_minus);
        btn[12] = findViewById(R.id.btn_multi);
        btn[13] = findViewById(R.id.btn_devide);
        btn[14] = findViewById(R.id.btn_clear);
        btn[15] = findViewById(R.id.btn_cal);
        ptResult = findViewById(R.id.pt_result);
    }

    private void initListener(){

        for (i=0; i<14; i++){
            btn[i].setOnClickListener((View view)->{
                Button btn = (Button)view;
                ptResult.append(btn.getText().toString());
            });
        }

        btn[14].setOnClickListener((View view)->{
            ptResult.setText("");
        });

        btn[15].setOnClickListener((View view)->{
            String result = ptResult.getText().toString();
            try {
                ptResult.setText(eval.cal(result));
            } catch (ScriptException e) {
                e.printStackTrace();
            }
        });

    }

}

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

https://blog.naver.com/getinthere/221694606685

 

안드로이드 1강 - (5) Relative 레이아웃

1. Relative 기본 예제activity_main.xmlitem_post1.xml​2. 위의 예제 참고https://blog.naver.com/codin...

blog.naver.com

 

안드로이드 drawable 폴더에 복붙할 시 하위폴더 인식을 못한다 (폴더 복붙 하지말 것)

 

 

layout_profile.xml

더보기
<?xml version="1.0" encoding="utf-8"?>
<merge
    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"
    >

    <RelativeLayout
        android:layout_marginLeft="10dp"
        android:layout_gravity="center"
        android:layout_weight="1"
        android:layout_width="0dp"
        android:layout_height="wrap_content">

        <ImageView
            android:id="@+id/img_pro1"
            android:layout_width="60dp"
            android:layout_height="60dp"
            app:srcCompat="@drawable/propic1" />

        <TextView
            android:layout_marginTop="5dp"
            android:layout_below="@id/img_pro1"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Your story" />

    </RelativeLayout>

</merge>

 

더보기

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">

    <LinearLayout

        android:orientation="horizontal"
        android:layout_width="match_parent"
        android:layout_height="100dp">

        <include layout="@layout/layout_profile" />
        <include layout="@layout/layout_profile" />
        <include layout="@layout/layout_profile" />
        <include layout="@layout/layout_profile" />
        <include layout="@layout/layout_profile" />

    </LinearLayout>

    <ScrollView
        android:layout_width="match_parent"
        android:layout_height="match_parent">

        <LinearLayout
            android:orientation="vertical"
            android:layout_width="match_parent"
            android:layout_height="wrap_content">

        </LinearLayout>

    </ScrollView>

</LinearLayout>

 

 

동그란 이미지를 만들기 위해 라이브러리 추가

https://github.com/hdodenhof/CircleImageView

 

hdodenhof/CircleImageView

A circular ImageView for Android. Contribute to hdodenhof/CircleImageView development by creating an account on GitHub.

github.com

 

 

 

androidx 를 써야한다 !!!! (구버전의 android는 사용못함)

구버전은 compile -> 신버전은 implementation

 

 

 

액션바 없애기

 

 

 

 

 

완성

 

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">

    <LinearLayout

        android:layout_width="match_parent"
        android:layout_height="100dp"
        android:orientation="horizontal">

        <include layout="@layout/layout_profile" />

        <include layout="@layout/layout_profile" />

        <include layout="@layout/layout_profile" />

        <include layout="@layout/layout_profile" />

        <include layout="@layout/layout_profile" />

    </LinearLayout>

    <View
        android:layout_width="match_parent"
        android:layout_height="1dp"
        android:background="@android:color/darker_gray" />

    <ScrollView
        android:layout_width="match_parent"
        android:layout_height="match_parent">

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="vertical">

            <!--            리니어 레이아웃 버티컬-->

            <include layout="@layout/layout_content" />
            <include layout="@layout/layout_content" />
            <include layout="@layout/layout_content" />
            <include layout="@layout/layout_content" />
            <include layout="@layout/layout_content" />

        </LinearLayout>

    </ScrollView>

</LinearLayout>

 

layout_profile.xml

더보기
<?xml version="1.0" encoding="utf-8"?>
<merge
    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"
    >

    <RelativeLayout
        android:layout_marginLeft="10dp"
        android:layout_gravity="center"
        android:layout_weight="1"
        android:layout_width="0dp"
        android:layout_height="wrap_content">

<!--        <ImageView-->
<!--            android:id="@+id/img_pro1"-->
<!--            android:layout_width="60dp"-->
<!--            android:layout_height="60dp"-->
<!--            app:srcCompat="@drawable/propic1" />-->

        <de.hdodenhof.circleimageview.CircleImageView
            xmlns:app="http://schemas.android.com/apk/res-auto"
            android:id="@+id/img_pro1"
            android:layout_width="60dp"
            android:layout_height="60dp"
            android:src="@drawable/propic1"
            app:civ_border_width="2dp"
            app:civ_border_color="#FF000000"/>

        <TextView
            android:layout_marginTop="5dp"
            android:layout_below="@id/img_pro1"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Your story" />

    </RelativeLayout>

</merge>

 

layout_content.xml

더보기
<?xml version="1.0" encoding="utf-8"?>
<merge
    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">

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="vertical">

        <RelativeLayout
            android:layout_width="match_parent"
            android:layout_height="60dp">

            <de.hdodenhof.circleimageview.CircleImageView xmlns:app="http://schemas.android.com/apk/res-auto"
                android:id="@+id/img_pro2"
                android:layout_marginLeft="10dp"
                android:layout_width="40dp"
                android:layout_height="match_parent"
                android:src="@drawable/propic1"
                app:civ_border_color="#FF000000"
                app:civ_border_width="2dp" />

            <TextView
                android:layout_width="wrap_content"
                android:layout_height="match_parent"
                android:layout_marginLeft="15dp"
                android:layout_toRightOf="@+id/img_pro2"
                android:gravity="center"
                android:text="numbiker.nikkhil"
                android:textSize="18dp"
                android:textStyle="bold" />

            <ImageView
                android:id="@+id/imageView2"
                android:layout_width="30dp"
                android:layout_height="match_parent"
                android:layout_alignParentRight="true"
                android:layout_marginRight="10dp"
                app:srcCompat="@drawable/ic_more" />


        </RelativeLayout>

        <ImageView
            android:id="@+id/imageView3"
            android:layout_width="match_parent"
            android:layout_height="300dp"
            android:scaleType="centerCrop"
            app:srcCompat="@drawable/postpic1" />

        <RelativeLayout
            android:layout_width="match_parent"
            android:layout_height="60dp">

            <ImageView
                android:id="@+id/imageView4"
                android:layout_width="40dp"
                android:layout_height="wrap_content"
                android:layout_alignParentLeft="true"
                android:layout_marginLeft="10dp"
                app:srcCompat="@drawable/like" />

            <ImageView
                android:id="@+id/imageView5"
                android:layout_width="40dp"
                android:layout_height="wrap_content"
                android:layout_marginLeft="10dp"
                android:layout_toRightOf="@id/imageView4"
                app:srcCompat="@drawable/chat_bubble" />


            <ImageView
                android:id="@+id/imageView6"
                android:layout_width="40dp"
                android:layout_height="wrap_content"
                android:layout_marginLeft="10dp"
                android:layout_toRightOf="@id/imageView5"
                app:srcCompat="@drawable/send" />

            <ImageView
                android:id="@+id/imageView7"
                android:layout_marginRight="10dp"
                android:layout_width="30dp"
                android:layout_height="wrap_content"
                android:layout_alignParentRight="true"
                android:layout_marginLeft="10dp"
                app:srcCompat="@drawable/bookmark" />

        </RelativeLayout>

        <RelativeLayout
            android:layout_width="match_parent"
            android:layout_height="40dp">

            <de.hdodenhof.circleimageview.CircleImageView xmlns:app="http://schemas.android.com/apk/res-auto"
                android:id="@+id/img_pro3"
                android:layout_marginLeft="10dp"
                android:layout_width="35dp"
                android:layout_height="match_parent"
                android:src="@drawable/propic2"
                app:civ_border_color="#FF000000"
                app:civ_border_width="2dp" />

            <TextView
                android:id="@+id/textView"
                android:layout_toRightOf="@id/img_pro3"
                android:gravity="center"
                android:layout_marginLeft="10dp"
                android:layout_width="wrap_content"
                android:layout_height="match_parent"
                android:text="Liked by"
                android:textSize="18dp"/>

            <TextView
                android:id="@+id/textView1"
                android:layout_toRightOf="@id/textView"
                android:gravity="center"
                android:layout_marginLeft="5dp"
                android:layout_width="wrap_content"
                android:layout_height="match_parent"
                android:text="bhuvan.van"
                android:textSize="18dp"
                android:textStyle="bold"/>

            <TextView
                android:id="@+id/textView2"
                android:layout_toRightOf="@id/textView1"
                android:gravity="center"
                android:layout_marginLeft="5dp"
                android:layout_width="wrap_content"
                android:layout_height="match_parent"
                android:text="and"
                android:textSize="18dp"/>

            <TextView
                android:id="@+id/textView3"
                android:layout_toRightOf="@id/textView2"
                android:gravity="center"
                android:layout_marginLeft="5dp"
                android:layout_width="wrap_content"
                android:layout_height="match_parent"
                android:text="24 others"
                android:textSize="18dp"
                android:textStyle="bold" />

        </RelativeLayout>

        <RelativeLayout
            android:layout_width="match_parent"
            android:layout_height="50dp">

            <TextView
                android:id="@+id/textView4"
                android:layout_width="wrap_content"
                android:layout_height="match_parent"
                android:layout_marginLeft="15dp"
                android:gravity="center"
                android:text="numbiker.ni"
                android:textSize="18dp"
                android:textStyle="bold" />

            <TextView
                android:id="@+id/textView5"
                android:layout_toRightOf="@id/textView4"
                android:gravity="center"
                android:layout_marginLeft="5dp"
                android:layout_width="wrap_content"
                android:layout_height="match_parent"
                android:text="#asdf"
                android:textSize="18dp"
                android:textStyle="bold"
                android:textColor="@android:color/holo_blue_dark"/>

        </RelativeLayout>

        <RelativeLayout
            android:layout_width="match_parent"
            android:layout_height="60dp">

            <de.hdodenhof.circleimageview.CircleImageView
                xmlns:app="http://schemas.android.com/apk/res-auto"
                android:id="@+id/img_pro4"
                android:layout_marginLeft="10dp"
                android:layout_width="40dp"
                android:layout_height="match_parent"
                android:src="@drawable/propic3"
                app:civ_border_color="#FF000000"
                app:civ_border_width="2dp" />

            <EditText
                android:id="@+id/editTextTextPersonName"
                android:layout_toRightOf="@id/img_pro4"
                android:gravity="center"
                android:layout_width="wrap_content"
                android:layout_height="match_parent"
                android:ems="10"
                android:inputType="textPersonName"
                android:textSize="22dp"
                android:textColor="@android:color/darker_gray"
                android:text="Add Comment..." />

            <!--            <TextView-->
<!--                android:id="@+id/textView6"-->
<!--                android:layout_toRightOf="@id/img_pro4"-->
<!--                android:gravity="center"-->
<!--                android:layout_marginLeft="15dp"-->
<!--                android:layout_width="wrap_content"-->
<!--                android:layout_height="match_parent"-->
<!--                android:text="Add Comment..."-->
<!--                android:textSize="22dp"/>-->

        </RelativeLayout>

        <TextView
            android:id="@+id/textView7"
            android:layout_marginLeft="15dp"
            android:layout_width="wrap_content"
            android:layout_height="match_parent"
            android:text="8HOURS AGO"
            android:textSize="16dp"/>

    </LinearLayout>

</merge>

 

<EditText
                android:id="@+id/editTextTextPersonName"
                android:layout_toRightOf="@id/img_pro4"
                android:gravity="center"
                android:layout_width="wrap_content"
                android:layout_height="match_parent"
                android:ems="10"
                android:inputType="textPersonName"
                android:textSize="22dp"
                android:textColor="@android:color/darker_gray"
                android:hint="Add Comment..."
                android:background="@android:color/transparent"/>

 

hint 는 placeholder와 비슷함

background는 밑줄을 없앤다

 

 

 

스마트폰 화면 전체를 window 라고 부른다

window는 백그라운드로 항상 깔려 있다

그 위에 올라가는 것이 activity

하나의 앱에는 여러개의 activity가  있다 (메인 로그인 회원가입 화면 등)

activity 위에는 SurfaceView가 올라간다

앱을 만든다는 것은 SurfaceView라는 하얀도화지에 그림을 그린다

 

뷰 - 그림

위젯 - 이벤트가 달려 있는 그림 - 안드로이드에서 제공하는 그림들 - 버튼 텍스트뷰 등등

머터리얼 - 

 

위젯을 직접만드는 것은 쉽지 않고, 기존의 것을 커스텀하여 사용

 

activity는
(1)자바파일
-로직
(2)XML
-화면

위의 두가지가 onCreate에서 합쳐져서 출력된다

 

자바에서는 함수에 파라미터로 넘기지만 

안드로이드에서는 시리얼 통신을 하여 데이터를 전송

 

버튼 내의 글자를 옮기기

 

 

속성을 줄때 id 아래에 주자

 

리니어 레이아웃 정리

 

더보기
<?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:orientation="vertical"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".MainActivity">


    <Button
        android:id="@+id/button"
        android:layout_weight="1"
        android:gravity="left"
        android:layout_width="100dp"
        android:layout_height="0dp"
        android:text="b1" />

    <Button
        android:id="@+id/button2"
        android:layout_weight="1"
        android:gravity="right"
        android:layout_gravity="right"
        android:layout_width="100dp"
        android:layout_height="0dp"
        android:text="b2" />

    <Button
        android:id="@+id/button3"
        android:layout_weight="1"
        android:layout_gravity="center"
        android:layout_width="100dp"
        android:layout_height="0dp"
        android:text="b3" />


</LinearLayout>

 

 

렐러티브 레이아웃

리니어가 아니기 때문에 오리엔테이션이 필요 없다

 

 

버튼 2개를 추가했으나 겹쳐버린다

 

 

-------------------

 

 

---------------------

 

 

위아래 배치

 

더보기
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
    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">


    <Button
        android:id="@+id/btn1"
        android:layout_alignParentTop="true"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:text="Top Menu" />

    <Button
        android:id="@+id/btn2"
        android:layout_alignParentBottom="true"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:text="Bottom Menu" />

    

</RelativeLayout>

리니어로 위와같이 하려면 마진을 엄청 줘야하고 불편하다

그래서 렐러티브를 이용한다

 

 

드래그하면 코드 위치가 바뀐다

 

 

부모와의 관계

 

 

start 는 시작위치가 위인지 왼쪽인지 상관없이 시작지점

 

 

다른 컴포넌트의 아래에 배치

 

---------------------

 

 

btn2의 위쪽에 배치

 

-----------------

 

 

 

더보기
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
    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">


    <Button
        android:id="@+id/btn1"
        android:layout_alignParentTop="true"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Top Menu1" />

    <Button
        android:id="@+id/btn4"
        android:layout_toRightOf="@id/btn1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Top Menu2" />

    <Button
        android:id="@+id/btn3"
        android:layout_below="@id/btn1"
        android:layout_above="@id/btn2"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:text="Bottom Menu" />

    <Button
        android:id="@+id/btn2"
        android:layout_alignParentBottom="true"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:text="Bottom Menu" />


</RelativeLayout>

---------------

 

 

----------------

 

 

겹쳐버린다

-------------

 

 

렐러티브 레이아웃은 HTML의 div 와 같은 역할 

-----------

 

 

--------------

 

 

 

더보기
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
    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">


    <RelativeLayout
        android:id="@+id/top"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content">

        <Button
            android:id="@+id/btn1"
            android:layout_alignParentTop="true"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Top Menu1" />

        <Button
            android:id="@+id/btn4"
            android:layout_marginLeft="10dp"
            android:layout_marginTop="20dp"
            android:layout_toRightOf="@id/btn1"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Top Menu2" />

    </RelativeLayout>

    <Button
        android:id="@+id/btn3"
        android:layout_below="@id/top"
        android:layout_above="@id/btn2"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:text="Bottom Menu" />

    <Button
        android:id="@+id/btn2"
        android:layout_alignParentBottom="true"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:text="Bottom Menu" />


</RelativeLayout>

------------------

 

 

뎁스depth가 있으면 있을수록 느려진다

---------------

 

 

애매한 위치에 배치하려면 margin을 줘야한다

---------------

 

 

사진 저장 위치

----------------

 

 

 

 

가중치가 자동으로 잡힌다

 

width를 0으로 하고 height를 match_parent로 설정

 

---------------

 

더보기
<TextView
            android:id="@+id/textView"
            android:textSize="25sp"
            android:textStyle="bold"
            android:gravity="center"
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:layout_weight="1"
            android:text="TimeLine" />

-------------------

 

 

 

 

이미지 구성

 

스케일 타입 centerCrop

------------------------------

 

 

클립아트 만들 때 하는 것

---------------------

 

 

 

 

 

 

 

 

 

---------------------

 

 

렐러티브

이미지뷰 텍스트뷰 이미지뷰

 

더보기
<?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">


    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="80dp"
        android:orientation="horizontal">

        <TextView
            android:id="@+id/textView"
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:layout_weight="1"
            android:gravity="center"
            android:text="TimeLine"
            android:textSize="25sp"
            android:textStyle="bold" />

        <TextView
            android:id="@+id/textView2"
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:layout_weight="1"
            android:gravity="center"
            android:text="Untitled"
            android:textSize="25sp"
            android:textStyle="bold" />

    </LinearLayout>

    <LinearLayout
        android:orientation="vertical"
        android:layout_width="match_parent"
        android:layout_height="match_parent">

        <ImageView
            android:id="@+id/imageView2"
            android:layout_width="match_parent"
            android:layout_height="400dp"
            android:scaleType="centerCrop"
            app:srcCompat="@drawable/img1" />

        <RelativeLayout
            android:layout_width="match_parent"
            android:layout_height="50dp">


            <ImageView
                android:id="@+id/imageView3"
                android:layout_marginLeft="10dp"
                android:layout_width="30dp"
                android:layout_height="match_parent"
                android:layout_alignParentLeft="true"
                app:srcCompat="@drawable/ic_favorite" />

            <TextView
                android:id="@+id/textView3"
                android:gravity="center"
                android:layout_marginLeft="10dp"
                android:layout_toRightOf="@id/imageView3"
                android:layout_width="wrap_content"
                android:layout_height="match_parent"
                android:text="TextView" />

            <ImageView
                android:id="@+id/imageView4"
                android:layout_width="35dp"
                android:layout_marginRight="10dp"
                android:layout_height="match_parent"
                android:layout_alignParentRight="true"
                app:srcCompat="@drawable/ic_more" />
        </RelativeLayout>

    </LinearLayout>

</LinearLayout>

 

-----------------------

 

 

 

-------------------

 

 

 

더보기
<RelativeLayout
            android:layout_width="match_parent"
            android:layout_height="60dp">

            <TextView
                android:id="@+id/tv_username"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="아이디"
                android:textStyle="bold"
                android:textSize="25sp">

            </TextView>

            <TextView
                android:id="@+id/tv_comment"
                android:layout_marginLeft="10dp"
                android:layout_toRightOf="@id/tv_username"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="내용"
                android:textSize="25sp">

            </TextView>

        </RelativeLayout>

 

---------------------

 

 

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">


    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="80dp"
        android:orientation="horizontal">

        <TextView
            android:id="@+id/textView"
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:layout_weight="1"
            android:gravity="center"
            android:text="TimeLine"
            android:textSize="25sp"
            android:textStyle="bold" />

        <TextView
            android:id="@+id/textView2"
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:layout_weight="1"
            android:gravity="center"
            android:text="Untitled"
            android:textSize="25sp"
            android:textStyle="bold" />

    </LinearLayout>

    <ScrollView
        android:layout_width="match_parent"
        android:layout_height="match_parent">

<!--        스크롤뷰는 레이아웃을 하나 밖에 못둔다 레이아웃으로 묶기-->

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:orientation="vertical">

            <include layout="@layout/layout_content" />
            <include layout="@layout/layout_content" />
            <include layout="@layout/layout_content" />

        </LinearLayout>


    </ScrollView>

</LinearLayout>

-------------------------

 

 

 

 

 

 

 

 

 

 

 

 

https://blog.naver.com/getinthere/221694578995

 

안드로이드 1강 - (1) 환경 구성

1. 안드로이드 설치https://developer.android.com/studio/index.html?hl=ko2. minSdk와 compileSd...

blog.naver.com

 

 

 

 

 

View Group - 레이아웃 - 뷰들을 담을 수 있다

1.리니어 - 위에서 아래, 왼쪽에서 오른쪽으로 화면을 구성
2.렐러티브 - 프레임 또는 컴포넌트와 관계되어 위치를 지정 (반응형)
3.그리드 - 격자모양으로 원하는 열의 개수를 정할 수 있다
4.제약 -

 

view - 버튼, 텍스트뷰 등등

 

 

전체 레이아웃은 코드로 수정

 

 

이렇게 수정

 

 

 

 

세로 또는 가로방향 세팅

 

 

 

 

 

 

넓이는 부모의 넓이

높이는 컨텐츠의 높이

 

 

 

 

 

 

px는 픽셀단위

dp는 비율

 

 

 

 

 

 

 

 

 

 

더보기
<?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:orientation="vertical"

    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".MainActivity">


    <Button
        android:id="@+id/button7"
        android:layout_width="match_parent"
        android:layout_height="70dp"
        android:text="Button" />

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="70dp"
        android:layout_weight="100"
        android:orientation="horizontal">


        <Button
            android:id="@+id/button9"
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:layout_weight="1"
            android:text="Button" />

        <Button
            android:id="@+id/button10"
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:layout_weight="1"
            android:text="Button" />

        <Button
            android:id="@+id/button11"
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:layout_weight="1"
            android:text="Button" />

        <Button
            android:id="@+id/button12"
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:layout_weight="1"
            android:text="Button" />

    </LinearLayout>

    <Button
        android:id="@+id/button8"
        android:layout_width="match_parent"
        android:layout_height="70dp"
        android:text="Button" />

</LinearLayout>

weight설정할 때는 해당 넓이나 높이를 0dp로 설정

 

 

    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"

코어 라이브러리와 같은것

 

 

 

더보기
<?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:orientation="vertical"

    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:gravity="center_vertical"
    tools:context=".MainActivity">

<!--gravity는 내부배치 -->
    <Button
        android:id="@+id/button19"
        android:layout_width="match_parent"
        android:layout_height="300"
        android:gravity="right|center"
        android:textSize="50sp"
        android:text="Button" />
</LinearLayout>

 

 

더보기
<?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:orientation="vertical"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".MainActivity">


    <LinearLayout
        android:layout_gravity="center"
        android:orientation="horizontal"
        android:layout_width="wrap_content"
        android:layout_height="match_parent">

        <Button
            android:id="@+id/button7"
            android:layout_width="100dp"
            android:layout_height="100dp"
            android:layout_gravity="center"
            android:text="Button"

            android:textSize="50sp"
            />

    </LinearLayout>

</LinearLayout>

 

 

 

'App > Android' 카테고리의 다른 글

인스타그램 UI 만들기  (0) 2020.07.09
200709 / 리니어 레이아웃으로 화면구성 /  (0) 2020.07.09
안드로이드 // 기본 세팅  (0) 2020.07.08
안드로이드 개발 가이드  (0) 2020.07.08
안드로이드 설치  (0) 2020.07.07

 

-----------

 

 

책따라하려면  10.0버전체크 (29)

 

안드로이드에서 액티비티란 - 화면

 

폴더명은 소문자

 

 

 

인텔 amd 구분

 

세팅

자동 임포트

 

 

 

alt enter 매직키

ctrl q

shift shift

alt 드래그

 

 

main이 없다는 것은 실행의 주도권이 안드로이드에 있다는 것이다
(프레임워크)

 

 

 

 

핫리로드 - 변경된 내용만 바꿔서 펌웨어 업데이트

 

화면마다 Activity 파일이 필요하다

그림 그리는 코드 / 자바 코드

분리되어있다

 

 

 

(하위버전을 입력해도 문제는 없다 - 개발 버전이 높기 때문)

 

 

 

'App > Android' 카테고리의 다른 글

인스타그램 UI 만들기  (0) 2020.07.09
200709 / 리니어 레이아웃으로 화면구성 /  (0) 2020.07.09
안드로이드 // 레이아웃 구성  (0) 2020.07.08
안드로이드 개발 가이드  (0) 2020.07.08
안드로이드 설치  (0) 2020.07.07

 

 

 

*서포트 라이브러리

안드로이드 등 상위 버전의 좋은 기능을

업그레이드 하지 않고 사용할 수 있는 라이브러리

 

하지만 높은 버전을 쓰는데도 서포트 라이브러리를 쓰는 등 난립이 될 수 있는데

jetpack은 깔끔하게 정리되어 있어서 이용하기 좋다

 

샘플

 

참조

 

코드랩가이드

 

기능을 넣고 싶을 때 테스트하며 만들어 볼 수 있다

 

머터리얼

가이드라인 따라 사용하는 것이 ux 측면에서 좋다 / component

 

문서 - 개발자 가이드

샘플코드를 보고 만들자

 

https://developer.android.com/guide?hl=ko

 

개발자 가이드  |  Android 개발자  |  Android Developers

Android 개발자 가이드에 오신 것을 환영합니다. 왼쪽 탐색에 나열된 문서에서는 Android 프레임워크와 다른 라이브러리에서 API를 사용하여 Android 앱을 빌드하는 방법을 알려줍니다. Android를 처음 ��

developer.android.com

 

안드로이드 개발 가이드 사이트 (샘플코드)

 

-------------

'App > Android' 카테고리의 다른 글

인스타그램 UI 만들기  (0) 2020.07.09
200709 / 리니어 레이아웃으로 화면구성 /  (0) 2020.07.09
안드로이드 // 레이아웃 구성  (0) 2020.07.08
안드로이드 // 기본 세팅  (0) 2020.07.08
안드로이드 설치  (0) 2020.07.07

 

 

SDK - 소프트웨어 개발 키트

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

'App > Android' 카테고리의 다른 글

인스타그램 UI 만들기  (0) 2020.07.09
200709 / 리니어 레이아웃으로 화면구성 /  (0) 2020.07.09
안드로이드 // 레이아웃 구성  (0) 2020.07.08
안드로이드 // 기본 세팅  (0) 2020.07.08
안드로이드 개발 가이드  (0) 2020.07.08

+ Recent posts