-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcode_11-12_user_interface.txt
121 lines (105 loc) · 4.34 KB
/
code_11-12_user_interface.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
[source code] Android Development Tutorials 11 and 12 - User Interface
***** Tutorial Notes
//User Interface//
** 11 - Designing the User Interface
1. Start a new project
a. with no Activity. Note this will display the “No files are open” gray screen.
b. Navigate to your app>java>your app and create a new Empty activity. Check Launcher Activity.
c. Open manifest to see that Studio added the launcher information.
2. Delete Hello World
3. Add Large Text, email, password, button
4. Change Large Text’s text property to “Sign In”
** 12 - More on User Interface
1. Changed button text using text editor to Log In
2. Added 320 dp width to Edit Views,
3. explained that dp is device pixel
4. replace hard coded String warning
a. by clicking light bulb and extracting resource
b. open strings.xml Note I got a “rendering problem” message, just click the refresh icon on the editor toolbar.
c. Do the same for the button. Note button displayed the reference instead of the string, so I ran clean project.
TIP!- Ctrl+ hover over a reference/resource and click - takes you right to the resource.
Static layout – uses the xml file.
Dynamic layout - design layout in java.
***** manifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.thenewboston.hamblaster">
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity android:name=".MainActivity">
<intent-filter>Activity States
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
***** MainActivity.java
package com.thenewboston.hamblaster;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
}
***** activity_main.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context="com.thenewboston.hamblaster.MainActivity">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text="@string/SignInTitle"
android:id="@+id/textView"
android:layout_alignParentTop="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/SignInButtonText"
android:id="@+id/button"
android:layout_centerVertical="true"
android:layout_centerHorizontal="true" />
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:inputType="textEmailAddress"
android:ems="10"
android:id="@+id/editText"
android:layout_marginTop="33dp"
android:layout_below="@+id/textView"
android:layout_centerHorizontal="true"
android:width="320dp"/>
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:inputType="numberPassword"
android:ems="10"
android:id="@+id/editText2"
android:layout_below="@+id/editText"
android:layout_centerHorizontal="true"
android:layout_marginTop="32dp"
android:width="320dp" />
</RelativeLayout>
***** strings.xml
<resources>
<string name="app_name">Hamblaster</string>
<string name="SignInTitle">Sign In</string>
<string name="SignInButtonText">Log In</string>
</resources>