๋ณธ๋ฌธ ๋ฐ”๋กœ๊ฐ€๊ธฐ

๐Ÿ’ป Extracurricular/์ฝ”๋ฎค๋‹ˆํ‹ฐ ๋ชจ๊ฐ์ฝ”

๋ชจ๊ฐ์ฝ” < Kotlin ๊ธฐ์ดˆํŽธ > - 12์ผ์ฐจ

โœ… Activity ์ƒ์„ฑํ•˜๊ธฐ

โšกActivity ๋ฅผ ์ƒ์„ฑํ•  ๋•Œ

  • ์ง์ ‘ ์ฝ”ํ‹€๋ฆฐ, xml ํŒŒ์ผ ๋งŒ๋“ค๊ธฐ
  • ์•ˆ๋“œ๋กœ์ด๋“œ ์ŠคํŠœ๋””์˜ค์—์„œ ์ œ๊ณตํ•˜๋Š” ํ…œํ”Œ๋ฆฟ ์ด์šฉ

โšก ํ…œํ”Œ๋ฆฟ์„ ์ด์šฉํ•  ๊ฒฝ์šฐ

๋”ฐ๋กœ ๋งค๋‹ˆํŽ˜์ŠคํŠธ ์„ค์ •์„ ๋”ฐ๋กœ ํ•ด์ฃผ์ง€ ์•Š์•„๋„ ๋จ!

 

 

1๏ธโƒฃ New > Activity > Empty Activity ๋ฅผ ํด๋ฆญ

 

2๏ธโƒฃ Activity ์ด๋ฆ„ ๋ณ€๊ฒฝ

์ด๋ฆ„์„ ๋ณ€๊ฒฝํ•˜๋ฉด Layout ์ด๋ฆ„๋„ ์ž๋™์œผ๋กœ ๋งž์ถฐ์„œ ๋ณ€๊ฒฝ๋จ

 

3๏ธโƒฃ Finish ๋ฒ„ํŠผ ํด๋ฆญ

์™„๋ฃŒ ํ›„ ๋ฉ”๋‹ˆํŽ˜์ŠคํŠธ ํŒŒ์ผ์„ ์—ด๋ฉด, ์•„๋ž˜ ์ฝ”๋“œ๊ฐ€ ์ƒˆ๋กœ ์ถ”๊ฐ€๋จ.

<activity android:name=".OOActivity"></activity>

โœ… ์•ฑ ๋Ÿฐ์ฒ˜ Activity ๋ณ€๊ฒฝ

 

โšก Activity๊ฐ€ ์ œ๋Œ€๋กœ ๋งŒ๋“ค์—ˆ๋Š”์ง€ TEST!

: ํ…Œ์ŠคํŠธ ๊ฒธ ์•ฑ์˜ ๋Ÿฐ์ฒ˜ (์•ฑ์ด ์—ด๋ฆด ๋•Œ ๊ฐ€์žฅ ๋จผ์ € ์—ด๋ฆฌ๋Š” Activity) ๋ฅผ ๋ณ€๊ฒฝ

 

โšก ์•„๋ž˜ ์ฝ”๋“œ์ฒ˜๋Ÿผ ๋งค๋‹ˆํŽ˜์ŠคํŠธ ํŒŒ์ผ ์ˆ˜์ •!

<activity android:name=".Activity์ด๋ฆ„">

: MainActivity -> MemoActivity ๋กœ ๋ณ€๊ฒฝ

 

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.comu.android.secretmemo">

    <application
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:roundIcon="@mipmap/ic_launcher_round"
        android:supportsRtl="true"
        android:theme="@style/Theme.SecretMemo">
        <activity android:name=".MemoActivity">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>

</manifest>

 

<intent-filter> ... </intent-filter>๋กœ ๊ฐ์‹ธ์ง„ ๋ถ€๋ถ„์ด

MemoActivity๋ฅผ ๋Ÿฐ์ฒ˜ Activity๋กœ ๋งŒ๋“œ๋Š” ์ฝ”๋“œ

 

 

โœ… ์˜ค๋Š˜์˜ ๋ฌธ์ œ : ๋ฉ”๋ชจ ํ™”๋ฉด ๋ ˆ์ด์•„์›ƒ ์™„์„ฑํ•˜๊ธฐ

โšก Constraint Layout์œผ๋กœ ๊ตฌ์„ฑํ•˜๊ณ , EditText์™€ FloatingActionButton ์ถ”๊ฐ€

