欧美三区_成人在线免费观看视频_欧美极品少妇xxxxⅹ免费视频_a级毛片免费播放_鲁一鲁中文字幕久久_亚洲一级特黄

ListView頁眉頁腳效果VS android背景漸變

系統 2547 0
大家都知道,在我們調用ListView的addFooterView()方法給List增加一個頁腳時,如果列表內容很多,超過了屏幕大小,那么頁腳就看不到了,可我們一般想要的效果是如下圖所示的,在ListView的內容超過屏幕時,頁腳還在屏幕的底部。

ListView頁眉頁腳效果VS android背景漸變

本文將介紹上圖所示的ListView效果,同時介紹一下在android中如何實現漸變效果,就像上圖中的頁眉頁腳的背景色一樣。

實現上面的效果主要使用幾個RelativeLayout標簽和ListView組合即可,代碼如下所示:
    
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
	android:orientation="vertical" android:layout_width="fill_parent"
	android:layout_height="fill_parent">
	<RelativeLayout android:id="@+id/listHeader"
		android:background="@drawable/jbshape" android:layout_alignParentTop="true"
		android:gravity="center_horizontal" android:layout_width="fill_parent"
		android:layout_height="wrap_content">
		<TextView android:text="IdeasAndroid 列表演示" android:textColor="#000000"
			android:textSize="18dip" android:layout_width="wrap_content"
			android:layout_height="wrap_content"></TextView>
	</RelativeLayout>
	<RelativeLayout android:id="@+id/listFooter"
		android:background="@drawable/jbshape" android:gravity="center_horizontal"
		android:layout_alignParentBottom="true" android:layout_width="fill_parent"
		android:layout_height="wrap_content">
		<Button android:id="@+id/prePage" android:layout_width="wrap_content"
			android:layout_height="wrap_content" android:text="上一頁"
			android:layout_alignParentLeft="true"></Button>
		<Button android:layout_width="wrap_content"
			android:layout_gravity="right" android:layout_height="wrap_content"
			android:text="下一頁" android:layout_toRightOf="@id/prePage"></Button>
	</RelativeLayout>
	<ListView android:id="@+id/myListView" android:layout_width="fill_parent"
		android:layout_height="fill_parent" android:layout_below="@id/listHeader"
		android:layout_above="@id/listFooter">
	</ListView>
</RelativeLayout>

  

幾個關鍵點:
1、在頁眉(id為listHeader)使用屬性android:layout_alignParentTop=”true”
聲明頁眉部分與父視圖的頂部對齊。
2、在頁腳(id為listFooter)使用屬性android:layout_alignParentBottom=”true” 聲明其與父視圖的底部對齊。
3、在 ListView中使用屬性android:layout_below=”@id/listHeader” android:layout_above=”@id/listFooter” 聲明ListView位于listHeader的下方,位于listFooter的上方。

這樣我們的頁眉頁腳效果就實現了。

再來看看是怎么實現漸變的?

我們在res/drawable目錄下新建一個叫jbshape.xml的文件,內容如下所示:
    
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
	android:shape="rectangle">
	<gradient android:startColor="#509245" android:centerColor="#3e8532"
		android:endColor="#509245" android:type="linear" android:angle="90"
		android:centerX="0.5" android:centerY="0.5" />
	<padding android:left="7dp" android:top="7dp" android:right="7dp"
		android:bottom="7dp" />
	<corners android:radius="4dp" />
</shape>

  

這里就不多講了,相信你一看就能看懂,android:shape 配置的是圖形的形式,主要包括方形、圓形等,本例中為方形。gradient節點主要配置起點顏色、終點顏色、中間點的坐標、中間點的顏色、漸變角度(90度為上下漸變,0為左右漸變),padding節點主要配置上下左右邊距,corners節點配置四周園角的半徑。更詳細的配置參見http://www.ideasandroid.com/android/sdk/docs/guide/topics/resources/drawable-resource.html 。

使用漸變就更簡單了,如第一部分代碼中所示的,直接用android:background=”@drawable/jbshape” 配置背景為剛才配置的漸變圖形即可。

好了,本文就介紹到這。如果還有不明白的地方請下載下面的代碼,然后在本地測試一下就明白了。

代碼下載:http://www.ideasandroid.com/android/demo/HeaderBottomListDemo.rar

ListView頁眉頁腳效果VS android背景漸變


更多文章、技術交流、商務合作、聯系博主

微信掃碼或搜索:z360901061

微信掃一掃加我為好友

QQ號聯系: 360901061

您的支持是博主寫作最大的動力,如果您喜歡我的文章,感覺我的文章對您有幫助,請用微信掃描下面二維碼支持博主2元、5元、10元、20元等您想捐的金額吧,狠狠點擊下面給點支持吧,站長非常感激您!手機微信長按不能支付解決辦法:請將微信支付二維碼保存到相冊,切換到微信,然后點擊微信右上角掃一掃功能,選擇支付二維碼完成支付。

【本文對您有幫助就好】

您的支持是博主寫作最大的動力,如果您喜歡我的文章,感覺我的文章對您有幫助,請用微信掃描上面二維碼支持博主2元、5元、10元、自定義金額等您想捐的金額吧,站長會非常 感謝您的哦!!!

發表我的評論
最新評論 總共0條評論
主站蜘蛛池模板: 午夜视频久久 | 亚洲欧美在线观看一区二区 | 国产免费久久精品44 | 亚洲爽| 欧美日韩欧美日韩 | 国产色婷婷视频在线观看 | 国产免费久久精品44 | 中文字幕在线一区二区三区 | 欧美不卡| 欧美亚洲一区二区三区四区 | 欧美日韩国产在线 | 亚洲国产一区在线 | 2一3sex性hd| 亚洲成av人片在线观看 | 亚洲国产日韩在线观频 | 亚洲免费网 | 又大又紧又硬又湿a视频 | 欧美成人久久 | 日韩国产在线 | 请吃饭的姐姐 | 日本国产视频 | 91香蕉国产视频 | 亚洲精品中文字幕大岛优香 | 亚洲精品久| 看中国毛片 | 国产99视频在线 | 小明看看在线视频 | 欧美日韩在线视频观看 | 美女在线视频一区二区 | 成人毛片网站 | 一级做a爰片性色毛片男小说 | 波多野结衣在线观看视频 | 青青在线香蕉精品视频免费看 | 奇米影视四色中文字幕 | 欧美高清性色生活片免费观看 | 国产精品久久久久久久久久久新郎 | 精品麻豆cm视频在线看 | 人人模人人干 | 精品伊人久久久大香线蕉欧美 | av超碰 | 欧美精彩视频 |