Android實現(xiàn)注冊界面
本文實例為大家分享了Android實現(xiàn)注冊界面的具體代碼,供大家參考,具體內(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個字符" ? ? ? ? ? ? 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個字符" ? ? ? ? ? ? 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="注冊" ? ? ? ? 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)容,希望對大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。
相關(guān)文章
Kotlin HttpURLConnection與服務(wù)器交互實現(xiàn)方法詳解
簡單來說,HttpURLConnection 是發(fā)起HTTP請求的基礎(chǔ)類庫,提供了HTTP請求的基本功能,不過封裝的比較少,在使用時很多內(nèi)容都需要自己設(shè)置,也需要自己處理請求流和響應(yīng)流2022-09-09
利用Kotlin如何實現(xiàn)Android開發(fā)中的Parcelable詳解
這篇文章主要給大家介紹了關(guān)于利用Kotlin如何實現(xiàn)Android開發(fā)中的Parcelable的相關(guān)資料,并且給大家介紹了關(guān)于Kotlin使用parcelable出現(xiàn):BadParcelableException: Parcelable protocol requires a Parcelable.Creator...問題的解決方法,需要的朋友可以參考下。2017-12-12
android里TextView加下劃線的幾種方法總結(jié)
下面小編就為大家?guī)硪黄猘ndroid里TextView加下劃線的幾種方法總結(jié)。小編覺得挺不錯的,現(xiàn)在就分享給大家,也給大家做個參考。一起跟隨小編過來看看吧2016-10-10
Android應(yīng)用程序簽名步驟及相關(guān)知識介紹
本文主要介紹Android應(yīng)用程序簽名相關(guān)的理論知識,包括:什么是簽名、為什么要給應(yīng)用程序簽名、如何給應(yīng)用程序簽名等,感興趣的朋友可以參考下哈2013-04-04
Android中判斷是否聯(lián)網(wǎng)實現(xiàn)代碼
這篇文章主要介紹了Android中判斷是否聯(lián)網(wǎng)實現(xiàn)代碼,本文直接給出實現(xiàn)代碼,需要的朋友可以參考下2015-06-06
Android編程重寫ViewGroup實現(xiàn)卡片布局的方法
這篇文章主要介紹了Android編程重寫ViewGroup實現(xiàn)卡片布局的方法,實例分析新建FlowLayout繼承ViewGroup類及設(shè)置布局文件實現(xiàn)卡片布局效果的相關(guān)技巧,需要的朋友可以參考下2016-02-02

