Skip to content

Commit 628c953

Browse files
committed
style #12: add card view input and hide status bar
1 parent 896c03f commit 628c953

File tree

3 files changed

+83
-8
lines changed

3 files changed

+83
-8
lines changed

QuizApp/app/src/main/java/com/example/quizapp/MainActivity.kt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,18 @@ package com.example.quizapp
22

33
import androidx.appcompat.app.AppCompatActivity
44
import android.os.Bundle
5+
import android.view.View
56

7+
@Suppress("DEPRECATION")
68
class MainActivity : AppCompatActivity() {
79
override fun onCreate(savedInstanceState: Bundle?) {
810
super.onCreate(savedInstanceState)
911
setContentView(R.layout.activity_main)
12+
13+
// Hide the status bar.
14+
window.decorView.systemUiVisibility = View.SYSTEM_UI_FLAG_FULLSCREEN
15+
// Remember that you should never show the action bar if the
16+
// status bar is hidden, so hide that too if necessary.
17+
actionBar?.hide()
1018
}
1119
}
Lines changed: 70 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,80 @@
11
<?xml version="1.0" encoding="utf-8"?>
2-
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
2+
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
33
xmlns:app="http://schemas.android.com/apk/res-auto"
44
xmlns:tools="http://schemas.android.com/tools"
55
android:layout_width="match_parent"
66
android:layout_height="match_parent"
7+
android:background="@drawable/ic_bg"
8+
android:gravity="center"
9+
android:orientation="vertical"
710
tools:context=".MainActivity">
811

912
<TextView
10-
android:layout_width="wrap_content"
13+
android:id="@+id/tv_app_name"
14+
android:layout_width="match_parent"
1115
android:layout_height="wrap_content"
12-
android:text="Hello World!"
13-
app:layout_constraintBottom_toBottomOf="parent"
14-
app:layout_constraintLeft_toLeftOf="parent"
15-
app:layout_constraintRight_toRightOf="parent"
16-
app:layout_constraintTop_toTopOf="parent" />
16+
android:gravity="center"
17+
android:text="@string/quiz_app"
18+
android:textColor="@android:color/white"
19+
android:textSize="25sp"
20+
android:textStyle="bold" />
1721

18-
</androidx.constraintlayout.widget.ConstraintLayout>
22+
<androidx.cardview.widget.CardView
23+
android:layout_width="match_parent"
24+
android:layout_height="wrap_content"
25+
android:layout_marginStart="20dp"
26+
android:layout_marginEnd="20dp"
27+
android:background="@android:color/white"
28+
app:cardCornerRadius="8dp"
29+
app:cardElevation="5dp">
30+
31+
<LinearLayout
32+
android:layout_width="match_parent"
33+
android:layout_height="wrap_content"
34+
android:orientation="vertical"
35+
android:padding="16dp">
36+
37+
<TextView
38+
android:layout_width="match_parent"
39+
android:layout_height="wrap_content"
40+
android:gravity="center"
41+
android:text="@string/welcome"
42+
android:textColor="#363A43"
43+
android:textSize="30sp"
44+
android:textStyle="bold" />
45+
46+
<TextView
47+
android:layout_width="match_parent"
48+
android:layout_height="wrap_content"
49+
android:gravity="center"
50+
android:text="@string/please_enter_your_name"
51+
android:textColor="#7A8089"
52+
android:textSize="16sp"
53+
android:textStyle="bold" />
54+
55+
<com.google.android.material.textfield.TextInputLayout
56+
style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox"
57+
android:layout_width="match_parent"
58+
android:layout_height="wrap_content"
59+
android:layout_marginTop="20dp">
60+
61+
<androidx.appcompat.widget.AppCompatEditText
62+
android:layout_width="wrap_content"
63+
android:layout_height="match_parent"
64+
android:hint="@string/hint_name"
65+
android:textColor="#363A43"
66+
android:textColorHint="#7A8089" />
67+
</com.google.android.material.textfield.TextInputLayout>
68+
69+
<Button
70+
android:layout_width="match_parent"
71+
android:layout_height="wrap_content"
72+
android:layout_marginTop="16dp"
73+
android:background="@color/purple_700"
74+
android:text="@string/button_start"
75+
android:textSize="18sp"
76+
android:textColor="@android:color/white"/>
77+
</LinearLayout>
78+
</androidx.cardview.widget.CardView>
79+
80+
</LinearLayout>
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
11
<resources>
22
<string name="app_name">Quiz App</string>
3+
<string name="quiz_app">Quiz App</string>
4+
<string name="welcome">Welcome</string>
5+
<string name="please_enter_your_name">Please enter your name</string>
6+
<string name="hint_name">Name</string>
7+
<string name="button_start">Start</string>
38
</resources>

0 commit comments

Comments
 (0)