android實(shí)現(xiàn)注冊頁面開發(fā)
本文實(shí)例為大家分享了android實(shí)現(xiàn)注冊頁面開發(fā)的具體代碼,供大家參考,具體內(nèi)容如下

在values文件里創(chuàng)建以下幾個(gè)文件

colors代碼:
<?xml version="1.0" encoding="utf-8"?> <resources> ? ? <color name="purple_200">#FFBB86FC</color> ? ? <color name="purple_500">#FF6200EE</color> ? ? <color name="purple_700">#FF3700B3</color> ? ? <color name="teal_200">#FF03DAC5</color> ? ? <color name="teal_700">#FF018786</color> ? ? <color name="black">#FF000000</color> ? ? <color name="white">#FFFFFFFF</color> </resources>
strings代碼塊
<resources> ? ? <string name="app_name">19260234anzidawang</string> </resources>
修改為自己的學(xué)號
styles代碼
<?xml version="1.0" encoding="utf-8"?> <resources> ? ? <style name="hLine"> ? ? ? ? <item name="android:layout_width">match_parent</item> ? ? ? ? <item name="android:layout_height">1dp</item> ? ? ? ? <item name="android:background">@android:color/white</item> ? ? </style> ? ? <style name="vLine"> ? ? ? ? <item name="android:layout_width">1dp</item> ? ? ? ? <item name="android:layout_height">match_parent</item> ? ? ? ? <item name="android:background">@android:color/white</item> ? ? </style> ? ? <style name="tvone"> ? ? ? ? <item name="android:layout_height">match_parent</item> ? ? ? ? <item name="android:layout_width">0dp</item> ? ? ? ? <item name="android:layout_weight">1</item> ? ? ? ? <item name="android:drawablePadding">8dp</item> ? ? ? ? <item name="android:gravity">center_horizontal</item> ? ? ? ? <item name="android:paddingTop">40dp</item> ? ? ? ? <item name="android:textColor">@android:color/white</item> ? ? ? ? <item name="android:textSize">15dp</item> ? ? </style> ? ? <style name="tvtwo"> ? ? ? ? <item name="android:layout_width">wrap_content</item> ? ? ? ? <item name="android:layout_height">wrap_content</item> ? ? ? ? <item name="android:layout_marginLeft">20dp</item> ? ? ? ? <item name="android:textColor">@android:color/white</item> ? ? ? ? <item name="android:textSize">15dp</item> ? ? </style> ? ? <style name="etOne"> ? ? ? ? <item name="android:layout_width">match_parent</item> ? ? ? ? <item name="android:layout_height">wrap_content</item> ? ? ? ? <item name="android:layout_marginLeft">30dp</item> ? ? ? ? <item name="android:background">@null</item> ? ? ? ? <item name="android:textColor">@android:color/white</item> ? ? </style> </resources>
布局文件(activity_main)
<?xml version="1.0" encoding="utf-8"?> <RelativeLayout ? ?xmlns:android="http://schemas.android.com/apk/res/android" ? ? android:layout_width="match_parent" ? ? android:layout_height="match_parent" ? ? android:background="@drawable/register_bg"> ? ? <LinearLayout ? ? ? ? android:layout_width="match_parent" ? ? ? ? android:layout_height="match_parent" ? ? ? ? android:orientation="vertical"> ? ? ? ? <TextView ? ? ? ? ? ? android:id="@+id/tv_title" ? ? ? ? ? ? android:layout_width="match_parent" ? ? ? ? ? ? android:layout_height="50dp" ? ? ? ? ? ? android:background="#01ceff" ? ? ? ? ? ? android:gravity="center" ? ? ? ? ? ? android:text="注冊" ? ? ? ? ? ? android:textColor="@color/white" ? ? ? ? ? ? android:textSize="20sp"/> ? ? ? ? <LinearLayout ? ? ? ? ? ? android:layout_width="match_parent" ? ? ? ? ? ? android:layout_height="130dp" ? ? ? ? ? ? android:orientation="horizontal"> ? ? ? ? ? ? <TextView ? ? ? ? ? ? ? ? style="@style/tvone" ? ? ? ? ? ? ? ? android:drawableTop="@drawable/qq_icon" ? ? ? ? ? ? ? ? android:text="qq register"/> ? ? ? ? ? ? <View style="@style/vLine"/> ? ? ? ? ? ? <TextView ? ? ? ? ? ? ? ? style="@style/tvone" ? ? ? ? ? ? ? ? android:drawableTop="@drawable/weixin_icon" ? ? ? ? ? ? ? ? android:text="wechat register"/> ? ? ? ? </LinearLayout> ? ? ? ? <View style="@style/hLine"/> ? ? ? ? <LinearLayout ? ? ? ? ? ? android:layout_width="match_parent" ? ? ? ? ? ? android:layout_height="wrap_content" ? ? ? ? ? ? android:gravity="center" ? ? ? ? ? ? android:orientation="horizontal" ? ? ? ? ? ? android:padding="15dp"> ? ? ? ? ? ? <ImageView ? ? ? ? ? ? ? ? android:layout_width="wrap_content" ? ? ? ? ? ? ? ? android:layout_height="match_parent" ? ? ? ? ? ? ? ? android:src="@drawable/email_icon"/> ? ? ? ? ? ? <TextView ? ? ? ? ? ? ? ? android:layout_width="wrap_content" ? ? ? ? ? ? ? ? android:layout_height="match_parent" ? ? ? ? ? ? ? ? android:layout_marginLeft="15dp" ? ? ? ? ? ? ? ? android:text="use email register" ? ? ? ? ? ? ? ? android:textColor="@android:color/white" ? ? ? ? ? ? ? ? android:textSize="15sp"/> ? ? ? ? </LinearLayout> ? ? ? ? <View style="@style/hLine" /> ? ? ? ? <LinearLayout ? ? ? ? ? ? android:layout_width="match_parent" ? ? ? ? ? ? android:layout_height="wrap_content" ? ? ? ? ? ? android:orientation="horizontal" ? ? ? ? ? ? android:padding="15dp"> ? ? ? ? ? ? <TextView ? ? ? ? ? ? ? ? style="@style/tvtwo" ? ? ? ? ? ? ? ? android:text="name"/> ? ? ? ? ? ? <EditText ? ? ? ? ? ? ? ? android:id="@+id/et_name" ? ? ? ? ? ? ? ? style="@style/etOne"/> ? ? ? ? </LinearLayout> ? ? ? ? <View style="@style/hLine"/> ? ? ? ? <LinearLayout ? ? ? ? ? ? android:layout_width="match_parent" ? ? ? ? ? ? android:layout_height="wrap_content" ? ? ? ? ? ? android:orientation="horizontal" ? ? ? ? ? ? android:padding="15dp"> ? ? ? ? ? ? <TextView ? ? ? ? ? ? ? ? style="@style/tvtwo" ? ? ? ? ? ? ? ? android:text="email"/> ? ? ? ? ? ? <EditText ? ? ? ? ? ? ? ? android:id="@+id/et_mail" ? ? ? ? ? ? ? ? style="@style/etOne"/> ? ? ? ? </LinearLayout> ? ? ? ? <View style="@style/hLine"/> ? ? ? ? <LinearLayout ? ? ? ? ? ? android:layout_width="match_parent" ? ? ? ? ? ? android:layout_height="wrap_content" ? ? ? ? ? ? android:orientation="horizontal" ? ? ? ? ? ? android:padding="15dp"> ? ? ? ? ? ? <TextView ? ? ? ? ? ? ? ? style="@style/tvtwo" ? ? ? ? ? ? ? ? android:text="password"/> ? ? ? ? ? ? <EditText ? ? ? ? ? ? ? ? android:id="@+id/et_pwd" ? ? ? ? ? ? ? ? style="@style/etOne" ? ? ? ? ? ? ? ? android:inputType="textPassword"/> ? ? ? ? </LinearLayout> ? ? ? ? <View ?style="@style/hLine"/> ? ? ? ? <LinearLayout ? ? ? ? ? ? android:layout_width="match_parent" ? ? ? ? ? ? android:layout_height="wrap_content" ? ? ? ? ? ? android:orientation="horizontal" ? ? ? ? ? ? android:padding="15dp"> ? ? ? ? ? ? <TextView ? ? ? ? ? ? ? ? style="@style/tvtwo" ? ? ? ? ? ? ? ? android:text="glender"/> ? ? ? ? ? ? ? ? <RadioGroup ? ? ? ? ? ? ? ? ? ? android:id="@+id/rg_sex" ? ? ? ? ? ? ? ? ? ? android:layout_width="match_parent" ? ? ? ? ? ? ? ? ? ? android:layout_height="match_parent" ? ? ? ? ? ? ? ? ? ? android:layout_marginLeft="50dp" ? ? ? ? ? ? ? ? ? ? android:orientation="horizontal"> ? ? ? ? ? ? ? ? ? ? <RadioButton ? ? ? ? ? ? ? ? ? ? ? ? android:id="@+id/rb_boy" ? ? ? ? ? ? ? ? ? ? ? ? android:layout_width="wrap_content" ? ? ? ? ? ? ? ? ? ? ? ? android:layout_height="wrap_content" ? ? ? ? ? ? ? ? ? ? ? ? android:text="man" ? ? ? ? ? ? ? ? ? ? ? ? android:textColor="@android:color/white" ? ? ? ? ? ? ? ? ? ? ? ? android:textSize="15sp"/> ? ? ? ? ? ? ? ? <RadioButton ? ? ? ? ? ? ? ? ? ? android:id="@+id/rb_girl" ? ? ? ? ? ? ? ? ? ? style="@style/tvtwo" ? ? ? ? ? ? ? ? ? ? android:text="woman"/> ? ? ? ? ? ? ? ? </RadioGroup> ? ? ? ? </LinearLayout> ? ? ? ? <View style="@style/hLine"/> ? ? ? ? <LinearLayout ? ? ? ? ? ? android:layout_width="match_parent" ? ? ? ? ? ? android:layout_height="wrap_content" ? ? ? ? ? ? android:orientation="horizontal" ? ? ? ? ? ? android:padding="15dp"> ? ? ? ? ? ? <TextView ? ? ? ? ? ? ? ? android:layout_width="wrap_content" ? ? ? ? ? ? ? ? android:layout_height="wrap_content" ? ? ? ? ? ? ? ? android:text="chose your hobby" ? ? ? ? ? ? ? ? android:textColor="@android:color/white" ? ? ? ? ? ? ? ? android:textSize="15sp"/> ? ? ? ? ? ? <CheckBox ? ? ? ? ? ? ? ? android:id="@+id/cb_sing" ? ? ? ? ? ? ? ? android:layout_width="wrap_content" ? ? ? ? ? ? ? ? android:layout_height="wrap_content" ? ? ? ? ? ? ? ? android:text="sing" ? ? ? ? ? ? ? ? android:textColor="@android:color/white" ? ? ? ? ? ? ? ? android:textSize="15sp"/> ? ? ? ? ? ? <CheckBox ? ? ? ? ? ? ? ? android:id="@+id/cb_dance" ? ? ? ? ? ? ? ? android:layout_width="wrap_content" ? ? ? ? ? ? ? ? android:layout_height="wrap_content" ? ? ? ? ? ? ? ? android:text="dancing" ? ? ? ? ? ? ? ? android:textColor="@android:color/white" ? ? ? ? ? ? ? ? android:textSize="15sp"/> ? ? ? ? ? ? <CheckBox ? ? ? ? ? ? ? ? android:id="@+id/cb_read" ? ? ? ? ? ? ? ? android:layout_width="wrap_content" ? ? ? ? ? ? ? ? android:layout_height="wrap_content" ? ? ? ? ? ? ? ? android:text="read" ? ? ? ? ? ? ? ? android:textColor="@android:color/white" ? ? ? ? ? ? ? ? android:textSize="15sp"/> ? ? ? ? </LinearLayout> ? ? ? ? <View style="@style/hLine"/> ? ? <View ? ? ? ? android:id="@+id/v_line" ? ? ? ? android:layout_width="match_parent" ? ? ? ? android:layout_height="1dp" ? ? ? ? android:layout_above="@+id/btn_submit" ? ? ? ? android:background="@android:color/darker_gray"/> ? ? <Button ? ? ? ? android:id="@+id/btn_submit" ? ? ? ? android:layout_width="match_parent" ? ? ? ? android:layout_height="50dp" ? ? ? ? android:layout_alignParentBottom="true" ? ? ? ? android:gravity="center" ? ? ? ? android:text="uodate" ? ? ? ? android:textColor="@android:color/white" ? ? ? ? android:background="@null" ? ? ? ? android:textSize="18sp"/> ? ? </LinearLayout> </RelativeLayout>
在drawable下面創(chuàng)建存放圖片的文件

