Notice
Recent Posts
Recent Comments
Link
yeon's blog
[Kotlin] 레이아웃 구현 본문
Kotlin을 이용한 Android Community App 개발 시작!
1. Splash 화면 구현
Splash 화면은 보통 앱의 로고를 띄우고 2초 정도 후에 메인화면으로 넘어간다. (카카오톡 참고)
activity_splash.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"
android:background="@color/yello"
tools:context=".SplashActivity">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/logo"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
위에 말했듯이 2초 정도 후에 Intro 화면으로 넘어갈 수 있도록 구현해주었다.
SplashActivity 전체코드
package com.example.mysololife
import android.content.Intent
import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import android.os.Handler
import com.example.mysololife.auth.IntroActivity
class SplashActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_splash)
Handler().postDelayed({
startActivity(Intent(this, IntroActivity::class.java))
finish()
}, 2000)
}
}
2. Intro 화면 구현
Intro 화면에는 로그인 / 회원가입 버튼을 만들어준다.
비회원도 앱에 접근할 수 있도록 하기 위해 비회원 가입 버튼도 추가로 생성해주었다.
activity_intro.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=".auth.IntroActivity">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
android:src="@drawable/loginbg"
android:scaleType="fitXY"
android:layout_width="match_parent"
android:layout_height="500dp" />
<ImageView
android:layout_width="match_parent"
android:layout_height="360dp"
android:scaleType="fitXY"
android:layout_alignParentBottom="true"
android:src="@drawable/upperbg" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_marginBottom="18dp"
android:orientation="vertical">
<Button
android:layout_width="match_parent"
android:layout_height="55dp"
android:background="@drawable/background_radius"
android:layout_margin="5dp"
android:text="로그인"
android:textStyle="bold"
android:textSize="17sp"/>
<Button
android:layout_width="match_parent"
android:layout_height="55dp"
android:background="@drawable/background_radius"
android:layout_margin="5dp"
android:text="회원가입"
android:textStyle="bold"
android:textSize="17sp"/>
<Button
android:layout_width="match_parent"
android:layout_height="55dp"
android:background="@drawable/background_radius"
android:layout_margin="5dp"
android:text="비회원 가입"
android:textStyle="bold"
android:textSize="17sp"/>
</LinearLayout>
</RelativeLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
3. 로그인 화면 구현
<?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=".auth.LoginActivity"
android:orientation="vertical">
<LinearLayout
android:background="@color/yello"
android:layout_width="match_parent"
android:layout_height="150dp">
<TextView
android:text="로그인"
android:textStyle="bold"
android:textColor="@color/black"
android:textSize="20sp"
android:gravity="center"
android:layout_width="match_parent"
android:layout_height="50dp" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="50dp"
android:orientation="vertical">
<EditText
style="@style/AuthEditText"
android:hint="email"
android:layout_width="match_parent"
android:layout_height="50dp" />
<LinearLayout
android:background="#999999"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_width="match_parent"
android:layout_height="0.5dp" />
<EditText
style="@style/AuthEditText"
android:hint="password"
android:inputType="textPassword"
android:layout_width="match_parent"
android:layout_height="50dp" />
<LinearLayout
android:background="#999999"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_width="match_parent"
android:layout_height="0.5dp" />
<Button
android:text="로그인하기"
android:layout_margin="20dp"
android:background="@drawable/background_radius_yello"
android:layout_width="match_parent"
android:layout_height="50dp" />
</LinearLayout>
</LinearLayout>
4. 회원가입 화면 구현
<?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=".auth.JoinActivity"
android:orientation="vertical">
<LinearLayout
android:background="@color/yello"
android:layout_width="match_parent"
android:layout_height="150dp">
<TextView
android:text="회원가입"
android:textStyle="bold"
android:textColor="@color/black"
android:textSize="20sp"
android:gravity="center"
android:layout_width="match_parent"
android:layout_height="50dp" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="50dp"
android:orientation="vertical">
<EditText
style="@style/AuthEditText"
android:hint="email"
android:layout_width="match_parent"
android:layout_height="50dp" />
<LinearLayout
android:background="#999999"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_width="match_parent"
android:layout_height="0.5dp" />
<EditText
style="@style/AuthEditText"
android:hint="password"
android:inputType="textPassword"
android:layout_width="match_parent"
android:layout_height="50dp" />
<LinearLayout
android:background="#999999"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_width="match_parent"
android:layout_height="0.5dp" />
<EditText
style="@style/AuthEditText"
android:hint="password check"
android:inputType="textPassword"
android:layout_width="match_parent"
android:layout_height="50dp" />
<LinearLayout
android:background="#999999"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_width="match_parent"
android:layout_height="0.5dp" />
<Button
android:text="회원가입하기"
android:layout_margin="20dp"
android:background="@drawable/background_radius_yello"
android:layout_width="match_parent"
android:layout_height="50dp" />
</LinearLayout>
</LinearLayout>
실행 화면
'Kotlin > 커뮤니티 앱' 카테고리의 다른 글
[Kotlin] 팁 페이지 (2) | 2024.01.12 |
---|---|
[Kotlin] 메인화면 레이아웃 (Navigation) (0) | 2024.01.06 |
[Kotlin] Firebase 회원가입, 로그인, 로그아웃, 익명로그인 기능 구현 (2) | 2024.01.03 |