โ 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์ผ์ฐจ
'๐ป Extracurricular > ์ฝ๋ฎค๋ํฐ ๋ชจ๊ฐ์ฝ' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
๋ชจ๊ฐ์ฝ < Kotlin ๊ธฐ์ดํธ > - 14์ผ์ฐจ (0) | 2022.03.14 |
---|---|
๋ชจ๊ฐ์ฝ < Kotlin ๊ธฐ์ดํธ > - 13์ผ์ฐจ (0) | 2022.03.14 |
๋ชจ๊ฐ์ฝ < Kotlin ๊ธฐ์ดํธ > - 11์ผ์ฐจ (0) | 2022.03.09 |
๋ชจ๊ฐ์ฝ < Kotlin ๊ธฐ์ดํธ > - 10์ผ์ฐจ (0) | 2022.03.09 |
๋ชจ๊ฐ์ฝ < Kotlin ๊ธฐ์ดํธ > - 9์ผ์ฐจ (0) | 2022.03.09 |