導航:首頁 > 操作系統 > android注冊界面代碼

android注冊界面代碼

發布時間:2024-06-23 02:55:56

1. android studio相對布局怎麼設計一個登陸界面

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#55ffff">

<TextView
android:id="@+id/tv_password"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="20dp"
android:layout_marginRight="20dp"
android:padding="10dp"
android:background="#ffffff"
android:hint="密碼"
android:textSize="15sp"
android:textColor="#000000"
android:layout_centerInParent="true"/>


<TextView
android:id="@+id/tv_user"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="20dp"
android:layout_marginRight="20dp"
android:background="#ffffff"
android:padding="10dp"
android:hint="用戶名"
android:textSize="15sp"
android:layout_marginBottom="15dp"
android:textColor="#000000"
android:layout_above="@+id/tv_password"/>

<TextView
android:id="@+id/tv_forget_password"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/tv_password"
android:layout_alignLeft="@+id/tv_password"
android:paddingTop="10dp"
android:text="忘記密碼>"
android:textSize="14sp"
android:textColor="#ff0000" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/tv_password"
android:layout_alignRight="@+id/tv_password"
android:paddingTop="10dp"
android:text="注冊>"
android:textSize="14sp"
android:textColor="#ff0000" />

<Button
android:id="@+id/but_login"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="50dp"
android:layout_marginRight="50dp"
android:layout_marginTop="20dp"
android:background="#4169E1"
android:text="登錄"
android:textSize="18sp"
android:textColor="#ffffff"
android:layout_below="@+id/tv_forget_password"/>

<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@mipmap/ic_launcher"
android:layout_centerHorizontal="true"
android:layout_marginBottom="30dp"
android:layout_above="@+id/tv_user"/>
</RelativeLayout>

2. 如何設計android的登錄界面

在網上在到一個登錄界面感覺挺不錯的,給大家分享一下~先看效果圖:

這個Demo除了按鈕、小貓和Logo是圖片素材之外,其餘的UI都是通過代碼實現的。

?

一、背景

背景藍色漸變,是通過一個xml文件來設置的。代碼如下:

background_login.xml

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:andro>
<gradient
android:startColor="#FFACDAE5"
android:endColor="#FF72CAE1"
android:angle="45"
/>
</shape>


startColor是漸變開始的顏色值,endColor是漸變結束的顏色值,angle是漸變的角度。其中#FFACDAE5中,FF是Alpha值,AC是RGB的R值,DA是RGB的G值,E5是RGB的B值,每個值在00~FF取值,即透明度、紅、綠、藍有0~255的分值,像要設置具體的顏色,可以在PS上的取色器上查看設置。

?

?

二、圓角白框

效果圖上面的並不是白框,其實框是白色的,只是設置了透明值,也是靠一個xml文件實現的。

background_login_div.xml

<?xml version="1.0" encoding="UTF-8"?>
<shape xmlns:andro>
<solid android:color="#55FFFFFF" />
<!-- 設置圓角
注意: bottomRightRadius是左下角而不是右下角 bottomLeftRadius右下角-->
<corners android:topLeftRadius="10dp" android:topRightRadius="10dp"
android:bottomRightRadius="10dp" android:bottomLeftRadius="10dp"/>
</shape>

?

三、界面的布局

界面的布局挺簡單的,就直接貼代碼啦~

login.xml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:andro
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@drawable/background_login">
<!-- padding 內邊距 layout_margin 外邊距
android:layout_alignParentTop 布局的位置是否處於頂部 -->

<RelativeLayout
android:
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:padding="15dip"
android:layout_margin="15dip"
android:background="@drawable/background_login_div_bg" >
<!-- 賬號 -->
<TextView
android:
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_marginTop="5dp"
android:text="@string/login_label_username"
/>
<EditText
android:
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:
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"
/>
<EditText
android:
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:
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:
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:
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>

3. 創建一個android界面,每行一個組件,依次放置一個EditText組件,一個TextVie

您可以使用Android Studio中的XML布局文件來創建界面。以下是一個示例代碼:

該代碼創建了一個包含兩行的線性布局,每行包含一個線性布局和一個組件。第一行包含一個EditText組件,第二行包含一個TextView組件。

4. android怎麼做動態的登陸界面

設計android的登錄界面的方法:

UI實現的代碼如下:

1、背景設置圖片:

background_login.xml

<?xmlversion="1.0"encoding="utf-8"?>

<shapexmlns:android="http://schemas.android.com/apk/res/android">

<gradient

android:startColor="#FFACDAE5"

android:endColor="#FF72CAE1"

android:angle="45"

/>

</shape>

2、圓角白框

效果圖上面的並不是白框,其實框是白色的,只是設置了透明值,也是靠一個xml文件實現的。

background_login_div.xml

<?xmlversion="1.0"encoding="UTF-8"?>

<shapexmlns:android="http://schemas.android.com/apk/res/android">

<solidandroid:color="#55FFFFFF"/>

<!--設置圓角

注意:bottomRightRadius是左下角而不是右下角bottomLeftRadius右下角-->

<cornersandroid:topLeftRadius="10dp"android:topRightRadius="10dp"

android:bottomRightRadius="10dp"android:bottomLeftRadius="10dp"/>

</shape>


3、界面布局:

login.xml

<?xmlversion="1.0"encoding="utf-8"?>

<LinearLayout

xmlns:android="http://schemas.android.com/apk/res/android"

android:orientation="vertical"

android:layout_width="fill_parent"

android:layout_height="fill_parent"

android:background="@drawable/background_login">

<!--padding內邊距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">

<!--賬號-->

<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">

<TextViewandroid: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"/>

<ImageViewandroid: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"/>

<ImageViewandroid: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源文件比較簡單,只是實例化Activity,去掉標題欄。

packagecom.mytwitter.acitivity;

importandroid.app.Activity;

importandroid.os.Bundle;

importandroid.view.Window;

{

@Override

publicvoidonCreate(BundlesavedInstanceState){

super.onCreate(savedInstanceState);

requestWindowFeature(Window.FEATURE_NO_TITLE);

setContentView(R.layout.login);

}

}

5、實現效果如下:

5. android項目怎麼注冊activity

1、打開AndroidManifest.xml文件
2、在application節點間插入
<activity android:name="com.example.testand.MainActivity"/>
com.example.testand.MainActivity是activity在工程中的路徑。這是最簡單的一個注冊

其他activity中可選用屬性有:
<activity android:allowTaskReparenting=["true" | "false"]
android:alwaysRetainTaskState=["true" | "false"]
android:clearTaskOnLaunch=["true" | "false"]
android:configChanges=["mcc", "mnc", "locale",
"touchscreen", "keyboard", "keyboardHidden",
"navigation", "orientation", "screenLayout",
"fontScale", "uiMode"]
android:enabled=["true" | "false"]
android:excludeFromRecents=["true" | "false"]
android:exported=["true" | "false"]
android:finishOnTaskLaunch=["true" | "false"]
android:icon="drawable resource"
android:label="string resource"
android:launchMode=["multiple" | "singleTop" |
"singleTask" | "singleInstance"]
android:multiprocess=["true" | "false"]
android:name="string"
android:noHistory=["true" | "false"]
android:permission="string"
android:process="string"
android:screenOrientation=["unspecified" | "user" | "behind" |
"landscape" | "portrait" |
"sensor" | "nosensor"]
android:stateNotNeeded=["true" | "false"]
android:taskAffinity="string"
android:theme="resource or theme"
android:windowSoftInputMode=["stateUnspecified",
"stateUnchanged", "stateHidden",
"stateAlwaysHidden", "stateVisible",
"stateAlwaysVisible", "adjustUnspecified",
"adjustResize", "adjustPan"] >
</activity>
(註:有些在application中重復的就不多闡述了)
1、android:alwaysRetainTaskState
是否保留狀態不變, 比如切換回home, 再從新打開,activity處於最後的狀態。比如一個瀏覽器擁有很多狀態(當打開了多個TAB的時候),用戶並不希望丟失這些狀態時,此時可將此屬性設置為true
2、android:clearTaskOnLaunch
比如 P 是 activity, Q 是被P 觸發的 activity, 然後返回Home, 重新啟動 P,是否顯示 Q
3、android:configChanges
當配置list發生修改時, 是否調用 onConfigurationChanged() 方法 比如 "locale|navigation|orientation".
這個我用過,主要用來看手機方向改變的. android手機在旋轉後,layout會重新布局, 如何做到呢?
正常情況下. 如果手機旋轉了.當前Activity後殺掉,然後根據方向重新載入這個Activity. 就會從onCreate開始重新載入.
如果你設置了 這個選項, 當手機旋轉後,當前Activity之後調用onConfigurationChanged() 方法. 而不跑onCreate方法等.
4、android:excludeFromRecents
是否可被顯示在最近打開的activity列表裡,默認是false
5、android:finishOnTaskLaunch
當用戶重新啟動這個任務的時候,是否關閉已打開的activity,默認是false
如果這個屬性和allowTaskReparenting都是true,這個屬性就是王牌。Activity的親和力將被忽略。該Activity已經被摧毀並非re-parented

6、android:launchMode(Activity載入模式)
在多Activity開發中,有可能是自己應用之間的Activity跳轉,或者夾帶其他應用的可復用Activity。可能會希望跳轉到原來某個Activity實例,而不是產生大量重復的Activity。這需要為Activity配置特定的載入模式,而不是使用默認的載入模式
Activity有四種載入模式:
standard、singleTop、singleTask、singleInstance(其中前兩個是一組、後兩個是一組),默認為standard

standard:就是intent將發送給新的實例,所以每次跳轉都會生成新的activity。
singleTop:也是發送新的實例,但不同standard的一點是,在請求的Activity正好位於棧頂時(配置成singleTop的Activity),不會構造新的實例
singleTask:和後面的singleInstance都只創建一個實例,當intent到來,需要創建設置為singleTask的Activity的時候,系統會檢查棧裡面是否已經有該Activity的實例。如果有直接將intent發送給它。
singleInstance:
首先說明一下task這個概念,Task可以認為是一個棧,可放入多個Activity。比如啟動一個應用,那麼Android就創建了一個Task,然後啟動這個應用的入口Activity,那在它的界面上調用其他的Activity也只是在這個task裡面。那如果在多個task中共享一個Activity的話怎麼辦呢。舉個例來說,如果開啟一個導游服務類的應用程序,裡面有個Activity是開啟GOOGLE地圖的,當按下home鍵退回到主菜單又啟動GOOGLE地圖的應用時,顯示的就是剛才的地圖,實際上是同一個Activity,實際上這就引入了singleInstance。singleInstance模式就是將該Activity單獨放入一個棧中,這樣這個棧中只有這一個Activity,不同應用的intent都由這個Activity接收和展示,這樣就做到了共享。當然前提是這些應用都沒有被銷毀,所以剛才是按下的HOME鍵,如果按下了返回鍵,則無效
7、android:multiprocess
是否允許多進程,默認是false
具體可看該篇文章:http://www.bangchui.org/simple/?t3181.html
8、android:noHistory
當用戶從Activity上離開並且它在屏幕上不再可見時,Activity是否從Activity stack中清除並結束。默認是false。Activity不會留下歷史痕跡
9、android:screenOrientation
activity顯示的模式
默認為unspecified:由系統自動判斷顯示方向
landscape橫屏模式,寬度比高度大
portrait豎屏模式, 高度比寬度大
user模式,用戶當前首選的方向
behind模式:和該Activity下面的那個Activity的方向一致(在Activity堆棧中的)
sensor模式:有物理的感應器來決定。如果用戶旋轉設備這屏幕會橫豎屏切換
nosensor模式:忽略物理感應器,這樣就不會隨著用戶旋轉設備而更改了
10、android:stateNotNeeded
activity被銷毀或者成功重啟時是否保存狀態
11、android:windowSoftInputMode
activity主窗口與軟鍵盤的交互模式,可以用來避免輸入法面板遮擋問題,Android1.5後的一個新特性。
這個屬性能影響兩件事情:
【A】當有焦點產生時,軟鍵盤是隱藏還是顯示
【B】是否減少活動主窗口大小以便騰出空間放軟鍵盤
各值的含義:
【A】stateUnspecified:軟鍵盤的狀態並沒有指定,系統將選擇一個合適的狀態或依賴於主題的設置
【B】stateUnchanged:當這個activity出現時,軟鍵盤將一直保持在上一個activity里的狀態,無論是隱藏還是顯示
【C】stateHidden:用戶選擇activity時,軟鍵盤總是被隱藏
【D】stateAlwaysHidden:當該Activity主窗口獲取焦點時,軟鍵盤也總是被隱藏的
【E】stateVisible:軟鍵盤通常是可見的
【F】stateAlwaysVisible:用戶選擇activity時,軟鍵盤總是顯示的狀態
【G】adjustUnspecified:默認設置,通常由系統自行決定是隱藏還是顯示
【H】adjustResize:該Activity總是調整屏幕的大小以便留出軟鍵盤的空間
【I】adjustPan:當前窗口的內容將自動移動以便當前焦點從不被鍵盤覆蓋和用戶能總是看到輸入內容的部分

閱讀全文

與android注冊界面代碼相關的資料

熱點內容
3j指標源碼怎麼用 瀏覽:862
出發命令 瀏覽:180
比較低碳鋼和鑄鐵在壓縮 瀏覽:319
天眼精準打擊指標源碼 瀏覽:938
pythondataframe 瀏覽:451
單片機的繼電器原理圖怎麼畫 瀏覽:895
自學程序員好考嗎 瀏覽:978
還款解壓再質押 瀏覽:970
doc2pdf 瀏覽:392
Android提示為空 瀏覽:623
sql預編譯和執行的語法 瀏覽:111
復盛壓縮機選型軟體 瀏覽:746
android培訓大綱 瀏覽:60
docker鏡像內編譯 瀏覽:861
繳納社保app哪個好 瀏覽:416
哪個app跑步有錢 瀏覽:58
貨幣理論pdf 瀏覽:428
python35鍵盤輸入 瀏覽:289
安卓手機頭部自定義怎麼取消 瀏覽:26
python套利交易 瀏覽:790