新聞中心
在上一篇文章中,我們已經(jīng)完成了數(shù)據(jù)模型的代碼,并且為了測試方便,在類中直接為很多成員變量提供了默認值。接下來,進入到界面部分。

網(wǎng)站建設(shè)哪家好,找創(chuàng)新互聯(lián)!專注于網(wǎng)頁設(shè)計、網(wǎng)站建設(shè)、微信開發(fā)、微信小程序開發(fā)、集團企業(yè)網(wǎng)站建設(shè)等服務(wù)項目。為回饋新老客戶創(chuàng)新互聯(lián)還提供了象州免費建站歡迎大家使用!
縱觀整個界面,可以分成上下兩塊,一塊是頂端的操作條,另一塊是占主體的列表框。
先從頂端的操作條開始,在這里,很容易分解成三個部分,左側(cè)的寫微博按鈕,中間的用戶名顯示,右側(cè)的刷新按鈕。兩個按鈕的風(fēng)格是一樣的,都是有常規(guī)和按下兩種狀態(tài),這種按鈕是非常常用的,我的做法是:
1. 在drawable文件夾下建立兩個xml文件,分別對應(yīng)了兩個按鈕;
2. 每個xml文件中使用selector標(biāo)簽定義常規(guī)狀態(tài)和選中狀態(tài)的兩個圖片資源;
3. 在Activity的布局中使用ImageButton,指定按鈕的background為透明,并指定src為剛才定義的兩個xml。
下面是這兩個xml文件的內(nèi)容:
- view plaincopy to clipboardprint?
- view plaincopy to clipboardprint?
在main.xml文件中,進行這一部分的布局,對于這三個界面元素而言,有明確的位置關(guān)系,因此采用RelativeLayout合適,內(nèi)容如下:
- view plaincopy to clipboardprint?
- android:layout_width="fill_parent" android:layout_height="44dp"
- android:background="@drawable/titlebar_lightgray_bg" android:orientation="horizontal">
- android:layout_width="wrap_content" android:layout_height="fill_parent"
- android:layout_alignParentLeft="true" android:background="@android:color/transparent"
- android:src="@drawable/write_button">
- android:layout_width="fill_parent" android:layout_height="fill_parent"
- android:textColor="@color/black" android:gravity="center" android:textSize="18sp">
- android:layout_width="wrap_content" android:layout_height="fill_parent"
- android:layout_alignParentRight="true" android:background="@android:color/transparent"
- android:src="@drawable/refresh_button">
最后,指定RelativeLayout的background為背景圖片即可。
本次用到的圖片有:
分享標(biāo)題:AndroidUI控件組合應(yīng)用之二:按鈕布局
本文網(wǎng)址:http://www.dlmjj.cn/article/djegsed.html


咨詢
建站咨詢
