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

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁 > 运维知识 > Android >内容正文

Android

android开发实例之minitwitter登录界面 代码,Android实例miniTwitter登录界面

發(fā)布時(shí)間:2024/9/19 Android 37 豆豆
生活随笔 收集整理的這篇文章主要介紹了 android开发实例之minitwitter登录界面 代码,Android实例miniTwitter登录界面 小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.

先上效果圖:

布局分析:分成三個(gè)部分,該Activity是一個(gè)無標(biāo)題的,設(shè)置無標(biāo)題需要在setContentView之前設(shè)置,否則會(huì)報(bào)錯(cuò):

requestWindowFeature(Window.FEATURE_NO_TITLE);

setContentView(R.layout.login);

第一部分是一個(gè)帶漸變色背景的LinearLayout布局,關(guān)于背景漸變色請(qǐng)參照android小技巧:android背景漸變色(shape,gradient),

這里就不再貼上代碼了,效果如下圖所示

第二部分,紅色線區(qū)域內(nèi),包括1,2,3,4如圖所示:

紅色的1表示的是一個(gè)帶圓角且背景色為#55FFFFFF(淡藍(lán)色)的RelativeLayout布局,代碼如下:

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

solid表示填充色,這里填充的是淡藍(lán)色。corners是設(shè)置圓角。

dp(即dip,deviceindependentpixels)設(shè)備獨(dú)立像素:這個(gè)和設(shè)備硬件有關(guān),一般我們?yōu)榱酥С諻VGA、HVGA和QVGA,不依賴像素。在android上開發(fā)的程序?qū)?huì)在不同分辨率的手機(jī)上運(yùn)行。為了讓程序外觀不至于相差太大,所以引入了dip的概念。比如定義一個(gè)矩形10x10dip.在分辨率為160dpi的屏上,比如G1,正好是10x10像素。而在240dpi的屏,則是15x15像素.換算公式為pixs=dips*(density/160).density就是屏的分辨率。

然后RelativeLayou的background引用此drawable,具體RelativeLayout設(shè)置如下:

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"

>

padding是指內(nèi)邊距(也就是指內(nèi)容與邊框的距離),layout_margin為外邊距(它的上一層與邊框的距離)。

接下來是區(qū)域2,為賬號(hào)的文本和輸入框,首先是賬號(hào)的文本,代碼如下:  

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

android:layout_alignParentTop這里表示此TextView的位置處于頂部

android:layout_marginTop="5dp"這里表示此TextView的邊框與RelativeLayout的頂部邊框距離有5dp

這里需要對(duì)這個(gè)TextView設(shè)置下字體顏色和字體大小,定義在res/style.xml里面

#444

14sp

定義賬號(hào)的輸入框,如下

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

android:hint輸入框里面的提示文字,

android:layout_below這里是設(shè)置為在賬號(hào)的文本框的下面,

android:singleLine為單行輸入(即你輸入回車的時(shí)候不會(huì)在換行了)

android:inputType這里text表示輸入的類型為文本

區(qū)域3是密碼文本和輸入框,同區(qū)域2,代碼如下:

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

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"

/>

區(qū)域4,登錄按鈕

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"

/>

第三部分:底下的文字和兩張圖片,分別標(biāo)記了1,2,3,4

區(qū)域1:還是一個(gè)RelativeLayout,但這里設(shè)置的很簡(jiǎn)單,代碼如下:

android:layout_width="fill_parent"

android:layout_height="wrap_content">

區(qū)域2:"沒有賬號(hào)?注冊(cè)"這幾個(gè)文字定義在string里面,包含了一個(gè)標(biāo)簽,

沒有帳號(hào)? 注冊(cè)

定義如下:

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"

/>

TextView是支持簡(jiǎn)單的html標(biāo)簽的,如標(biāo)簽,但并不是支持所有標(biāo)簽,支持更復(fù)雜的html標(biāo)簽得用webView組件。

android:textColorLink是設(shè)置文字聯(lián)機(jī)的顏色,雖然TextView支持標(biāo)簽,但是這里不能點(diǎn)擊此鏈接,不要被假象所迷惑。

區(qū)域3是一直貓的卡通圖片,貌似有點(diǎn)丑,將就下吧,

android:layout_alignParentRight="true"位于layout的最右邊

android:layout_alignParentBottom="true"位于layout的最底部

android:layout_marginRight="25dp"該imageView的邊框距離layout邊框有25dp,其他的margin類似。

區(qū)域4是一個(gè)帶文字的圖片的ImageView

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"

/>

android:layout_toLeftOf="@id/miniTwitter_logo"在那個(gè)小貓ImageView的左邊(水平位置)

android:layout_alignBottom="@id/miniTwitter_logo"這里意思是這兩個(gè)ImageView(區(qū)域3和區(qū)域4)下邊緣對(duì)齊

android:paddingBottom="8dp"圖片距離ImageView底部邊框8dp,也就是將圖片上抬個(gè)8dp

總結(jié)

以上是生活随笔為你收集整理的android开发实例之minitwitter登录界面 代码,Android实例miniTwitter登录界面的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。