如何創(chuàng)建,首先復(fù)制圖片.右擊drawable,ctrl +v.

選擇第一個(gè)路徑就行.兩個(gè)路徑區(qū)別不加以贅述

下面命名就ok.
java代碼
package com.example.a19260234zjh;
import androidx.appcompat.app.AppCompatActivity;
import android.os.Bundle;
import android.text.TextUtils;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.CheckBox;
import android.widget.CompoundButton;
import android.widget.EditText;
import android.widget.RadioGroup;
import android.widget.Toast;
public class MainActivity extends AppCompatActivity implements
? ? ? ? View.OnClickListener, CompoundButton.OnCheckedChangeListener {
? ? private EditText et_name,et_email,et_pwd;
? ? private Button btn_submit;
? ? private String name,email,pwd,sex,hobbys;
? ? private RadioGroup rg_sex;
? ? private CheckBox cb_sing,cb_dance,cb_read;
? ? @Override
? ? protected void onCreate(Bundle savedInstanceState) {
? ? ? ? super.onCreate(savedInstanceState);
? ? ? ? setContentView(R.layout.activity_main);
? ? ? ? init();
? ? }
? ? private void init(){
? ? ? ? et_name=findViewById(R.id.et_name);
? ? ? ? et_email=findViewById(R.id.et_mail);
? ? ? ? et_pwd=findViewById(R.id.et_pwd);
? ? ? ? rg_sex=findViewById(R.id.rg_sex);
? ? ? ? cb_sing=findViewById(R.id.cb_sing);
? ? ? ? cb_read=findViewById(R.id.cb_read);
? ? ? ? cb_dance=findViewById(R.id.cb_dance);
? ? ? ? btn_submit=findViewById(R.id.btn_submit);
? ? ? ? btn_submit.setOnClickListener(this);
? ? ? ? cb_sing.setOnCheckedChangeListener(this);
? ? ? ? cb_dance.setOnCheckedChangeListener(this);
? ? ? ? cb_read.setOnCheckedChangeListener(this);
? ? ? ? hobbys=new String();
? ? ? ? rg_sex.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
? ? ? ? ? ? @Override
? ? ? ? ? ? public void onCheckedChanged(RadioGroup radioGroup, int checkedId) {
? ? ? ? ? ? ? ? switch (checkedId){
? ? ? ? ? ? ? ? ? ? case R.id.rb_boy:
? ? ? ? ? ? ? ? ? ? ? ? sex="man";
? ? ? ? ? ? ? ? ? ? case R.id.rb_girl:
? ? ? ? ? ? ? ? ? ? ? ? sex="woman";
? ? ? ? ? ? ? ? ? ? ? ? break;
? ? ? ? ? ? ? ? }
? ? ? ? ? ? }
? ? ? ? });
? ? }
? ? private void getData(){
? ? ? ? name=et_name.getText().toString().trim();
? ? ? ? email=et_email.getText().toString().trim();
? ? ? ? pwd=et_pwd.getText().toString().trim();
? ? }
? ? @Override
? ? public void onClick(View v){
? ? ? ? switch (v.getId()){
? ? ? ? ? ? case R.id.btn_submit:
? ? ? ? ? ? ? ? getData();
? ? ? ? ? ? ? ? if(TextUtils.isEmpty(name)){
? ? ? ? ? ? ? ? ? ? Toast.makeText(MainActivity.this,"input name",
? ? ? ? ? ? ? ? ? ? ? ? ? ? Toast.LENGTH_SHORT).show();
? ? ? ? ? ? ? ? }
? ? ? ? ? ? ? ? else if(TextUtils.isEmpty(email)){
? ? ? ? ? ? ? ? ? ? Toast.makeText(MainActivity.this,"input email",
? ? ? ? ? ? ? ? ? ? ? ? ? ? Toast.LENGTH_SHORT).show();
? ? ? ? ? ? ? ? }
? ? ? ? ? ? ? ? else if(TextUtils.isEmpty(pwd)){
? ? ? ? ? ? ? ? ? ? Toast.makeText(MainActivity.this,"input password",
? ? ? ? ? ? ? ? ? ? ? ? ? ? Toast.LENGTH_SHORT).show();
? ? ? ? ? ? ? ? }
? ? ? ? ? ? ? ? ?else if(TextUtils.isEmpty(sex)){
? ? ? ? ? ? ? ? ? ? Toast.makeText(MainActivity.this,"input glendar",
? ? ? ? ? ? ? ? ? ? ? ? ? ? Toast.LENGTH_SHORT).show();
? ? ? ? ? ? ? ? }
? ? ? ? ? ? ? ? ?else if(TextUtils.isEmpty(hobbys)){
? ? ? ? ? ? ? ? ? ? Toast.makeText(MainActivity.this,"input hobbys",
? ? ? ? ? ? ? ? ? ? ? ? ? ? Toast.LENGTH_SHORT).show();
? ? ? ? ? ? ? ? } else{
? ? ? ? ? ? ? ? ? ? ?Toast.makeText(MainActivity.this,"success",
? ? ? ? ? ? ? ? ? ? ? ? ? ? ?Toast.LENGTH_SHORT).show();
? ? ? ? ? ? ? ? ? ? Log.i("MainActivity","information"+"name:"+name+",email:"+email+
? ? ? ? ? ? ? ? ? ? ? ? ? ? ",sex"+sex+",hobby"+hobbys);
? ? ? ? ? ? ? ? }
? ? ? ? ? ? ? ? ?break;
? ? ? ? }
? ? }
? ? @Override
? ? public void onCheckedChanged(CompoundButton buttonViwe,boolean isChecked){
? ? ? ? String motion=buttonViwe.getText().toString();
? ? ? ? if(isChecked){
? ? ? ? ? ? if(!hobbys.contains(motion)){
? ? ? ? ? ? ? ? hobbys=hobbys+motion;
? ? ? ? ? ? }
? ? ? ? }else {
? ? ? ? ? ? if(hobbys.contains(motion)){
? ? ? ? ? ? ? ? hobbys=hobbys.replace(motion,"");
? ? ? ? ? ? }
? ? ? ? }
? ? }
}以上就是實(shí)現(xiàn)注冊頁面所需要的代碼.
效果如下:

