Android开发--实现Android登录注册页面(上)

打印 上一主题 下一主题

主题 522|帖子 522|积分 1566

简单的Android开发登录注册,这个是没有连数据库的
首先,新建项目,新建一个登录页面LoginActivity和注册页面RegisterActivity。
下面是登录页面的代码:activity_login.xml
  1. <?xml version="1.0" encoding="utf-8"?>
  2. <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
  3.     xmlns:app="http://schemas.android.com/apk/res-auto"
  4.     xmlns:tools="http://schemas.android.com/tools"
  5.     android:layout_width="match_parent"
  6.     android:layout_height="match_parent"
  7.     android:orientation="vertical"
  8.     tools:context=".LoginActivity">
  9.     <LinearLayout
  10. <?xml version="1.0" encoding="utf-8"?>
  11. <resources>
  12.    
  13.    
  14. </resources>android:layout_width="match_parent"
  15. <?xml version="1.0" encoding="utf-8"?>
  16. <resources>
  17.    
  18.    
  19. </resources>android:layout_height="wrap_content"
  20. <?xml version="1.0" encoding="utf-8"?>
  21. <resources>
  22.    
  23.    
  24. </resources>android:orientation="horizontal"
  25. <?xml version="1.0" encoding="utf-8"?>
  26. <resources>
  27.    
  28.    
  29. </resources>android:layout_marginLeft="20dp"
  30. <?xml version="1.0" encoding="utf-8"?>
  31. <resources>
  32.    
  33.    
  34. </resources>android:layout_marginRight="20dp"
  35. <?xml version="1.0" encoding="utf-8"?>
  36. <resources>
  37.    
  38.    
  39. </resources>android:layout_marginTop="20dp"
  40. <?xml version="1.0" encoding="utf-8"?>
  41. <resources>
  42.    
  43.    
  44. </resources>android:gravity="center_vertical">
  45. <?xml version="1.0" encoding="utf-8"?>
  46. <resources>
  47.    
  48.    
  49. </resources><TextView
  50. <?xml version="1.0" encoding="utf-8"?>
  51. <resources>
  52.    
  53.    
  54. </resources>    android:layout_width="wrap_content"
  55. <?xml version="1.0" encoding="utf-8"?>
  56. <resources>
  57.    
  58.    
  59. </resources>    android:layout_height="wrap_content"
  60. <?xml version="1.0" encoding="utf-8"?>
  61. <resources>
  62.    
  63.    
  64. </resources>    android:text="账号:"
  65. <?xml version="1.0" encoding="utf-8"?>
  66. <resources>
  67.    
  68.    
  69. </resources>    android:textSize="25sp" />
  70. <?xml version="1.0" encoding="utf-8"?>
  71. <resources>
  72.    
  73.    
  74. </resources><EditText
  75. <?xml version="1.0" encoding="utf-8"?>
  76. <resources>
  77.    
  78.    
  79. </resources>    android:id="@+id/et_account"
  80. <?xml version="1.0" encoding="utf-8"?>
  81. <resources>
  82.    
  83.    
  84. </resources>    android:layout_width="match_parent"
  85. <?xml version="1.0" encoding="utf-8"?>
  86. <resources>
  87.    
  88.    
  89. </resources>    android:hint="请输入用户名或手机号"
  90. <?xml version="1.0" encoding="utf-8"?>
  91. <resources>
  92.    
  93.    
  94. </resources>    style="@style/MyEditStyle"
  95. <?xml version="1.0" encoding="utf-8"?>
  96. <resources>
  97.    
  98.    
  99. </resources>    android:layout_marginLeft="10dp"
  100. <?xml version="1.0" encoding="utf-8"?>
  101. <resources>
  102.    
  103.    
  104. </resources>    android:inputType="text"></EditText>
  105.     </LinearLayout>
  106.     <LinearLayout
  107. <?xml version="1.0" encoding="utf-8"?>
  108. <resources>
  109.    
  110.    
  111. </resources>android:layout_width="match_parent"
  112. <?xml version="1.0" encoding="utf-8"?>
  113. <resources>
  114.    
  115.    
  116. </resources>android:layout_height="wrap_content"
  117. <?xml version="1.0" encoding="utf-8"?>
  118. <resources>
  119.    
  120.    
  121. </resources>android:orientation="horizontal"
  122. <?xml version="1.0" encoding="utf-8"?>
  123. <resources>
  124.    
  125.    
  126. </resources>android:layout_marginLeft="20dp"
  127. <?xml version="1.0" encoding="utf-8"?>
  128. <resources>
  129.    
  130.    
  131. </resources>android:layout_marginRight="20dp"
  132. <?xml version="1.0" encoding="utf-8"?>
  133. <resources>
  134.    
  135.    
  136. </resources>android:layout_marginTop="20dp"
  137. <?xml version="1.0" encoding="utf-8"?>
  138. <resources>
  139.    
  140.    
  141. </resources>android:gravity="center_vertical">
  142. <?xml version="1.0" encoding="utf-8"?>
  143. <resources>
  144.    
  145.    
  146. </resources><TextView
  147. <?xml version="1.0" encoding="utf-8"?>
  148. <resources>
  149.    
  150.    
  151. </resources>    android:layout_width="wrap_content"
  152. <?xml version="1.0" encoding="utf-8"?>
  153. <resources>
  154.    
  155.    
  156. </resources>    android:layout_height="wrap_content"
  157. <?xml version="1.0" encoding="utf-8"?>
  158. <resources>
  159.    
  160.    
  161. </resources>    android:text="密码:"
  162. <?xml version="1.0" encoding="utf-8"?>
  163. <resources>
  164.    
  165.    
  166. </resources>    android:textSize="25sp" />
  167. <?xml version="1.0" encoding="utf-8"?>
  168. <resources>
  169.    
  170.    
  171. </resources><EditText
  172. <?xml version="1.0" encoding="utf-8"?>
  173. <resources>
  174.    
  175.    
  176. </resources>    android:id="@+id/et_password"
  177. <?xml version="1.0" encoding="utf-8"?>
  178. <resources>
  179.    
  180.    
  181. </resources>    android:layout_width="match_parent"
  182. <?xml version="1.0" encoding="utf-8"?>
  183. <resources>
  184.    
  185.    
  186. </resources>    android:hint="请输入密码"
  187. <?xml version="1.0" encoding="utf-8"?>
  188. <resources>
  189.    
  190.    
  191. </resources>    style="@style/MyEditStyle"
  192. <?xml version="1.0" encoding="utf-8"?>
  193. <resources>
  194.    
  195.    
  196. </resources>    android:layout_marginLeft="10dp"
  197. <?xml version="1.0" encoding="utf-8"?>
  198. <resources>
  199.    
  200.    
  201. </resources>    android:inputType="numberPassword"></EditText>
  202.     </LinearLayout>
  203.     <LinearLayout
  204. <?xml version="1.0" encoding="utf-8"?>
  205. <resources>
  206.    
  207.    
  208. </resources>android:layout_width="match_parent"
  209. <?xml version="1.0" encoding="utf-8"?>
  210. <resources>
  211.    
  212.    
  213. </resources>android:layout_height="wrap_content"
  214. <?xml version="1.0" encoding="utf-8"?>
  215. <resources>
  216.    
  217.    
  218. </resources>android:orientation="horizontal"
  219. <?xml version="1.0" encoding="utf-8"?>
  220. <resources>
  221.    
  222.    
  223. </resources>android:gravity="center"
  224. <?xml version="1.0" encoding="utf-8"?>
  225. <resources>
  226.    
  227.    
  228. </resources>android:layout_marginTop="20dp"
  229. <?xml version="1.0" encoding="utf-8"?>
  230. <resources>
  231.    
  232.    
  233. </resources>android:layout_marginLeft="20dp"
  234. <?xml version="1.0" encoding="utf-8"?>
  235. <resources>
  236.    
  237.    
  238. </resources>android:layout_marginRight="20dp"
  239. <?xml version="1.0" encoding="utf-8"?>
  240. <resources>
  241.    
  242.    
  243. </resources>>
  244. <?xml version="1.0" encoding="utf-8"?>
  245. <resources>
  246.    
  247.    
  248. </resources><CheckBox
  249. <?xml version="1.0" encoding="utf-8"?>
  250. <resources>
  251.    
  252.    
  253. </resources>    android:id="@+id/cb_remember"
  254. <?xml version="1.0" encoding="utf-8"?>
  255. <resources>
  256.    
  257.    
  258. </resources>    android:layout_width="wrap_content"
  259. <?xml version="1.0" encoding="utf-8"?>
  260. <resources>
  261.    
  262.    
  263. </resources>    android:layout_height="wrap_content"
  264. <?xml version="1.0" encoding="utf-8"?>
  265. <resources>
  266.    
  267.    
  268. </resources>    android:text="记住密码"></CheckBox>
  269.     </LinearLayout>
  270.     <Button
  271. <?xml version="1.0" encoding="utf-8"?>
  272. <resources>
  273.    
  274.    
  275. </resources>android:id="@+id/btn_login"
  276. <?xml version="1.0" encoding="utf-8"?>
  277. <resources>
  278.    
  279.    
  280. </resources>android:layout_width="match_parent"
  281. <?xml version="1.0" encoding="utf-8"?>
  282. <resources>
  283.    
  284.    
  285. </resources>android:layout_height="wrap_content"
  286. <?xml version="1.0" encoding="utf-8"?>
  287. <resources>
  288.    
  289.    
  290. </resources>android:text="登录"
  291. <?xml version="1.0" encoding="utf-8"?>
  292. <resources>
  293.    
  294.    
  295. </resources>style="@style/MyBtnStyle"
  296. <?xml version="1.0" encoding="utf-8"?>
  297. <resources>
  298.    
  299.    
  300. </resources>android:layout_marginTop="20dp"
  301. <?xml version="1.0" encoding="utf-8"?>
  302. <resources>
  303.    
  304.    
  305. </resources>android:layout_marginLeft="20dp"
  306. <?xml version="1.0" encoding="utf-8"?>
  307. <resources>
  308.    
  309.    
  310. </resources>android:layout_marginRight="20dp"></Button>
  311.     <TextView
  312. <?xml version="1.0" encoding="utf-8"?>
  313. <resources>
  314.    
  315.    
  316. </resources>android:layout_width="wrap_content"
  317. <?xml version="1.0" encoding="utf-8"?>
  318. <resources>
  319.    
  320.    
  321. </resources>android:layout_height="wrap_content"
  322. <?xml version="1.0" encoding="utf-8"?>
  323. <resources>
  324.    
  325.    
  326. </resources>android:textColor="@color/colorPrimary"
  327. <?xml version="1.0" encoding="utf-8"?>
  328. <resources>
  329.    
  330.    
  331. </resources>android:text="还没有账号?"
  332. <?xml version="1.0" encoding="utf-8"?>
  333. <resources>
  334.    
  335.    
  336. </resources>android:layout_gravity="right"
  337. <?xml version="1.0" encoding="utf-8"?>
  338. <resources>
  339.    
  340.    
  341. </resources>android:layout_marginRight="20dp"
  342. <?xml version="1.0" encoding="utf-8"?>
  343. <resources>
  344.    
  345.    
  346. </resources>android:layout_marginTop="10dp"
  347. <?xml version="1.0" encoding="utf-8"?>
  348. <resources>
  349.    
  350.    
  351. </resources>android:onClick="toRegister"
  352. <?xml version="1.0" encoding="utf-8"?>
  353. <resources>
  354.    
  355.    
  356. </resources>></TextView>
  357. </LinearLayout>
复制代码
效果如图:



下面是注册页面的代码:activity_register.xml
  1. <?xml version="1.0" encoding="utf-8"?>
  2. <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
  3.     xmlns:app="http://schemas.android.com/apk/res-auto"
  4.     xmlns:tools="http://schemas.android.com/tools"
  5.     android:layout_width="match_parent"
  6.     android:layout_height="match_parent"
  7.     android:orientation="vertical"
  8.     tools:context=".LoginActivity">
  9.     <LinearLayout
  10. <?xml version="1.0" encoding="utf-8"?>
  11. <resources>
  12.    
  13.    
  14. </resources>android:layout_width="match_parent"
  15. <?xml version="1.0" encoding="utf-8"?>
  16. <resources>
  17.    
  18.    
  19. </resources>android:layout_height="wrap_content"
  20. <?xml version="1.0" encoding="utf-8"?>
  21. <resources>
  22.    
  23.    
  24. </resources>android:orientation="horizontal"
  25. <?xml version="1.0" encoding="utf-8"?>
  26. <resources>
  27.    
  28.    
  29. </resources>android:layout_marginLeft="20dp"
  30. <?xml version="1.0" encoding="utf-8"?>
  31. <resources>
  32.    
  33.    
  34. </resources>android:layout_marginRight="20dp"
  35. <?xml version="1.0" encoding="utf-8"?>
  36. <resources>
  37.    
  38.    
  39. </resources>android:layout_marginTop="20dp"
  40. <?xml version="1.0" encoding="utf-8"?>
  41. <resources>
  42.    
  43.    
  44. </resources>android:gravity="center_vertical">
  45. <?xml version="1.0" encoding="utf-8"?>
  46. <resources>
  47.    
  48.    
  49. </resources><TextView
  50. <?xml version="1.0" encoding="utf-8"?>
  51. <resources>
  52.    
  53.    
  54. </resources>    android:layout_width="wrap_content"
  55. <?xml version="1.0" encoding="utf-8"?>
  56. <resources>
  57.    
  58.    
  59. </resources>    android:layout_height="wrap_content"
  60. <?xml version="1.0" encoding="utf-8"?>
  61. <resources>
  62.    
  63.    
  64. </resources>    android:text="账号:"
  65. <?xml version="1.0" encoding="utf-8"?>
  66. <resources>
  67.    
  68.    
  69. </resources>    android:textSize="25sp" />
  70. <?xml version="1.0" encoding="utf-8"?>
  71. <resources>
  72.    
  73.    
  74. </resources><EditText
  75. <?xml version="1.0" encoding="utf-8"?>
  76. <resources>
  77.    
  78.    
  79. </resources>    android:id="@+id/et_account"
  80. <?xml version="1.0" encoding="utf-8"?>
  81. <resources>
  82.    
  83.    
  84. </resources>    android:layout_width="match_parent"
  85. <?xml version="1.0" encoding="utf-8"?>
  86. <resources>
  87.    
  88.    
  89. </resources>    android:hint="请输入用户名或手机号"
  90. <?xml version="1.0" encoding="utf-8"?>
  91. <resources>
  92.    
  93.    
  94. </resources>    style="@style/MyEditStyle"
  95. <?xml version="1.0" encoding="utf-8"?>
  96. <resources>
  97.    
  98.    
  99. </resources>    android:layout_marginLeft="10dp"
  100. <?xml version="1.0" encoding="utf-8"?>
  101. <resources>
  102.    
  103.    
  104. </resources>    android:inputType="text"></EditText>
  105.     </LinearLayout>
  106.     <LinearLayout
  107. <?xml version="1.0" encoding="utf-8"?>
  108. <resources>
  109.    
  110.    
  111. </resources>android:layout_width="match_parent"
  112. <?xml version="1.0" encoding="utf-8"?>
  113. <resources>
  114.    
  115.    
  116. </resources>android:layout_height="wrap_content"
  117. <?xml version="1.0" encoding="utf-8"?>
  118. <resources>
  119.    
  120.    
  121. </resources>android:orientation="horizontal"
  122. <?xml version="1.0" encoding="utf-8"?>
  123. <resources>
  124.    
  125.    
  126. </resources>android:layout_marginLeft="20dp"
  127. <?xml version="1.0" encoding="utf-8"?>
  128. <resources>
  129.    
  130.    
  131. </resources>android:layout_marginRight="20dp"
  132. <?xml version="1.0" encoding="utf-8"?>
  133. <resources>
  134.    
  135.    
  136. </resources>android:layout_marginTop="20dp"
  137. <?xml version="1.0" encoding="utf-8"?>
  138. <resources>
  139.    
  140.    
  141. </resources>android:gravity="center_vertical">
  142. <?xml version="1.0" encoding="utf-8"?>
  143. <resources>
  144.    
  145.    
  146. </resources><TextView
  147. <?xml version="1.0" encoding="utf-8"?>
  148. <resources>
  149.    
  150.    
  151. </resources>    android:layout_width="wrap_content"
  152. <?xml version="1.0" encoding="utf-8"?>
  153. <resources>
  154.    
  155.    
  156. </resources>    android:layout_height="wrap_content"
  157. <?xml version="1.0" encoding="utf-8"?>
  158. <resources>
  159.    
  160.    
  161. </resources>    android:text="密码:"
  162. <?xml version="1.0" encoding="utf-8"?>
  163. <resources>
  164.    
  165.    
  166. </resources>    android:textSize="25sp" />
  167. <?xml version="1.0" encoding="utf-8"?>
  168. <resources>
  169.    
  170.    
  171. </resources><EditText
  172. <?xml version="1.0" encoding="utf-8"?>
  173. <resources>
  174.    
  175.    
  176. </resources>    android:id="@+id/et_password"
  177. <?xml version="1.0" encoding="utf-8"?>
  178. <resources>
  179.    
  180.    
  181. </resources>    android:layout_width="match_parent"
  182. <?xml version="1.0" encoding="utf-8"?>
  183. <resources>
  184.    
  185.    
  186. </resources>    android:hint="请输入密码"
  187. <?xml version="1.0" encoding="utf-8"?>
  188. <resources>
  189.    
  190.    
  191. </resources>    style="@style/MyEditStyle"
  192. <?xml version="1.0" encoding="utf-8"?>
  193. <resources>
  194.    
  195.    
  196. </resources>    android:layout_marginLeft="10dp"
  197. <?xml version="1.0" encoding="utf-8"?>
  198. <resources>
  199.    
  200.    
  201. </resources>    android:inputType="numberPassword"></EditText>
  202.     </LinearLayout>
  203.     <LinearLayout
  204. <?xml version="1.0" encoding="utf-8"?>
  205. <resources>
  206.    
  207.    
  208. </resources>android:layout_width="match_parent"
  209. <?xml version="1.0" encoding="utf-8"?>
  210. <resources>
  211.    
  212.    
  213. </resources>android:layout_height="wrap_content"
  214. <?xml version="1.0" encoding="utf-8"?>
  215. <resources>
  216.    
  217.    
  218. </resources>android:orientation="horizontal"
  219. <?xml version="1.0" encoding="utf-8"?>
  220. <resources>
  221.    
  222.    
  223. </resources>android:gravity="center"
  224. <?xml version="1.0" encoding="utf-8"?>
  225. <resources>
  226.    
  227.    
  228. </resources>android:layout_marginTop="20dp"
  229. <?xml version="1.0" encoding="utf-8"?>
  230. <resources>
  231.    
  232.    
  233. </resources>android:layout_marginLeft="20dp"
  234. <?xml version="1.0" encoding="utf-8"?>
  235. <resources>
  236.    
  237.    
  238. </resources>android:layout_marginRight="20dp"
  239. <?xml version="1.0" encoding="utf-8"?>
  240. <resources>
  241.    
  242.    
  243. </resources>>
  244. <?xml version="1.0" encoding="utf-8"?>
  245. <resources>
  246.    
  247.    
  248. </resources><CheckBox
  249. <?xml version="1.0" encoding="utf-8"?>
  250. <resources>
  251.    
  252.    
  253. </resources>    android:id="@+id/cb_remember"
  254. <?xml version="1.0" encoding="utf-8"?>
  255. <resources>
  256.    
  257.    
  258. </resources>    android:layout_width="wrap_content"
  259. <?xml version="1.0" encoding="utf-8"?>
  260. <resources>
  261.    
  262.    
  263. </resources>    android:layout_height="wrap_content"
  264. <?xml version="1.0" encoding="utf-8"?>
  265. <resources>
  266.    
  267.    
  268. </resources>    android:text="记住密码"></CheckBox>
  269.     </LinearLayout>
  270.     <Button
  271. <?xml version="1.0" encoding="utf-8"?>
  272. <resources>
  273.    
  274.    
  275. </resources>android:id="@+id/btn_login"
  276. <?xml version="1.0" encoding="utf-8"?>
  277. <resources>
  278.    
  279.    
  280. </resources>android:layout_width="match_parent"
  281. <?xml version="1.0" encoding="utf-8"?>
  282. <resources>
  283.    
  284.    
  285. </resources>android:layout_height="wrap_content"
  286. <?xml version="1.0" encoding="utf-8"?>
  287. <resources>
  288.    
  289.    
  290. </resources>android:text="登录"
  291. <?xml version="1.0" encoding="utf-8"?>
  292. <resources>
  293.    
  294.    
  295. </resources>style="@style/MyBtnStyle"
  296. <?xml version="1.0" encoding="utf-8"?>
  297. <resources>
  298.    
  299.    
  300. </resources>android:layout_marginTop="20dp"
  301. <?xml version="1.0" encoding="utf-8"?>
  302. <resources>
  303.    
  304.    
  305. </resources>android:layout_marginLeft="20dp"
  306. <?xml version="1.0" encoding="utf-8"?>
  307. <resources>
  308.    
  309.    
  310. </resources>android:layout_marginRight="20dp"></Button>
  311.     <TextView
  312. <?xml version="1.0" encoding="utf-8"?>
  313. <resources>
  314.    
  315.    
  316. </resources>android:layout_width="wrap_content"
  317. <?xml version="1.0" encoding="utf-8"?>
  318. <resources>
  319.    
  320.    
  321. </resources>android:layout_height="wrap_content"
  322. <?xml version="1.0" encoding="utf-8"?>
  323. <resources>
  324.    
  325.    
  326. </resources>android:textColor="@color/colorPrimary"
  327. <?xml version="1.0" encoding="utf-8"?>
  328. <resources>
  329.    
  330.    
  331. </resources>android:text="还没有账号?"
  332. <?xml version="1.0" encoding="utf-8"?>
  333. <resources>
  334.    
  335.    
  336. </resources>android:layout_gravity="right"
  337. <?xml version="1.0" encoding="utf-8"?>
  338. <resources>
  339.    
  340.    
  341. </resources>android:layout_marginRight="20dp"
  342. <?xml version="1.0" encoding="utf-8"?>
  343. <resources>
  344.    
  345.    
  346. </resources>android:layout_marginTop="10dp"
  347. <?xml version="1.0" encoding="utf-8"?>
  348. <resources>
  349.    
  350.    
  351. </resources>android:onClick="toRegister"
  352. <?xml version="1.0" encoding="utf-8"?>
  353. <resources>
  354.    
  355.    
  356. </resources>></TextView>
  357. </LinearLayout><?xml version="1.0" encoding="utf-8"?>
  358. <resources>
  359.    
  360.    
  361. </resources>
复制代码
效果如图:


最后,在LoginActivity.java中,加入一串代码:getSupportActionBar().setTitle("登录");
在RegisterActivity.java中,加入一串代码:getSupportActionBar().setTitle("注册");
  1. public class LoginActivity extends AppCompatActivity {
  2.     public static final int REQUEST_CODE_REGISTER = 1;
  3.     private static final String TAG="tag";
  4.     private Button btnLogin;
  5.     private EditText etAccount,etPassword;
  6.     private CheckBox cbRemember;
  7.     private String userName="a";
  8.     private String pass="123";
  9.     @Override
  10.     protected void onCreate(Bundle savedInstanceState) {
  11. <?xml version="1.0" encoding="utf-8"?>
  12. <resources>
  13.    
  14.    
  15. </resources>super.onCreate(savedInstanceState);
  16. <?xml version="1.0" encoding="utf-8"?>
  17. <resources>
  18.    
  19.    
  20. </resources>setContentView(R.layout.activity_login);
  21. <?xml version="1.0" encoding="utf-8"?>
  22. <resources>
  23.    
  24.    
  25. </resources>getSupportActionBar().setTitle("登录");
  26.      }
  27. }
复制代码
 上面的代码是LoginActivity.java中的代码,其实要添加的只有一句,其他都写出来是为了让读者能看懂,具体写在哪里。这段代码的作用是: 使标题栏那边显示的文字是登录/注册,而不是一串默认的英文
下面两张图片,左边是未添加代码的效果,右边是添加代码后的效果


写到这里,页面整体布局大致完成了,下面,你们需要添加部分细节,来使得颜色和样式跟我一致。我在上面的xml文件代码中,有下面这个代码:
  1. style="@style/MyEditStyle"和style="@style/MyBtnStyle"
复制代码
你们在前面写的时候,可能会报错,很正常,因为这是引用控件样式的代码,你们需要设置一下这个样式,然后引用,就不会报错啦。
这是设置EditText和Button控件的样式,首先新建style.xml文件。在values中右键,New--Values Resource File,文件名为style。在style.xml文件中,写如下代码:
  1. <?xml version="1.0" encoding="utf-8"?>
  2. <resources>
  3.    
  4.    
  5. </resources>
复制代码
 这里面又引用了样式,是设置输入框的边框和按钮的背景颜色。继续下面的步骤:drawable右键--New--Drawable Resource File,文件名为:btn_bg_selector,代码如下:
  1. <?xml version="1.0" encoding="utf-8"?>
  2. <resources>
  3.    
  4.    
  5. </resources>
复制代码
 drawable右键--New--Drawable Resource File,文件名为:edit_text_bg,代码如下:
  1. <?xml version="1.0" encoding="utf-8"?>
  2. <resources>
  3.    
  4.    
  5. </resources>
