国产片侵犯亲女视频播放_亚洲精品二区_在线免费国产视频_欧美精品一区二区三区在线_少妇久久久_在线观看av不卡

服務器之家:專注于服務器技術及軟件下載分享
分類導航

PHP教程|ASP.NET教程|Java教程|ASP教程|編程技術|正則表達式|C/C++|IOS|C#|Swift|Android|VB|R語言|JavaScript|易語言|vb.net|

服務器之家 - 編程語言 - Android - android 開發教程之日歷項目實踐(三)

android 開發教程之日歷項目實踐(三)

2020-12-29 15:51Android開發網 Android

決定開始學習 Android 平臺下的軟件開發,以日歷作為實踐項目,進行一周后,基本完成,有需要的朋友可以參考下

二、創建樣式

日歷顯示的表格線,使用 cell 填充圖形的邊框來實現,為了統一,我們先定義邊框線的顏色及線條精細。

另外還要定義一系統填充樣式等。

創建 color

color_calendar_border 表格線
color_calendar_title_gregorian 標題欄日期年月文字的顏色color_calendar_title_lunar 標題欄農歷color_calendar_title_startcolor_calendar_title_endcolor_calendar_title_addition 標題欄 節日,節氣color_calendar_weekindex 年單位周序號color_calendar_weekindex_backgroundcolor_calendar_weekend 周末color_calendar_weekend_backgroundcolor_calendar_header 表頭color_calendar_header_backgroundcolor_calendar_outrange 非本月日期color_calendar_outrange_backgroundcolor_calendar_normal_gregorian 公歷日期color_calendar_normal_lunar  農歷日期color_calendar_normal_backgroundcolor_calendar_today_gregorian 今天公歷日期color_calendar_today_lunar 今天農歷日期color_calendar_today_backgroundcolor_calendar_solarterm 節氣color_calendar_festival 節日color_calendar_pressed 點擊單元格填充背景
color_calendar_focused 焦點單元格填充背景

 

 

點擊 下圖 菜單 search 下面的圖標(new android xml file)

 

android 開發教程之日歷項目實踐(三)

選擇 resource type -> values,輸入文件名 -> colors,選擇 root element -> resources,點擊 finish。

android 開發教程之日歷項目實踐(三)

定義 color_calendar_border

復制代碼 代碼如下:

<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="color_calendar_border">#3fff</color>
<color name="color_calendar_title_gregorian">#cfff</color>
<color name="color_calendar_title_lunar">#cfff</color>
<color name="color_calendar_title_start">#c000</color>
<color name="color_calendar_title_end">#6000</color>
<color name="color_calendar_title_addition">#f63</color>
<color name="color_calendar_weekindex">#3fff</color>
<color name="color_calendar_weekindex_background">#369f</color>
<color name="color_calendar_weekend">#9fff</color>
<color name="color_calendar_weekend_background">#3f99</color>
<color name="color_calendar_header">#9fff</color>
<color name="color_calendar_header_background">#6000</color>
<color name="color_calendar_outrange">#3fff</color>
<color name="color_calendar_outrange_background">#3fff</color>
<color name="color_calendar_normal_gregorian">#cfff</color>
<color name="color_calendar_normal_lunar">#9fff</color>
<color name="color_calendar_normal_background">#0000</color>
<color name="color_calendar_today_gregorian">#cfff</color>
<color name="color_calendar_today_lunar">#9fff</color>
<color name="color_calendar_today_background">#06c</color>
<color name="color_calendar_solarterm">#c0c3</color>
<color name="color_calendar_festival">#cf90</color>
<color name="color_calendar_pressed">#306c</color>
<color name="color_calendar_focused">#606c</color>
</resources>


color 的值由四部分組成:透明度,red, green, blue,每部分可以用一位或兩位十六進制數字表示,透明度可以省略。

 

如:

  ffff 或 ffffffff 表示不透明白色,前面的透明度可以省略:fff 或 ffffff

  7f00 表示半透明的紅色

更多請查看:http://developer.android.com/guide/topics/resources/more-resources.html#color

將顏色定義統一放在一個文件中,是出于兩點考慮,一是多處用到同一種顏色定義,這樣一處修改,相應的位置都會跟著變,另外則是為了修改方便,無須到處去找某一個文件。上面的 color_calendar_border 被表格的各種狀態填充圖形用到,而像 color_calendar_weelndex_background 只有一處用到,如果不想統一管理,也可以不在這里定義,在定義 shape 時,直接使用固定值。

創建 dimen

 

 

點擊 下圖 菜單 search 下面的圖標(new android xml file)


android 開發教程之日歷項目實踐(三)

選擇 resource type -> values,輸入文件名 -> dimens,選擇 root element -> resources,點擊 finish。

android 開發教程之日歷項目實踐(三)

完成的 xml 文件內容:

復制代碼 代碼如下:

<?xml version="1.0" encoding="utf-8"?>
<resources>
<dimen name="dimen_calendar_border">1dp</dimen>

</resources>


尺寸的單位主要有六種:dp, sp, pt, px, mm, in,更多介紹請參照:http://developer.android.com/guide/topics/resources/more-resources.html#dimension

創建 color state list

 

 

在我們的日歷中,單元格有三種狀態,分別是無焦點,按下,有焦點,為了在不同的狀態下顯示不同的顏色,可以定義 color state list。

