안드로이드 스튜디오 전체/따라하기
로그인화면 구현하기
달톤
2020. 9. 14. 21:03
activity_login.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"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:paddingLeft="30sp"
android:paddingTop="20sp"
android:paddingRight="30sp"
android:paddingBottom="20sp">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:text="LOGIN"
android:textColor="#02A2F8"
android:textSize="20sp" />
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_margin="20dp"
android:background="@null"
android:src="@drawable/icon" />
<com.google.android.material.textfield.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<com.google.android.material.textfield.TextInputEditText
android:id="@+id/edt_email"
android:layout_width="match_parent"
android:layout_height="50dp"
android:hint="@string/email" />
</com.google.android.material.textfield.TextInputLayout>
<com.google.android.material.textfield.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<com.google.android.material.textfield.TextInputEditText
android:id="@+id/edt_password"
android:layout_width="match_parent"
android:layout_height="50dp"
android:hint="@string/password" />
</com.google.android.material.textfield.TextInputLayout>
<RelativeLayout
android:id="@+id/layout_login"
android:layout_width="match_parent"
android:layout_height="60dp"
android:layout_marginTop="50dp"
android:background="@drawable/btn_login_blue"
android:clickable="true">
<ImageView
android:layout_width="30dp"
android:layout_height="30dp"
android:layout_alignParentLeft="true"
android:layout_centerVertical="true"
android:layout_marginLeft="40dp"
android:src="@drawable/icon_user2" />
<TextView
android:layout_width="match_parent"
android:layout_height="60dp"
android:layout_centerHorizontal="true"
android:gravity="center"
android:stateListAnimator="@null"
android:text="Log in"
android:textColor="#ffffff"
android:textSize="18sp" />
</RelativeLayout>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_margin="30sp"
android:text="OR"
android:textSize="17sp" />
<RelativeLayout
android:id="@+id/layout_facebook"
android:layout_width="match_parent"
android:layout_height="60dp"
android:background="@drawable/btn_loginwithfacebook_darkblue"
android:clickable="true">
<ImageView
android:layout_width="30dp"
android:layout_height="30dp"
android:layout_alignParentLeft="true"
android:layout_centerVertical="true"
android:layout_marginLeft="40dp"
android:src="@drawable/icon_facebook" />
<TextView
android:layout_width="match_parent"
android:layout_height="60dp"
android:layout_centerHorizontal="true"
android:gravity="center"
android:stateListAnimator="@null"
android:text="Log in with Facebook"
android:textColor="#ffffff"
android:textSize="17sp" />
</RelativeLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="50dp"
android:orientation="horizontal"
android:weightSum="10">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_weight="5"
android:gravity="center"
android:text="Forgot Password"
android:textSize="17dp" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_weight="5"
android:gravity="center"
android:text="Create Account"
android:textColor="#02A2F8"
android:textSize="17dp" />
</LinearLayout>
</LinearLayout>
build.gradle(Moudule:app)
apply plugin: 'com.android.application'
android {
compileSdkVersion 29
buildToolsVersion "29.0.2"
defaultConfig {
applicationId 'com.example.samplesenti'
minSdkVersion 16
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'
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'androidx.appcompat:appcompat:1.2.0'
implementation 'androidx.constraintlayout:constraintlayout:2.0.1'
implementation 'com.google.android.material:material:1.2.1'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test.ext:junit:1.1.2'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
}