酷知百科網

位置:首頁 > 遊戲數碼 > 互聯網

如何使用Android Studio開發用戶登入介面

互聯網1.08W

目前如火如荼的android應用開發遍地開花,爲了更好的適應移動互聯網的發展,掌握移動開發成爲程序員必須掌握的一門技能。本文透過一個簡單案例講述如果透過Android Studio開發一個用戶登入介面。

操作方法

(01)我們項目的前提是你已經將基本的執行環境及sdk都已經安裝好了,讀者可自行搜狗搜尋環境配置相關內容,本文不再贅述。右鍵點擊new-->Module,Module相當於新建了一個項目。如圖所示

如何使用Android Studio開發用戶登入介面

(02)選擇Android Application,點擊next

如何使用Android Studio開發用戶登入介面 第2張

(03)將My Module 和app改成自己項目相應的名字,同時選擇支援的Android版本

如何使用Android Studio開發用戶登入介面 第3張

(04)這一步我們選擇Blank Activity,自己手動編寫登入介面,而不依賴系統內置的Login Activity,一直點擊next,最後點擊finish就完成了項目的創建

如何使用Android Studio開發用戶登入介面 第4張

(05)在project下我們可以看到出現了我們剛纔創建的login項目

如何使用Android Studio開發用戶登入介面 第5張

(06)展開res/layout,點擊開啟activity_檔案,在這個檔案裏我們將完成登入介面的編寫

(07)這是初始的主介面,還沒有經過我們編寫的介面,Android Studio有一個很強大的預覽功能,相當給力

如何使用Android Studio開發用戶登入介面 第6張

(08)我們將activity_的代碼替換成如下代碼:<TableLayout xmlns:android=""android:layout_width="fill_parent"android:layout_height="fill_parent"android:gravity="center_vertical"android:stretchColumns="0,3"><TableRow><TextView /><TextViewandroid:text="賬   號:"android:layout_width="wrap_content"android:layout_height="wrap_content"android:textSize="24px"/><EditTextandroid:id="@+id/account"android:layout_width="wrap_content"android:layout_height="wrap_content"android:textSize="24px"android:minWidth="220px"/><TextView /></TableRow><TableRow android:layout_marginTop="20px"><TextView /><TextViewandroid:text="密  碼:"android:layout_width="wrap_content"android:layout_height="wrap_content"/><EditTextandroid:id="@+id/pwd"android:layout_width="wrap_content"android:layout_height="wrap_content"android:minWidth="220px"android:textSize="24px"android:inputType="textPassword"/><TextView /></TableRow><TableRow android:layout_marginTop="20px"><TextView /><Buttonandroid:id="@+id/login"android:text="登入"android:layout_width="wrap_content"android:layout_height="wrap_content"/><Buttonandroid:id="@+id/quit"android:text="退出"android:layout_width="wrap_content"android:layout_height="wrap_content"/><TextView /></TableRow></TableLayout>

(09)預覽效果如圖

如何使用Android Studio開發用戶登入介面 第7張

(10)使用Android 手機進行測試,大功告成

如何使用Android Studio開發用戶登入介面 第8張

特別提示

一定要先配置好java執行環境及android執行環境

跟着步驟操作