每個(gè)人的圖片不一樣,效果也不一樣.建議圖片盡量小一些。
以上就是本文的全部內(nèi)容,希望對大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。
相關(guān)文章
android 更改TextView中任意位置字體大小和顏色的方法
下面小編就為大家分享一篇android 更改TextView中任意位置字體大小和顏色的方法,具有很好的參考價(jià)值,希望對大家有所幫助。一起跟隨小編過來看看吧2018-01-01
Android利用Fragment實(shí)現(xiàn)Tab選項(xiàng)卡效果
這篇文章主要為大家詳細(xì)介紹了Android利用Fragment實(shí)現(xiàn)Tab選項(xiàng)卡效果,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2016-08-08
Android實(shí)現(xiàn)讀取相機(jī)(相冊)圖片并進(jìn)行剪裁
在 Android應(yīng)用中,很多時(shí)候我們需要實(shí)現(xiàn)上傳圖片,或者直接調(diào)用手機(jī)上的拍照功能拍照處理然后直接顯示并上傳功能,下面將講述調(diào)用相機(jī)拍照處理圖片然后顯示和調(diào)用手機(jī)相冊中的圖片處理然后顯示的功能2015-08-08
Android中使用Kotlin實(shí)現(xiàn)一個(gè)簡單的登錄界面
Kotlin 是一種在 Java 虛擬機(jī)上運(yùn)行的靜態(tài)類型編程語言,被稱之為 Android 世界的Swift,由 JetBrains 設(shè)計(jì)開發(fā)并開源。接下來本文通過實(shí)例代碼給大家講解Android中使用Kotlin實(shí)現(xiàn)一個(gè)簡單的登錄界面,一起看看吧2017-09-09
Android ActionBar完全解析使用官方推薦的最佳導(dǎo)航欄(上)
Action Bar是一種新増的導(dǎo)航欄功能,在Android 3.0之后加入到系統(tǒng)的API當(dāng)中,它標(biāo)識了用戶當(dāng)前操作界面的位置,并提供了額外的用戶動(dòng)作、界面導(dǎo)航等功能2017-04-04
kotlin 官方學(xué)習(xí)教程之基礎(chǔ)語法詳解
這篇文章主要介紹了kotlin 官方學(xué)習(xí)教程之基礎(chǔ)語法詳解的相關(guān)資料,需要的朋友可以參考下2017-05-05
關(guān)于Kotlin的自動(dòng)類型轉(zhuǎn)換詳解
這篇文章主要給大家介紹了關(guān)于Kotlin的自動(dòng)類型轉(zhuǎn)換的相關(guān)資料,文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧2020-09-09
關(guān)于Android CountDownTimer的使用及注意事項(xiàng)
這篇文章主要介紹了關(guān)于Android CountDownTimer的使用及注意事項(xiàng),具有很好的參考價(jià)值,希望對大家有所幫助,如有錯(cuò)誤或未考慮完全的地方,望不吝賜教2023-11-11
Android開發(fā)之自定義星星評分控件RatingBar用法示例
這篇文章主要介紹了Android開發(fā)之自定義星星評分控件RatingBar用法,結(jié)合具體實(shí)例形式分析了Android自定義評分控件的具體實(shí)現(xiàn)步驟以及功能、布局相關(guān)操作技巧,需要的朋友可以參考下2019-03-03