โšก ํ…์ŠคํŠธ๋ฅผ ์ž…๋ ฅํ•  ๋•Œ ์šฐ์ธก ํ•˜๋‹จ์˜ ๋ฒ„ํŠผ์„ ๊ฐ€๋ฆฌ์ง€ ์•Š๋„๋ก ๋งŒ๋“ค๊ธฐ

 

๐Ÿ‘€ xml ์ฝ”๋“œ

<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".MemoActivity">

  <EditText
      android:id="@+id/editText"
      android:layout_width="0dp"
      android:layout_height="wrap_content"
      android:layout_marginTop="32dp"
      android:ems="10"
      android:gravity="start|top"
      android:inputType="textMultiLine"
      app:layout_constraintBottom_toBottomOf="parent"
      app:layout_constraintEnd_toEndOf="parent"
      app:layout_constraintHorizontal_bias="0.0"
      app:layout_constraintStart_toStartOf="parent"
      app:layout_constraintTop_toTopOf="parent"
      app:layout_constraintVertical_bias="0.0" />

  <com.google.android.material.floatingactionbutton.FloatingActionButton
      android:id="@+id/floatingActionButton"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:clickable="true"
      app:layout_constraintBottom_toBottomOf="parent"
      app:layout_constraintEnd_toEndOf="parent"
      app:layout_constraintTop_toBottomOf="@+id/editText"
      app:layout_constraintStart_toStartOf="parent"
      app:layout_constraintHorizontal_bias="0.99"
      app:layout_constraintVertical_bias="0.99"
      app:srcCompat="@android:drawable/ic_menu_search" />

  </androidx.constraintlayout.widget.ConstraintLayout>

 

๐Ÿ‘€ AndroidManifest.xml

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.comu.android.secretmemo" >
    <application
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:roundIcon="@mipmap/ic_launcher_round"
        android:supportsRtl="true"
        android:theme="@style/Theme.SecretMemo" >
        <activity
            android:name=".MemoActivity"
            android:exported="true"
            android:windowSoftInputMode="adjustResize" >
            <!-- adjustResize : ํ‚ค๋ณด๋“œ๊ฐ€ ์˜ฌ๋ผ๊ฐˆ ๋•Œ ์•กํ‹ฐ๋น„ํ‹ฐ์˜ ํฌ๊ธฐ๋ฅผ ์กฐ์ •ํ•ด์ค๋‹ˆ๋‹ค. -->
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
            <!-- activity ๋‚ด์— intent-filter์„ ๋„ฃ์–ด์ค€ ๊ณณ์ด ์ฒซ๋ฒˆ์งธ ์‹œ์ž‘๋ ˆ์ด์•„์›ƒ์ด ๋ฉ๋‹ˆ๋‹ค. -->
        </activity>
        <activity
            android:name=".MainActivity"
            android:exported="true"
            android:windowSoftInputMode="adjustResize">
        </activity>
    </application>
</manifest>

 

๐Ÿ‘€ ์‹คํ–‰๊ฒฐ๊ณผ


 

https://codemate.kr/@guswlsdl04/๋ชจ๊ฐ์ฝ”-์ฝ”ํ‹€๋ฆฐ-๊ธฐ์ดˆํŽธ-12์ผ์ฐจ

 

๐ŸŒˆ ๋ชจ๊ฐ์ฝ” <์ฝ”ํ‹€๋ฆฐ ๊ธฐ์ดˆํŽธ> - 12์ผ์ฐจ by guswlsdl04 | ์ฝ”๋“œ๋ฉ”์ดํŠธ

โœ… Activity ์ƒ์„ฑํ•˜๊ธฐ โšกActivity ๋ฅผ ์ƒ์„ฑํ•  ๋•Œ ์ง์ ‘ ์ฝ”ํ‹€๋ฆฐ, xml ํŒŒ์ผ ๋งŒ๋“ค๊ธฐ ์•ˆ๋“œ๋กœ์ด๋“œ ์ŠคํŠœ๋””์˜ค์—์„œ ์ œ๊ณตํ•˜๋Š” ํ…œํ”Œ๋ฆฟ ์ด์šฉ โšก ํ…œํ”Œ๋ฆฟ์„ ์ด์šฉํ•  ๊ฒฝ์šฐ ๋”ฐ๋กœ ๋งค๋‹ˆํŽ˜์ŠคํŠธ ์„ค์ •์„ ๋”ฐ๋กœ ํ•ด์ฃผ์ง€ ์•Š์•„๋„

codemate.kr