Android Create Login Big Image

Android Create Login Big Image


1. Project Structure


2. Gradle

plugins {
  id 'com.android.application'
}

android {
  compileSdkVersion 30
  buildToolsVersion "30.0.3"

  defaultConfig {
    applicationId "com.login.bigimage"
    minSdkVersion 19
    targetSdkVersion 30
    versionCode 1
    versionName "1.0"

    testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
  }

  buildTypes {
    release {
      minifyEnabled false
      proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
    }
  }
  compileOptions {
    sourceCompatibility JavaVersion.VERSION_1_8
    targetCompatibility JavaVersion.VERSION_1_8
  }
}

dependencies {
  implementation 'com.balysv:material-ripple:1.0.2'
  implementation 'androidx.appcompat:appcompat:1.3.0'
  implementation 'com.google.android.material:material:1.4.0'
  implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
  implementation 'com.crystal:crystalrangeseekbar:1.1.3'
  testImplementation 'junit:junit:4.+'
  androidTestImplementation 'androidx.test.ext:junit:1.1.3'
  androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
}

3. Main Activity
package com.login.bigimage;

import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.widget.Toolbar;
import android.graphics.Color;
import android.graphics.PorterDuff;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import com.login.bigimage.utils.Tools;

public class MainActivity extends AppCompatActivity {

  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_login_big_image);
    initToolbar();
  }

  private void initToolbar() {
    Toolbar toolbar = findViewById(R.id.toolbar);
    toolbar.setNavigationIcon(R.drawable.ic_menu);
    toolbar.getNavigationIcon().setColorFilter(Color.WHITE, PorterDuff.Mode.SRC_ATOP);
    setSupportActionBar(toolbar);
    getSupportActionBar().setTitle(null);
    getSupportActionBar().setDisplayHomeAsUpEnabled(false);
  }

  @Override
  public boolean onCreateOptionsMenu(Menu menu) {
    getMenuInflater().inflate(R.menu.menu_close, menu);
    Tools.changeMenuIconColor(menu, Color.WHITE);
    return true;
  }

  @Override
  public boolean onOptionsItemSelected(MenuItem item) {
    if (item.getItemId() == R.id.action_close) {
      finish();
    }
    return super.onOptionsItemSelected(item);
  }
}


4. Layout

<?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:background="@color/grey_5"
  android:fitsSystemWindows="true"
  android:orientation="vertical">

  <RelativeLayout
    android:layout_width="match_parent"
    android:layout_height="400dp">

    <ImageView
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      android:scaleType="centerCrop"
      android:src="@drawable/image_24" />

    <View
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      android:background="@color/overlay_dark_40" />

    <androidx.appcompat.widget.Toolbar
      android:id="@+id/toolbar"
      android:layout_width="match_parent"
      android:layout_height="?android:attr/actionBarSize"
      android:background="@android:color/transparent"
      android:fitsSystemWindows="true"
      android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
      app:contentInsetStartWithNavigation="0dp"
      app:popupTheme="@style/ThemeOverlay.AppCompat.Light" />


    <LinearLayout
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:layout_centerInParent="true"
      android:gravity="center"
      android:orientation="vertical"
      android:paddingBottom="@dimen/spacing_xxlarge">

      <ImageView
        android:layout_width="60dp"
        android:layout_height="60dp"
        android:src="@drawable/logo"
        android:tint="@android:color/white" />

      <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginTop="@dimen/spacing_medium"
        android:text="Material X"
        android:textAppearance="@style/Base.TextAppearance.AppCompat.Headline"
        android:textColor="@android:color/white"
        android:textStyle="bold" />

    </LinearLayout>

  </RelativeLayout>

  <LinearLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:gravity="center"
    android:layout_marginTop="-60dp"
    android:orientation="vertical">

    <androidx.cardview.widget.CardView
      android:layout_width="match_parent"
      android:layout_height="120dp"
      android:layout_marginLeft="@dimen/spacing_mlarge"
      android:layout_marginRight="@dimen/spacing_mlarge"
      app:cardCornerRadius="2dp"
      app:cardElevation="2dp"
      app:cardUseCompatPadding="true">

      <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="vertical">

        <EditText
          android:layout_width="match_parent"
          android:layout_height="0dp"
          android:layout_weight="1"
          android:background="@android:color/transparent"
          android:hint="Email"
          android:paddingLeft="@dimen/spacing_smlarge"
          android:paddingRight="@dimen/spacing_smlarge" />

        <View
          android:layout_width="match_parent"
          android:layout_height="1dp"
          android:background="@color/grey_5" />

        <EditText
          android:layout_width="match_parent"
          android:layout_height="0dp"
          android:layout_weight="1"
          android:background="@android:color/transparent"
          android:hint="Password"
          android:paddingLeft="@dimen/spacing_smlarge"
          android:paddingRight="@dimen/spacing_smlarge" />

      </LinearLayout>

    </androidx.cardview.widget.CardView>

    <com.google.android.material.floatingactionbutton.FloatingActionButton
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:layout_marginTop="@dimen/spacing_mlarge"
      android:clickable="true"
      android:gravity="center"
      android:tint="@android:color/white"
      app:backgroundTint="@color/colorPrimary"
      app:fabSize="normal"
      app:elevation="2dp"
      app:rippleColor="@color/grey_5"
      app:srcCompat="@drawable/ic_chevron_right" />

  </LinearLayout>

</LinearLayout>


5. Value

<?xml version="1.0" encoding="utf-8"?>
<resources xmlns:ns1="urn:oasis:names:tc:xliff:document:1.2">

  <style name="ThemeOverlay.AppCompat.Dark.ActionBar" parent="Base.ThemeOverlay.AppCompat.Dark.ActionBar"/>
  <style name="ThemeOverlay.AppCompat.DayNight" parent="ThemeOverlay.AppCompat.Light"/>
  <style name="Base.TextAppearance.AppCompat.Headline" parent="android:TextAppearance.Material.Headline"/>

  <color name="overlay_dark_40">#66000000</color>
  <color name="grey_5">#f2f2f2</color>

</resources>