Skip to content

Instantly share code, notes, and snippets.

@PPartisan
Created November 2, 2016 22:05
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save PPartisan/6c563e1a7d4a625040883131a8ad5049 to your computer and use it in GitHub Desktop.
Save PPartisan/6c563e1a7d4a625040883131a8ad5049 to your computer and use it in GitHub Desktop.
Quick sample layout for a login screen using support libraries
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:android="http://schemas.android.com/apk/res/android">
<ImageView
android:id="@+id/background"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
<android.support.v7.widget.GridLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:layout_marginBottom="16dp"
android:layout_marginStart="16dp"
android:layout_marginEnd="16dp"
android:paddingTop="16dp"
android:paddingBottom="16dp"
app:columnCount="2"
android:layout_gravity="center">
<Button
android:id="@+id/login_btn_google"
android:layout_width="0dp"
android:layout_height="wrap_content"
app:layout_columnWeight="1"
android:text="Sign Up"
android:drawableLeft="@drawable/ic_google"
android:gravity="center"
android:padding="16dp"
app:backgroundTint="#dd4b39"
style="@style/Widget.AppCompat.Button.Colored" />
<Button
android:id="@+id/login_btn_facebook"
android:layout_width="0dp"
android:layout_height="wrap_content"
app:layout_columnWeight="1"
android:text="Sign Up"
android:drawableLeft="@drawable/ic_facebook"
android:gravity="center"
android:padding="16dp"
app:backgroundTint="#3b5998"
style="@style/Widget.AppCompat.Button.Colored" />
<android.support.v7.widget.CardView
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_columnSpan="2"
app:cardElevation="0dp"
app:cardUseCompatPadding="true"
app:cardBackgroundColor="#44ffffff">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="48dp"
android:layout_marginStart="16dp"
android:layout_marginEnd="16dp"
android:orientation="horizontal">
<ImageView
android:layout_width="24dp"
android:layout_height="24dp"
android:layout_gravity="center"
android:src="@drawable/ic_person_white_24dp"/>
<EditText
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:hint="Username"
android:layout_marginStart="16dp"
android:layout_marginEnd="16dp"
android:background="@null"
android:gravity="center_vertical"
android:textColorHint="@android:color/white"
android:textColor="@android:color/white"/>
</LinearLayout>
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="#88ffffff" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="48dp"
android:layout_marginStart="16dp"
android:layout_marginEnd="16dp"
android:orientation="horizontal">
<ImageView
android:layout_width="24dp"
android:layout_height="24dp"
android:layout_gravity="center"
android:src="@drawable/ic_lock_white_24dp"/>
<EditText
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:hint="Password"
android:layout_marginStart="16dp"
android:layout_marginEnd="16dp"
android:background="@null"
android:gravity="center_vertical"
android:textColorHint="@android:color/white"
android:textColor="@android:color/white"/>
</LinearLayout>
</LinearLayout>
</android.support.v7.widget.CardView>
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Create account"
android:padding="16dp"
app:layout_columnSpan="2"
app:backgroundTint="@android:color/white"/>
</android.support.v7.widget.GridLayout>
</FrameLayout>
public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
Window w = getWindow();
w.setFlags(
WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS,
WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS
);
}
setContentView(R.layout.activity_main);
final ImageView background = (ImageView) findViewById(R.id.background);
Picasso.with(this).load(R.drawable.bg).fit().centerCrop().into(background);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment