Android實(shí)現(xiàn)注冊(cè)界面
本文實(shí)例為大家分享了Android實(shí)現(xiàn)注冊(cè)界面的具體代碼,供大家參考,具體內(nèi)容如下
LinearLayout 控制布局
TextView 用于顯示文字
EditText 輸入框
RadioGroup 單選按鈕和RadioButton一起用
CheckBox 復(fù)選框
Spinner 下拉框
源碼:
register.xml
<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" ? ? android:orientation="vertical" android:layout_width="match_parent" ? ? android:layout_height="match_parent"> ? ? <LinearLayout ? ? ? ? android:layout_width="match_parent" ? ? ? ? android:layout_height="wrap_content" ? ? ? ? > ? ? ? ? <TextView ? ? ? ? ? ? android:layout_width="wrap_content" ? ? ? ? ? ? android:layout_height="wrap_content" ? ? ? ? ? ? android:layout_marginLeft="6dp" ? ? ? ? ? ? android:layout_marginTop="10dp" ? ? ? ? ? ? android:text="用戶名:" ? ? ? ? ? ? android:textSize="15dp" ? ? ? ? ? ? android:textColor="@color/colorPrimary" ? ? ? ? ? ? /> ? ? ? ? <EditText ? ? ? ? ? ? android:layout_width="wrap_content" ? ? ? ? ? ? android:layout_height="wrap_content" ? ? ? ? ? ? android:layout_marginLeft="6dp" ? ? ? ? ? ? android:layout_marginTop="10dp" ? ? ? ? ? ? android:hint="輸入2-10個(gè)字符" ? ? ? ? ? ? android:textColor="@color/colorPrimary" ? ? ? ? ? ? android:layout_weight="1"/> ? ? </LinearLayout> ? ? <LinearLayout ? ? ? ? android:layout_width="match_parent" ? ? ? ? android:layout_height="wrap_content" ? ? ? ? > ? ? ? ? <TextView ? ? ? ? ? ? android:layout_width="wrap_content" ? ? ? ? ? ? android:layout_height="wrap_content" ? ? ? ? ? ? android:layout_marginLeft="6dp" ? ? ? ? ? ? android:layout_marginTop="10dp" ? ? ? ? ? ? android:text="密碼: ? ?" ? ? ? ? ? ? android:textSize="15dp" ? ? ? ? ? ? android:textColor="@color/colorPrimary" ? ? ? ? ? ? /> ? ? ? ? <EditText ? ? ? ? ? ? android:layout_width="wrap_content" ? ? ? ? ? ? android:layout_height="wrap_content" ? ? ? ? ? ? android:layout_marginLeft="6dp" ? ? ? ? ? ? android:layout_marginTop="10dp" ? ? ? ? ? ? android:hint="輸入6-10個(gè)字符" ? ? ? ? ? ? android:textColor="@color/colorPrimary" ? ? ? ? ? ? android:layout_weight="1"/> ? ? </LinearLayout> ? ? <LinearLayout ? ? ? ? android:layout_width="match_parent" ? ? ? ? android:layout_height="wrap_content" ? ? ? ? > ? ? ? ? <TextView ? ? ? ? ? ? android:layout_width="wrap_content" ? ? ? ? ? ? android:layout_height="wrap_content" ? ? ? ? ? ? android:layout_marginLeft="6dp" ? ? ? ? ? ? android:layout_marginTop="23dp" ? ? ? ? ? ? android:text="性別選擇: ? ?" ? ? ? ? ? ? android:textSize="15dp" ? ? ? ? ? ? android:textColor="@color/colorPrimary" ? ? ? ? ? ? /> ? ? ? ? <RadioGroup ? ? ? ? ? ? android:layout_width="wrap_content" ? ? ? ? ? ? android:layout_height="wrap_content" ? ? ? ? ? ? android:orientation="horizontal" ? ? ? ? ? ? android:layout_marginLeft="10dp" ? ? ? ? ? ? android:layout_marginTop="10dp"> ? ? ? ? ? ? <RadioButton ? ? ? ? ? ? ? ? android:layout_width="wrap_content" ? ? ? ? ? ? ? ? android:layout_height="wrap_content" ? ? ? ? ? ? ? ? android:layout_marginLeft="30dp" ? ? ? ? ? ? ? ? android:layout_marginTop="6dp" ? ? ? ? ? ? ? ? android:text="男"/> ? ? ? ? ? ? <RadioButton ? ? ? ? ? ? ? ? android:layout_width="wrap_content" ? ? ? ? ? ? ? ? android:layout_height="wrap_content" ? ? ? ? ? ? ? ? android:layout_marginLeft="30dp" ? ? ? ? ? ? ? ? android:layout_marginTop="6dp" ? ? ? ? ? ? ? ? android:text="女"/> ? ? ? ? </RadioGroup> ? ? </LinearLayout> ? ? <LinearLayout ? ? ? ? android:layout_width="match_parent" ? ? ? ? android:layout_height="wrap_content"> ? ? ? ? <TextView ? ? ? ? ? ? android:layout_width="wrap_content" ? ? ? ? ? ? android:layout_height="wrap_content" ? ? ? ? ? ? android:layout_marginLeft="5dp" ? ? ? ? ? ? android:layout_marginTop="6dp" ? ? ? ? ? ? android:textSize="15dp" ? ? ? ? ? ? android:text="愛好選擇:" ? ? ? ? ? ? android:textColor="@color/colorPrimaryDark"/> ? ? ? ? <CheckBox ? ? ? ? ? ? android:layout_width="wrap_content" ? ? ? ? ? ? android:layout_height="wrap_content" ? ? ? ? ? ? android:layout_marginTop="6dp" ? ? ? ? ? ? android:layout_marginLeft="20dp" ? ? ? ? ? ? android:text="游泳"/> ? ? ? ? <CheckBox ? ? ? ? ? ? android:layout_width="wrap_content" ? ? ? ? ? ? android:layout_height="wrap_content" ? ? ? ? ? ? android:layout_marginTop="6dp" ? ? ? ? ? ? android:layout_marginLeft="20dp" ? ? ? ? ? ? android:text="打球"/> ? ? ? ? <CheckBox ? ? ? ? ? ? android:layout_width="wrap_content" ? ? ? ? ? ? android:layout_height="wrap_content" ? ? ? ? ? ? android:layout_marginTop="6dp" ? ? ? ? ? ? android:layout_marginLeft="20dp" ? ? ? ? ? ? android:text="看書"/> ? ? </LinearLayout> ? ? <LinearLayout ? ? ? ? android:layout_width="match_parent" ? ? ? ? android:layout_height="wrap_content"> ? ? ? ? <TextView ? ? ? ? ? ? android:layout_width="wrap_content" ? ? ? ? ? ? android:layout_height="wrap_content" ? ? ? ? ? ? android:layout_marginLeft="5dp" ? ? ? ? ? ? android:layout_marginTop="6dp" ? ? ? ? ? ? android:textSize="15dp" ? ? ? ? ? ? android:text="所在地"/> ? ? ? ? <Spinner ? ? ? ? ? ? android:layout_width="wrap_content" ? ? ? ? ? ? android:layout_height="wrap_content" ? ? ? ? ? ? android:layout_marginTop="6dp" ? ? ? ? ? ? android:layout_marginLeft="10dp" ? ? ? ? ? ? android:entries="@array/citys"> ? ? ? ? </Spinner> ? ? </LinearLayout> ? ? <Button ? ? ? ? android:layout_width="match_parent" ? ? ? ? android:layout_height="wrap_content" ? ? ? ? android:text="注冊(cè)" ? ? ? ? android:textColor="@color/colorPrimaryDark"/> </LinearLayout>
strings.xml
<resources> ? ? <string name="app_name">Register</string> ? ? <string-array name="citys"> ? ? ? ? <item>贛州</item> ? ? ? ? <item>上海</item> ? ? ? ? <item>廣州</item> ? ? ? ? <item>深圳</item> ? ? ? ? <item>北京</item> ? ? ? ? <item>湖南</item> ? ? ? ? <item>湖北</item> ? ? ? ? <item>南寧</item> ? ? ? ? <item>廈門</item> ? ? </string-array> </resources>
Main.java
package com.example.hsy.register; 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.register); ? ? } }
效果圖
以上就是本文的全部內(nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。
相關(guān)文章
android根據(jù)分辨率自動(dòng)調(diào)整字體大小的實(shí)例代碼
android根據(jù)分辨率自動(dòng)調(diào)整字體大小的實(shí)例代碼,需要的朋友可以參考一下2013-06-06Android Studio 3.0上分析內(nèi)存泄漏的原因
本篇文章主要介紹了Android Studio 3.0上分析內(nèi)存泄漏的原因,小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,也給大家做個(gè)參考。一起跟隨小編過來看看吧2017-11-11Android setButtonDrawable()的兼容問題解決辦法
這篇文章主要介紹了Android setButtonDrawable()的兼容問題解決辦法的相關(guān)資料,需要的朋友可以參考下2017-03-03Android用viewPager2實(shí)現(xiàn)UI界面翻頁滾動(dòng)的效果
自學(xué)Android中,然后需要實(shí)現(xiàn)UI頁面翻頁滑動(dòng)的效果,例如頭條的功能 我這邊利用了viewPager2的翻頁功能,具體流程如下:2021-05-05Android封裝實(shí)現(xiàn)短信驗(yàn)證碼的獲取倒計(jì)時(shí)
這篇文章主要介紹了Android封裝實(shí)現(xiàn)短信驗(yàn)證碼的獲取倒計(jì)時(shí),文中通過示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)吧2023-03-03Android 關(guān)于ExpandableListView刷新問題的解決方法
下面小編就為大家?guī)硪黄狝ndroid 關(guān)于ExpandableListView刷新問題的解決方法。小編覺得挺不錯(cuò)的,現(xiàn)在就分享給大家,也給大家做個(gè)參考。一起跟隨小編過來看看吧2016-12-12Android仿網(wǎng)易一元奪寶客戶端下拉加載動(dòng)畫效果(一)
本文通過一個(gè)demo給大家介紹了android仿網(wǎng)易一元奪寶客戶端下拉加載動(dòng)畫效果,非常不錯(cuò),具有參考借鑒價(jià)值,需要的朋友可以參考下2016-09-09