欧美三区_成人在线免费观看视频_欧美极品少妇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條評論
主站蜘蛛池模板: 久久亚洲热 | 亚洲欧美成人 | 97超级碰碰碰在线播放 | 日本久久久久久久 | 国产浮力影院在线地址 | 成人免费电影av | 国产精品免费观看 | 国产激情一区二区三区 | 亚洲日本中文字幕天天更新 | 亚洲好视频| 午夜性刺激在线观看视频 | 中文字幕视频在线 | 国产精品视频免费视频 | 成人欧美一区在线视频在线观看 | 91精品国产综合久久福利软件 | 性激情 | 成人视品 | 性做久久久久久免费观看欧美 | 国产1区2区 | 国产成人精品免费久久久久 | 国产成人啪精品视频免费网站软件 | 欧美伦理大片 | 国产精品网址 | 国产亚洲蜜芽精品久久 | 91中文字幕 | 99热国产这里只有精品9九 | 黄色片在线免费看 | 日本高清视频www | 久久久久国产成人精品亚洲午夜 | 国产精品视频第一区二区三区 | 欧洲怡红院 | 国产成久久免费精品AV片天堂 | 久久人人爽人人爽人人片va | 男女一进一出视频 | 欧美日韩一区二区中文字幕 | 久久综合狠狠色综合伊人 | 久久精品99久久 | www一区二区三区 | 日本www视频在线观看 | 久久99精品久久久久久国产越南 | 男女性刺激爽爽免费视频 |