關于 color state list,更多請參照:http://developer.android.com/guide/topics/resources/color-list-resource.html。

 

color state list 列表

colorlist_calendar_normal
colorlist_calendar_outrange
colorlist_calendar_weekend
colorlist_calendar_today

 

點擊 下圖 菜單 search 下面的圖標(new android xml file)

android 開發教程之日歷項目實踐(三)

選擇 resource type -> drawable,輸入文件名 -> colorlist_calendar_outrange,選擇 root element -> selector,點擊 finish。

完成的 xml 文件

復制代碼 代碼如下:

<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_pressed="true" android:color="@color/color_calendar_pressed"/>
<item android:state_focused="true" android:color="@color/color_calendar_focused"/>
<item android:color="@color/color_calendar_outrange_background"/>
</selector>


其它也同樣創建。

 

 

創建的 drawable

shape_calendar_titlebar.xml 主畫面標題欄填充背景shape_calendar_header.xml 表頭填充背景shape_calendar_cell_weekindex.xml 年為單元的周序號單元格填充背景shape_calendar_cell_weekend.xml 周末日期單元格填充背景shape_calendar_cell_normal.xml 當月普通日期單元格填充背景shape_calendar_cell_outrange.xml 非當前月日期單元格填充背景shape_calendar_cell_today.xml 今天單元格填充背景

 

點擊 下圖 菜單 search 下面的圖標(new android xml file)

android 開發教程之日歷項目實踐(三)

選擇 resource type -> drawable,輸入文件名 -> shpae_calendar_titlebar,選擇 root element -> shape,點擊 finish。

android 開發教程之日歷項目實踐(三)

輸入 shape 定義

復制代碼 代碼如下:

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<corners android:radius="3dp" />
<gradient android:angle="90"
android:startcolor="@color/color_calendar_title_start"
android:endcolor="@color/color_calendar_title_end"
/>
</shape>


這段定義代碼會幫我們生成一個圓角矩形,填充顏色是上下漸變的。

 

radius = 圓角大小

angle = 漸變填充方向(45的位數,0-360,90 表示從上往下漸變填充)

startcolor, endcolor = 填充的起始與終止顏色定義

其它的也按此一一創建,但表格的填充矩形,不要圓角,刪除 radius 或設為 0

如:shape_calendar_cell_outrange.xml

復制代碼 代碼如下:

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<solid android:color="@color/colorlist_calendar_outrange" />
<stroke android:width="@dimen/dimen_calendar_border"
android:color="@color/color_calendar_border" />
</shape>


solid = 填充色,這里用前面定義的 color state list,來實現不同狀態下,填充不同顏色。

 

stroke = 矩形邊框,width = 邊框線粗細, color = 邊框線顏色

創建 style

打開 res/styles.xml,添加樣式定義。由于樣式與畫面設計相關,在我們設計界面時,還要相應調整,所以在使用時,一一添加。這里給出一個 sample:

復制代碼 代碼如下:

<resources xmlns:android="http://schemas.android.com/apk/res/android">

<!--
base application theme, dependent on api level. this theme is replaced
by appbasetheme from res/values-vxx/styles.xml on newer devices.
-->
<style name="appbasetheme" parent="android:theme.light">
<!--
theme customizations available in newer api levels can go in
res/values-vxx/styles.xml, while customizations related to
backward-compatibility can go here.
-->
</style>

<!-- application theme. -->
<style name="apptheme" parent="appbasetheme">
<!-- all customizations that are not specific to a particular api-level can go here. -->
</style>

<style name="style_calendar_title">
<item name="android:background">@drawable/shape_calendar_titlebar</item>
</style>

<style name="style_calendar_title_gregorian">
<item name="android:textsize">36sp</item>
<item name="android:textstyle">bold</item>
<item name="android:textcolor">@color/color_calendar_title_gregorian</item>
<item name="android:layout_marginleft">25dp</item>
</style>
... ...
</resources>

延伸 · 閱讀

精彩推薦
主站蜘蛛池模板: 91精品国产乱码久久久久久久久 | 欧美午夜影院 | 久久久久综合 | 亚洲午夜精品片久久www慈禧 | 中文字幕高清视频 | 欧美日韩一区二区在线观看 | 欧美成人免费电影 | 日韩在线视频观看 | 欧美日韩国产一区二区三区不卡 | 免费日韩成人 | 人人插人人 | 国产日韩欧美在线观看 | 欧美日韩一区二区三区不卡视频 | 日韩免费片| 成人精品99| 理伦影院 | 91午夜精品 | 亚洲在线 | 亚洲精品一区二区三区在线观看 | 三区影院 | 亚洲男人天堂网 | 欧美bbbxxx| 久草最新 | 毛片在线免费 | 亚洲欧美自拍视频 | 精品欧美一区二区三区久久久 | 欧美爱爱视频 | 五月激情综合网 | 国产精品久久久久久久久久久久冷 | 开心久久婷婷综合中文字幕 | 久久99精品久久久久 | 欧美一级在线观看 | av免费网| 国产精品久久久久久久久久久久久 | 国内精品久久久久久影视8 有码在线 | 亚洲一区中文字幕在线观看 | 亚洲精品一区二区三区精华液 | 亚洲人成网站在e线播放 | 亚洲永久免费视频 | 亚洲精品一区在线观看 | 亚洲 视频 一区 |