當前位置:成語大全網 - 漢語詞典 - android如何做動態登錄界面?

android如何做動態登錄界面?

android登錄界面的設計方法:

UI實現代碼如下:

1,背景設置圖片:

background_login.xml

& lt?xml?version="1.0 "?編碼="utf-8 "?& gt

& lt外形?xmlns:Android = "/apk/RES/Android " & gt;

& lt漸變?

android:startColor="#FFACDAE5 "

Android:end color = " # ff 72 CAE 1 "

android:angle="45 "

/& gt;

& lt/shape & gt;

2、圓形白盒

效果圖頂部不是白盒。其實盒子是白色的,但是設置了透明值,也是用壹個xml文件實現的。

background_login_div.xml

& lt?xml?version="1.0 "?編碼="UTF-8 "?& gt

& lt外形?xmlns:Android = "/apk/RES/Android " & gt;

& lt固體?android:color="#55FFFFFF "?/& gt;

& lt!- ?設置圓角

註意:?BottomRightRadius是左下角而不是右下角-& gt;

& lt角落?Android:topLeftRadius = " 10dp "?Android:topRightRadius = " 10dp "

Android:bottomRightRadius = " 10dp "?Android:bottomLeftRadius = " 10dp "/& gt;

& lt/shape & gt;

3.界面布局:

login.xml

& lt?xml?version="1.0 "?編碼="utf-8 "?& gt

& lt線性布局

xmlns:Android = "/apk/RES/Android "

android:orientation="vertical "

Android:layout _ width = " fill _ parent "

Android:layout _ height = " fill _ parent "

Android:background = " @ drawable/background _ log in " & gt;

& lt!- ?填充?內緣?布局_邊距?邊緣

android:layout_alignParentTop?布局的位置在頂部嗎?-& gt;

& ltRelativeLayout?

android:id="@+id/login_div "

Android:layout _ width = " fill _ parent "

Android:layout _ height = " wrap _ content "

android:padding="15dip "

Android:layout _ margin = " 15 dip "?

Android:background = " @ drawable/background _ log in _ div _ BG "?& gt

& lt!- ?賬號?-& gt;

& ltTextView?

Android:id = " @+id/log in _ user _ input "

Android:layout _ width = " wrap _ content "

Android:layout _ height = " wrap _ content "

Android:layout _ alignParentTop = " true "

android:layout_marginTop="5dp "

Android:text = " @ string/log in _ label _ username "

style = " @ style/normal text "/& gt;

& ltEditText?

android:id="@+id/username_edit "

Android:layout _ width = " fill _ parent "

Android:layout _ height = " wrap _ content "

Android:hint = " @ string/log in _ username _ hint "

Android:layout _ below = " @ id/log in _ user _ input "

android:singleLine="true "

Android:input type = " text "/& gt;

& lt!- ?密碼?文字?-& gt;

& ltTextView?

Android:id = " @+id/log in _ 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/log in _ label _ password "

style = " @ style/normal text "/& gt;

& ltEditText?

android:id="@+id/password_edit "

Android:layout _ width = " fill _ parent "

Android:layout _ height = " wrap _ content "

Android:layout _ below = " @ id/log in _ password _ input "

android:password="true "

android:singleLine="true "

Android:input type = " text password "?/& gt;

& lt!- ?登錄按鈕?-& gt;

& lt按鈕?

android:id="@+id/signin_button "

Android:layout _ width = " wrap _ content "

Android:layout _ height = " wrap _ content "

Android:layout _ below = " @ id/password _ edit "

Android:layout _ align right = " @ id/password _ edit "

Android:text = " @ string/log in _ label _ sign in "

Android:background = " @ drawable/blue _ button "?/& gt;

& lt/relative layout & gt;

& ltRelativeLayout?

Android:layout _ width = " fill _ parent "

Android:layout _ height = " wrap _ content "?& gt

& lttextview Android:id = " @+id/register _ link "

Android:text = " @ string/log in _ register _ link "

Android:layout _ width = " wrap _ content "

Android:layout _ height = " wrap _ content "

Android:layout _ margin left = " 15dp "

android:textColor="#888 "

Android:textColorLink = " # ff 0066 cc "?/& gt;

& ltImageView?Android:id = " @+id/mini Twitter _ 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 _ margin right = " 25dp "

Android:layout _ margin left = " 10dp "

Android:layout _ margin bottom = " 25dp "?/& gt;

& ltImageView?android:src="@drawable/logo "

Android:layout _ width = " wrap _ content "

Android:layout _ height = " wrap _ content "

Android:layout _ toLeftOf = " @ id/mini Twitter _ logo "

Android:layout _ align bottom = " @ id/mini Twitter _ logo "

Android:padding bottom = " 8dp "/& gt;

& lt/relative layout & gt;

& lt/linear layout & gt;

4、java源代碼,Java源文件比較簡單,只需實例化Activity,去掉標題欄即可。

包裹?com . my Twitter . a activity;

進口?Android . app . activity;

進口?Android . OS . bundle;

進口?Android . view . window;

公共?班級?LoginActivity?延伸?活動?{

@覆蓋

公共?作廢?onCreate(捆綁?savedInstanceState)?{

super . oncreate(savedInstanceState);

requestWindowFeature(窗口。特征_編號_標題);

setContentView(r . layout . log in);

}

} ?

5.實現效果如下:?