Recent Posts
Recent Comments
라떼는말이야
[Android] 로그인 구현하기 - 디자인 본문
반응형
activity_login.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:id="@+id/container"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingBottom="@dimen/activity_vertical_margin"
tools:context=".ui.login.LoginActivity">
<EditText
android:id="@+id/password"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="24dp"
android:layout_marginTop="16dp"
android:layout_marginEnd="24dp"
android:hint="@string/prompt_password"
android:imeActionLabel="@string/action_sign_in_short"
android:imeOptions="actionDone"
android:inputType="textPassword"
android:selectAllOnFocus="true"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/username" />
<EditText
android:id="@+id/username"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="24dp"
android:layout_marginTop="300dp"
android:layout_marginEnd="24dp"
android:hint="@string/prompt_email"
android:inputType="textEmailAddress"
android:selectAllOnFocus="true"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<ProgressBar
android:id="@+id/loading"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginStart="32dp"
android:layout_marginTop="64dp"
android:layout_marginEnd="32dp"
android:layout_marginBottom="64dp"
android:visibility="gone"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="@+id/password"
app:layout_constraintStart_toStartOf="@+id/password"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.3" />
<TextView
android:id="@+id/textView"
android:layout_width="139dp"
android:layout_height="55dp"
android:fontFamily="@font/roboto_mono_thin"
android:text="USWIN"
android:textAllCaps="false"
android:textColor="@color/purple_500"
android:textSize="40dp"
android:textStyle="italic"
app:layout_constraintBottom_toTopOf="@+id/username"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<Button
android:id="@+id/btn_login"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="44dp"
android:text="로그인"
android:textColor="@color/design_default_color_on_secondary"
app:layout_constraintEnd_toEndOf="@+id/password"
app:layout_constraintStart_toStartOf="@+id/password"
app:layout_constraintTop_toBottomOf="@+id/password" />
<Button
android:id="@+id/btn_sign"
style="@style/Widget.AppCompat.Button.Borderless"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="start"
android:layout_marginTop="16dp"
android:layout_marginEnd="48dp"
android:layout_marginRight="48dp"
android:layout_marginBottom="64dp"
android:enabled="true"
android:text="@string/action_sign_in"
android:textColor="@color/purple_500"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="@+id/btn_login"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintStart_toStartOf="@+id/btn_login"
app:layout_constraintTop_toBottomOf="@+id/btn_login"
app:layout_constraintVertical_bias="0.0" />
</androidx.constraintlayout.widget.ConstraintLayout>
EditText의 힌트들은 [res] -> [values] -> strings.xml 에 지정되어 있다.
로고의 폰트는 구글의 roboto_mono_thin폰트를 사용했다.
strings.xml
<resources>
<string name="app_name">Login</string>
<!-- Strings related to login -->
<string name="prompt_email">아이디</string>
<string name="prompt_password">비밀번호</string>
<string name="action_sign_in">회원 가입</string>
<string name="action_login">로그인</string>
</resources>
앱을 실행시켰을 때 바로 로그인 창이 뜨도록 AndroidManinfest.xml 파일을 수정했다.
AndroidManinfest.xml
<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.Login">
<activity android:name=".RegisterActivity"></activity>
<activity
android:name=".ui.login.LoginActivity"
android:label="@string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<meta-data
android:name="preloaded_fonts"
android:resource="@array/preloaded_fonts" />
</application>
기존에 MainActivity 안에 있는 <intent-filter> 블록을 LoginActivity 안으로 옮겨준다.
LoginActivity.java
package com.example.login.ui.login;
import android.app.Activity;
import androidx.annotation.Nullable;
import androidx.annotation.StringRes;
import androidx.appcompat.app.AppCompatActivity;
import com.example.login.R;
import com.example.login.RegisterActivity;
public class LoginActivity extends AppCompatActivity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_login);
}
반응형
'안드로이드' 카테고리의 다른 글
[Android] permission 권한 정리 (0) | 2021.08.03 |
---|---|
[Kotlin] Room 사용법 (Android에서 로컬 데이터베이스 사용하기) (0) | 2021.07.27 |
[Android] 현재 고민 중인 문제 : 화면 갱신 문제 (해결) (0) | 2021.05.28 |
[Android] 뒤로 가기 두번 눌러 종료 구현 (0) | 2021.05.28 |
[Android] 영화 앱 기능 확장 (좋아요, 한줄평) (0) | 2021.03.25 |
[Android] 버튼 상속해서 커스텀 버튼 만들기 (Bitmap Button) (0) | 2021.03.19 |
[Android] res/values에서 textSize 지정하기 (0) | 2021.03.19 |
[Android] 터치 이벤트 처리 (0) | 2021.03.19 |
Comments