复制代码
最后,再调整一下导航栏和标题栏的颜色,就OK啦
colors.xml文件中,添加绿色这个颜色,如下代码,
  1.     <color name="colorPrimary">@color/green_500</color>
  2.     <color name="colorPrimaryDark">@color/green_700</color>
  3.     <color name="colorAccent">#E64A19</color>
  4.     <color name="green_200">#A5D6A7</color>
  5.     <color name="green_500">#4CAF50</color>
  6.     <color name="green_700">#4CAF50</color>
复制代码
themes.xml文件中,只需要修改前两个item的内容,其他代码是为了你们参照一下位置,别改错了。代码如下:
  1. <?xml version="1.0" encoding="utf-8"?>
  2. <resources>
  3.    
  4.    
  5. </resources>
复制代码
到这里,你的登录注册页面部分就完成啦!恭喜你!
以上代码,都是我自己一个个敲的,也运行过,运行结果是没问题的。当然如果你有什么意见建议,请不吝赐教❥(^_-)
具体的跳转实现看下一篇笔记哦,下一篇笔记结尾也有源码分享。

免责声明:如果侵犯了您的权益,请联系站长,我们会及时删除侵权内容,谢谢合作!
回复

使用道具 举报

0 个回复

正序浏览

快速回复

您需要登录后才可以回帖 登录 or 立即注册

本版积分规则

前进之路

金牌会员
这个人很懒什么都没写!

标签云

快速回复 返回顶部 返回列表