日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

java 仿qq登录界面7.1_安卓开发学习笔记(七):仿写腾讯QQ登录注册界面

發布時間:2024/7/19 编程问答 34 豆豆
生活随笔 收集整理的這篇文章主要介紹了 java 仿qq登录界面7.1_安卓开发学习笔记(七):仿写腾讯QQ登录注册界面 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

這段代碼的關鍵主要是在我們的相對布局以及線性布局上面,我們首先在總體布局里設置為線性布局,然后再在里面設置為相對布局,這是一個十分常見的XML布局模式。

廢話不多說,直接上代碼:

一.activity.xml

>

android:layout_width="match_parent"android:layout_height="160dp"android:padding="16dp"android:layout_margin="0dp"

>

android:layout_width="match_parent"android:layout_height="wrap_content"android:padding="16dp"android:layout_margin="0dp"

>

android:id="@+id/account"android:layout_width="match_parent"android:layout_height="wrap_content"android:layout_marginBottom="16dp"android:hint="QQ號/密碼/郵箱"/>

/>

android:layout_below="@id/account"android:id="@+id/password"android:layout_width="match_parent"android:layout_height="wrap_content"android:password="true"android:hint="密碼"/>

/>

android:layout_width="match_parent"android:layout_height="33dp"android:padding="0dp"android:layout_margin="0dp"

>

android:id="@+id/remember_pass"android:layout_width="wrap_content"android:layout_height="wrap_content"android:text="記住密碼"/>

android:layout_width="match_parent"android:layout_height="wrap_content"android:layout_margin="16dp">

android:id="@+id/login"android:layout_width="match_parent"android:layout_height="wrap_content"android:text="登錄"android:textColor="#fff"android:background="#008cc9"/>

android:id="@+id/forget_pwd"android:layout_below="@id/login"android:layout_width="wrap_content"android:layout_height="wrap_content"android:background="@null"android:textColor="#2999ce"android:gravity="start"android:layout_marginTop="16dp"android:textSize="16dp"android:text="忘記密碼?"/>

android:id="@+id/register"android:layout_below="@id/login"android:layout_width="wrap_content"android:layout_height="wrap_content"android:background="@null"android:textColor="#2999ce"android:gravity="end"android:text="新用戶注冊"android:layout_marginTop="16dp"android:textSize="16dp"android:layout_alignParentRight="true"/>

android:layout_width="match_parent"android:layout_height="80dp"android:padding="16dp"android:layout_margin="0dp">

android:layout_width="wrap_content"android:layout_height="wrap_content" />

二.main.java

package com.example.lenovo.fqq;

import android.content.Intent;

import android.support.v7.app.ActionBar;

import android.support.v7.app.AppCompatActivity;

import android.os.Bundle;

import android.view.View;

import android.widget.Button;public classMain3Activity extends AppCompatActivity {

@Overrideprotected voidonCreate(Bundle savedInstanceState) {

super.onCreate(savedInstanceState);

setContentView(R.layout.activity_main3);

Button button=(Button) findViewById(R.id.login);

button.setOnClickListener(newView.OnClickListener() {

@Overridepublic voidonClick(View v) {

Intent intent=new Intent(Main3Activity.this,Main2Activity.class);

startActivity(intent);

}

});

ActionBar a=getSupportActionBar();if(a!=null)

{

a.hide();

}

}

}

其中的代碼:

ActionBar a=getSupportActionBar();

if(a!=null)

{

a.hide();

}

}

}

主要是為了能夠將我們的標題欄隱藏,不然的話就會顯示出標題欄,達不到我們仿寫的效果了。

Button button=(Button) findViewById(R.id.login);

button.setOnClickListener(new View.OnClickListener() {

@Override

public void onClick(View v) {

Intent intent=new Intent(Main3Activity.this,Main2Activity.class);

startActivity(intent);

}

});

上面這一段代碼主要是用到了活動的跳轉,不然登錄是登錄不進去的!這里因為我們直接使用了java當中活動的跳轉。點擊登錄就會立刻跳轉到下一個界面進行登錄,當然

TextView簡介:

TextView,是View的直接子類。它是一個文本顯示控件,提供了基本的顯示文本的功能,并且是大部分UI控件的父類,因為大部分UI控件都需要展示信息。

如果僅僅是展示文本,那么TextView的作用就太小了,所以它還預定義了一些類似于HTML的標簽,通過這些標簽可以使TextView控件顯示不同的顏色、大小、字體、圖片、鏈接。這些HTML標簽都需要android.text.Html類的支持,但是并不包括所有的HTML標簽。

常用的可以再TextView中設定的標簽有:

:設置顏色和字體。

:設置字體大號

:設置字體小號

\:斜體\粗體

:連接網址

:圖片

使用這些標簽可以用Html.fromHtml方法將這些標簽的字符串轉換成CharSequence接口,然后在TextView.setText()中進行設置。如果需要響應設置的HTML標簽進行響應,需要設置TextView.setMovementMethod(LinkMovementMethod.getInstance())。

CharSequence為接口類型,大家可能對其有點陌生,但是它的子類肯定會讓大家有熟悉的感覺,String、StringBuffer、StringBuilder、SpannableString、SpannableStringBuilder都是其子類,它包括了字符串的所有類,因為面向對象的多態性,在這里把他理解成字符串類的抽象即可。

除了使用HTML標簽的方式設定顯示文本中的URL地址、郵箱地址、電話等產生超鏈接出發相應的服務,可以使用android:autoLink屬性來設置,以下是android:autoLink屬性的介紹:

None:默認的,不匹配任何連接。

web:網址。

email:郵箱。

phone:電話號碼。

map:匹配映射網址。

all:匹配所有連接。

最終搞定,實現具體效果如下:

總結

以上是生活随笔為你收集整理的java 仿qq登录界面7.1_安卓开发学习笔记(七):仿写腾讯QQ登录注册界面的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。