我們項(xiàng)目的前提是你已經(jīng)將基本的運(yùn)行環(huán)境及sdk都已經(jīng)安裝好了,讀者可自行百度環(huán)境配置相關(guān)內(nèi)容,本文不再贅述。右鍵點(diǎn)擊new--Module,Module相當(dāng)于新建了一個(gè)項(xiàng)目。

成都創(chuàng)新互聯(lián)是一家專(zhuān)業(yè)提供龍川企業(yè)網(wǎng)站建設(shè),專(zhuān)注與成都網(wǎng)站設(shè)計(jì)、成都網(wǎng)站建設(shè)、html5、小程序制作等業(yè)務(wù)。10年已為龍川眾多企業(yè)、政府機(jī)構(gòu)等服務(wù)。創(chuàng)新互聯(lián)專(zhuān)業(yè)網(wǎng)站設(shè)計(jì)公司優(yōu)惠進(jìn)行中。
選擇Android Application,點(diǎn)擊next
將My Module 和app改成自己項(xiàng)目相應(yīng)的名字,同時(shí)選擇支持的Android版本
這一步我們選擇Blank Activity,自己手動(dòng)編寫(xiě)登錄界面,而不依賴系統(tǒng)內(nèi)置的Login Activity,一直點(diǎn)擊next,最后點(diǎn)擊finish就完成了項(xiàng)目的創(chuàng)建
在project下我們可以看到出現(xiàn)了我們剛才創(chuàng)建的login項(xiàng)目
展開(kāi)res/layout,點(diǎn)擊打開(kāi)activity_main.xml文件,在這個(gè)文件里我們將完成登錄界面的編寫(xiě)
這是初始的主界面,還沒(méi)有經(jīng)過(guò)我們編寫(xiě)的界面,Android Studio有一個(gè)很強(qiáng)大的預(yù)覽功能,相當(dāng)給力,將activity_main.xml的代碼替換成如下代碼:
TableLayout xmlns:android=""
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:gravity="center_vertical"
android:stretchColumns="0,3"
TableRow
TextView /
TextView
android:text="賬 號(hào):"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="24px"
/
EditText
首先程序進(jìn)入SplashActivity,就是啟動(dòng)頁(yè)面。
xml布局文件就是一個(gè)全屏的圖片,要注意的是設(shè)置android:scaleType ="matrix"這個(gè)屬性。不然不會(huì)全屏。
過(guò)1秒之后轉(zhuǎn)入登陸頁(yè)面,從圖片我們可以看出,騰訊的UI做的還是相當(dāng)美觀漂亮的,既簡(jiǎn)潔又不失美觀。先分析一下這個(gè)登錄界面,從整體可以看出,根布局的
背景色是藍(lán)色的,而那個(gè)QQ Android其實(shí)是一個(gè)圖片背景色和根布局的背景色一樣,這樣就不會(huì)有視覺(jué)偏差。
設(shè)計(jì)android的登錄界面的方法:
UI實(shí)現(xiàn)的代碼如下:
1、背景設(shè)置圖片:
background_login.xml
?xml?version="1.0"?encoding="utf-8"?
shape?xmlns:android=""??
gradient
android:startColor="#FFACDAE5"
android:endColor="#FF72CAE1"
android:angle="45"
/
/shape
2、圓角白框
效果圖上面的并不是白框,其實(shí)框是白色的,只是設(shè)置了透明值,也是靠一個(gè)xml文件實(shí)現(xiàn)的。
background_login_div.xml
?xml?version="1.0"?encoding="UTF-8"?
shape?xmlns:android=""??
solid?android:color="#55FFFFFF"?/
!--?設(shè)置圓角
注意:?bottomRightRadius是左下角而不是右下角??bottomLeftRadius右下角--
corners?android:topLeftRadius="10dp"?android:topRightRadius="10dp"
android:bottomRightRadius="10dp"?android:bottomLeftRadius="10dp"/
/shape
3、界面布局:
login.xml
?xml?version="1.0"?encoding="utf-8"?
LinearLayout
xmlns:android=""??
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@drawable/background_login"
!--?padding?內(nèi)邊距???layout_margin?外邊距
android:layout_alignParentTop?布局的位置是否處于頂部?--
RelativeLayout
android:id="@+id/login_div"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:padding="15dip"
android:layout_margin="15dip"
android:background="@drawable/background_login_div_bg"?
!--?賬號(hào)?--
TextView
android:id="@+id/login_user_input"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_marginTop="5dp"
android:text="@string/login_label_username"
style="@style/normalText"/
EditText
android:id="@+id/username_edit"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:hint="@string/login_username_hint"
android:layout_below="@id/login_user_input"
android:singleLine="true"
android:inputType="text"/
!--?密碼?text?--
TextView
android:id="@+id/login_password_input"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/username_edit"
android:layout_marginTop="3dp"
android:text="@string/login_label_password"
style="@style/normalText"/
EditText
android:id="@+id/password_edit"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="@id/login_password_input"
android:password="true"
android:singleLine="true"
android:inputType="textPassword"?/
!--?登錄button?--
Button
android:id="@+id/signin_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/password_edit"
android:layout_alignRight="@id/password_edit"
android:text="@string/login_label_signin"
android:background="@drawable/blue_button"?/
/RelativeLayout
RelativeLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"?
TextView??android:id="@+id/register_link"
android:text="@string/login_register_link"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="15dp"
android:textColor="#888"
android:textColorLink="#FF0066CC"?/
ImageView?android:id="@+id/miniTwitter_logo"
android:src="@drawable/cat"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_alignParentBottom="true"
android:layout_marginRight="25dp"
android:layout_marginLeft="10dp"
android:layout_marginBottom="25dp"?/
ImageView?android:src="@drawable/logo"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toLeftOf="@id/miniTwitter_logo"
android:layout_alignBottom="@id/miniTwitter_logo"
android:paddingBottom="8dp"/
/RelativeLayout
/LinearLayout
4、java源代碼,Java源文件比較簡(jiǎn)單,只是實(shí)例化Activity,去掉標(biāo)題欄。
package?com.mytwitter.acitivity;
import?android.app.Activity;
import?android.os.Bundle;
import?android.view.Window;
public?class?LoginActivity?extends?Activity?{
@Override
public?void?onCreate(Bundle?savedInstanceState)?{
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE);
setContentView(R.layout.login);
}
}
5、實(shí)現(xiàn)效果如下:
android studio做酷狗登錄界面如下
使用Android Studio 編寫(xiě)的第一個(gè)demo,使用布局文件—xml實(shí)現(xiàn)用戶登錄界面
注:所建工程均為Android 6.0 所以只要是Android 6.0(包括6.0)以上的真機(jī),模擬機(jī)都可以使用
Step1:Android Studio 開(kāi)發(fā)環(huán)境的搭建:
1.安裝JDK (1.8);
2.安裝Android studio (3.3.1) 包含 gradle、sdk manage 、avd manage ;
3.使用sdk manage 下載安裝 sdk;
4.使用avd manages 創(chuàng)建虛擬機(jī)。
分享文章:android登錄界面設(shè)計(jì),Android登錄界面設(shè)計(jì)代碼
文章源于:http://chinadenli.net/article3/dsecgis.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供網(wǎng)站策劃、微信公眾號(hào)、搜索引擎優(yōu)化、外貿(mào)網(wǎng)站建設(shè)、App設(shè)計(jì)、服務(wù)器托管
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來(lái)源: 創(chuàng)新互聯(lián)