代碼:http://download.csdn.net/detail/huangbin95487710/9257743
依賴包模式
完整運行還需要用到以下依賴包
- 下拉漸顯圖片的scrollview【CircleView】
<declare-styleable name="Circle"> <!-- 圖片拉伸高度 --> <attr name="circle_length" format="integer" /> <!-- 阻尼回彈時間 --> <attr name="circle_duration" format="integer" /> <!-- 圖片高度 --> <attr name="circle_image_height" format="integer" /> <!-- 圖片基於什麼分辨率設計得,按寬度計算 --> <attr name="circle_image_res" format="integer" /> </declare-styleable>
- 自定義全屏Dialog【DivDialog】
<!-- dialog的樣式 --> <style name="divdialog" parent="@android:style/Theme.Dialog"> <item name="android:windowFrame">@null</item> <!-- Dialog的windowFrame框爲無 --> <item name="android:windowIsFloating">true</item> <!-- 是否漂現在activity上 --> <item name="android:windowIsTranslucent">true</item> <!-- 是否半透明 --> <item name="android:windowFullscreen">true</item> <item name="android:windowNoTitle">true</item> <item name="android:backgroundDimEnabled">false</item> <item name="android:windowBackground">@android:color/transparent</item> </style>
- 去除阻塞效果展開列表【ExpandableListView】
- 全展開GridView【FullGridView】
- 全展開listview【FullListView】
- 去除阻尼效果GridView【GridView】
- 自動縮放圖片(等比寬,縮放高度)【ImageView】
- 自動縮放&摳圓圖片【ImageViewEraser】
- 固定佈局,裁剪圖片(可按佈局權重或者固定寬高,裁剪圖片,居中擺放)【ImageViewLayout】
- 固定佈局,裁剪圖片(裁剪正方形圖形)【ImageViewWH】
- 豎直方向的虛線【LineView】
<declare-styleable name="Line"> <!-- 線方式 --> <attr name="line_mode"> <enum name="normal" value="0" /> <enum name="dash" value="1" /> </attr> <!-- 顏色 --> <attr name="line_color" format="color" /> </declare-styleable>
- 去除阻尼效果ListView【ListView】
- 索引效果【PListView,PBladeView,PBaseAdapter】
<declare-styleable name="PBladeStyle"> <!-- 字體顏色 --> <attr name="android:textColor" /> <!-- 字體大小 --> <attr name="android:textSize" /> <!-- 選中字體顏色 --> <attr name="pblv_select_text_color" format="color" /> <!-- 選中字體背景顏色 --> <attr name="pblv_select_text_bg_color" format="color" /> <!-- 是否顯示索引字符 --> <attr name="pblv_show_toast" format="boolean" /> <!-- 過濾不存在索引字符 --> <attr name="pblv_filter_key" format="boolean" /> </declare-styleable>
<!-- 索引樣式 --> <style name="DivPBladeStyle"> <!-- 字體顏色 --> <item name="android:textColor">#FF000000</item> <!-- 字體大小 --> <item name="android:textSize">14sp</item> <!-- 選中字體顏色 --> <item name="pblv_select_text_color">#FFffffff</item> <!-- 選中字體背景顏色 --> <item name="pblv_select_text_bg_color">#FF000000</item> <!-- 是否顯示索引字符 --> <item name="pblv_show_toast">true</item> <!-- 過濾不存在索引字符 --> <item name="pblv_filter_key">false</item> </style>
- 引用圓點【PointView】
<declare-styleable name="PointView"> <!-- 圖標寬度 --> <attr name="point_width" format="dimension" /> <!-- 圖標高度 --> <attr name="point_height" format="dimension" /> <!-- 間距 --> <attr name="point_splace" format="dimension" /> <!-- 背景 --> <attr name="point" format="integer" /> <!-- 選中背景 --> <attr name="point_pressed" format="integer" /> <!-- 佈局長度 --> <attr name="android:layout_width" /> <!-- 佈局高度 --> <attr name="android:layout_height" /> </declare-styleable>
- 彈窗設置【Popup】
<style name="popup_style"> <item name="android:windowEnterAnimation">@anim/popup_scale_out</item> <item name="android:windowExitAnimation">@anim/popup_scale_in</item> </style>
- 圓環進度條【ProgressWheel】
<declare-styleable name="ProgressWheel"> <attr name="android:text" /> <attr name="android:textColor" /> <attr name="android:textSize" /> <attr name="android:layout_width" /> <attr name="android:layout_height" /> <!-- 進度顏色 --> <attr name="pw_barcolor" format="color" /> <!-- 外圓顏色 --> <attr name="pw_rimcolor" format="color" /> <!-- 外圓寬度 --> <attr name="pw_rimwidth" format="dimension" /> <!-- 增長速度 --> <attr name="pw_spinspeed" format="dimension" /> <!-- 增長事件 --> <attr name="pw_delaymillis" format="integer" /> <!-- 內圓顏色 --> <attr name="pw_circlecolor" format="color" /> <!-- 進度寬度 --> <attr name="pw_barwidth" format="dimension" /> <!-- 進度長度 --> <attr name="pw_barlength" format="dimension" /> <!-- 圓邊框顏色 --> <attr name="pw_contourcolor" format="color" /> <!-- 圓邊框大小 --> <attr name="pw_contoursize" format="dimension" /> <!-- 是否顯示進度 --> <attr name="pw_show_num" format="boolean" /> </declare-styleable> <!-- 重寫ProgressWheel樣式 --> <style name="DivProgressWheel"> <item name="android:layout_width">64dp</item> <item name="android:layout_height">64dp</item> </style>
- 圓矩形圖片【RectImageView】
- 圓形
- 矩形
<declare-styleable name="RectImageView"> <!-- 弧度 --> <attr name="ri_radius" format="dimension" /> <!-- 圖片原始寬度 --> <attr name="ri_base_width" format="integer" /> <!-- 圖片原始高度 --> <attr name="ri_base_height" format="integer" /> <!-- 邊框寬度 --> <attr name="ri_border_width" format="dimension" /> <!-- 邊框顏色 --> <attr name="ri_border_color" format="color" /> <!-- 是否爲圓形 --> <attr name="ri_is_oval" format="boolean" /> <!-- 居中方式 --> <attr name="android:scaleType" /> <!-- 背景 --> <attr name="android:background" /> <!-- 圖片 --> <attr name="android:src" /> </declare-styleable> <!-- 默認樣式 --> <style name="DivRectImageView"> <item name="ri_radius">@dimen/ri_radius_default</item> <item name="ri_base_width">0</item> <item name="ri_base_height">0</item> <item name="ri_border_width">@dimen/ri_border_width_default</item> <item name="ri_border_color">@color/ri_border_color_default</item> <item name="ri_is_oval">@bool/ri_is_oval_default</item> <item name="android:scaleType">centerCrop</item> </style>
- 橫條多圖片滾動【RollImageView】
<declare-styleable name="Roll"> <!-- 移動方式 --> <attr name="rool_mode"> <enum name="left" value="0" /> <enum name="right" value="1" /> </attr> <!-- 滾動時間 --> <attr name="roll_duration" format="integer" /> <!-- 圖片高度 --> <attr name="roll_image_height" format="integer" /> <!-- 圖片基於什麼分辨率設計得,按寬度計算 --> <attr name="roll_image_height_base" format="integer" /> <!-- 圖片觸摸移動 --> <attr name="roll_touch" format="boolean" /> <!-- 最小寬度倍數 ,最小1.0 --> <attr name="roll_minwidth" format="float" /> <!-- 圖片id --> <attr name="android:src" /> </declare-styleable> <style name="DivRoll"> <item name="android:layout_width">fill_parent</item> <item name="android:layout_height">wrap_content</item> <item name="roll_duration">50</item> <item name="roll_image_height">300</item> <item name="roll_image_height_base">960</item> <item name="roll_touch">true</item> <item name="android:src">@drawable/view_no_photo</item> <item name="rool_mode">left</item> <item name="roll_minwidth">1.2</item> </style>
- ListView滾動【RollListView】
<declare-styleable name="RollList"> <!-- list滾動時間 --> <attr name="roll_list_duration" format="integer" /> </declare-styleable> <style name="DivRollList" parent="@style/DivListView"> <item name="roll_list_duration">50</item> </style>
- 去除阻尼效果【ScrollView】
- 自定義ScrollView,解決:ScrollView嵌套ViewPager,導致ViewPager不能滑動的問題【ScrollViewCustom】
- 不能觸摸的ScrollView(適用場景:ScrollView嵌套ScrollView)【ScrollViewNoTouch】
- 拖動點控件【SeekBarView】
<!-- 高度 --> <dimen name="seekbar_height">10dip</dimen> <!-- 圓角幅度 --> <dimen name="seekbar_radius">6dip</dimen> <!-- 默認的底色 --> <color name="seekbar_bg">#60FFFFFF</color> <!-- 滾過的顏色 --> <color name="seekbar_select_bg">#00FFFFFF</color> <!-- 選中的寬度 --> <dimen name="seekbar_thumb_width">60dip</dimen> <!-- 選中的高度 --> <dimen name="seekbar_thumb_height">10dip</dimen> <!-- 選中的圓角幅度 --> <dimen name="seekbar_thumb_radius">6dip</dimen> <!-- 選中的顏色 --> <color name="seekbar_thumb_bg">#99FFFFFF</color> <!-- 平滑移動改變 --> <bool name="seekbar_move_change_show">true</bool> <declare-styleable name="SeekBarView"> <attr name="seekbar_move_change" format="boolean" /> </declare-styleable> <!-- 重寫SeekBar樣式 --> <style name="DivSeekBarView" parent="@android:style/Widget.SeekBar"> <item name="android:layout_width">fill_parent</item> <item name="android:layout_height">@dimen/seekbar_thumb_height</item> <item name="android:layout_gravity">center_vertical</item> <item name="android:max">100</item> <item name="android:maxHeight">@dimen/seekbar_height</item> <item name="android:minHeight">@dimen/seekbar_height</item> <item name="android:progressDrawable">@drawable/view_seekbar_drawable</item> <item name="android:thumb">@drawable/view_seekbar_thumb</item> <item name="android:thumbOffset">0dip</item> <item name="android:padding">0dip</item> <item name="seekbar_move_change">@bool/seekbar_move_change_show</item> </style>
- 標籤式自動排序佈局【TabsLayout】
<declare-styleable name="TabsLayout"> <attr name="android:paddingLeft" /> <attr name="android:paddingRight" /> <attr name="android:padding" /> <attr name="android:layout_margin" /> <attr name="android:layout_marginLeft" /> <attr name="android:layout_marginRight" /> <attr name="android:gravity" /> <attr name="android:orientation" /> <!-- 標籤控件佈局 --> <attr name="tabs_layout" format="integer" /> <!-- 展開動畫 --> <attr name="tabs_anim" format="boolean" /> </declare-styleable> <style name="DivTabsLayout"> <item name="android:orientation">vertical</item> <item name="android:layout_marginLeft">10dip</item> <item name="android:layout_marginRight">10dip</item> <item name="android:gravity">center_horizontal</item> <item name="tabs_layout">@layout/view_tabslayout</item> <item name="tabs_anim">true</item> </style>
- 文字控件(文字自動換行)【TextView】
- 自適應高度ViewPager(適用場景:ScrollView嵌套ViewPager)【ViewPagerCustom】
- 下拉刷新,上拉加載更多【XListView】
<declare-styleable name="XListView"> <!-- 底部背景顏色 --> <attr name="xlv_footer_bg" format="color" /> <!-- 底部字體大小 --> <attr name="xlv_footer_font_size" format="dimension" /> <!-- 底部字體顏色 --> <attr name="xlv_footer_font_color" format="color" /> <!-- 頂部背景顏色 --> <attr name="xlv_header_bg" format="color" /> <!-- 頂部字體大小 --> <attr name="xlv_header_font_size" format="dimension" /> <!-- 頂部字體顏色 --> <attr name="xlv_header_font_color" format="color" /> <!-- 每頁的數量 --> <attr name="xlv_page_num" format="integer" /> <!-- 刷新 --> <attr name="xlv_refresh" format="boolean" /> <!-- 加載更多 --> <attr name="xlv_load" format="boolean" /> <!-- 加載禁止滑動 --> <attr name="xlv_touch" format="boolean" /> <!-- 頭部佈局 --> <attr name="xlv_header_layout" format="integer" /> <!-- 頭部佈局 --> <attr name="xlv_footer_layout" format="integer" /> </declare-styleable> <style name="DivXListView" parent="@style/DivListView"> <item name="xlv_footer_bg">#FFffffff</item> <item name="xlv_footer_font_size">16sp</item> <item name="xlv_footer_font_color">#FF6e6e6e</item> <item name="xlv_header_bg">#FFffffff</item> <item name="xlv_header_font_size">16sp</item> <item name="xlv_header_font_color">#FF6e6e6e</item> <item name="xlv_page_num">10</item> <item name="xlv_touch">false</item> <item name="xlv_load">true</item> <item name="xlv_refresh">true</item> <item name="xlv_header_layout">@layout/view_xlistview_header</item> <item name="xlv_footer_layout">@layout/view_xlistview_footer</item> </style>
- 輪播圖控件【AutoGallery】
<declare-styleable name="AutoGallery"> <!-- gallery圖片基礎寬度 --> <attr name="ag_item_width" format="integer" /> <!-- gallery圖片基礎高度 --> <attr name="ag_item_height" format="integer" /> <!-- gallery圖片基於什麼分辨率設計得 --> <attr name="ag_item_res" format="integer" /> <!-- gallery自動播放時間間隔,單位:毫秒 --> <attr name="ag_time" format="integer" /> <!-- 子控件圖片默認loading底圖 --> <attr name="ag_item_loading_bg" format="integer" /> <!-- 佈局長度 --> <attr name="android:layout_width" /> <!-- 佈局高度 --> <attr name="android:layout_height" /> <!-- 邊緣消失效果 --> <attr name="android:fadingEdge" /> <!-- 間距 --> <attr name="android:spacing" /> <!-- 未選中的透明度陰影 --> <attr name="unselectedalpha" format="float" /> <!-- 循環播放 --> <attr name="ag_loop" format="boolean" /> <!-- 是否自動播放 --> <attr name="ag_auto" format="boolean" /> <!-- 子控件佈局 --> <attr name="ag_item_layout" format="integer" /> </declare-styleable> <!-- 默認樣式 --> <style name="DivAutoGallery"> <item name="android:layout_width">fill_parent</item> <item name="android:layout_height">wrap_content</item> <item name="android:fadingEdge">none</item> <item name="android:spacing">0dip</item> <item name="unselectedalpha">1.0</item> <item name="ag_item_width">@integer/ag_item_width_default</item> <item name="ag_item_height">@integer/ag_item_height_default</item> <item name="ag_item_res">@integer/ag_item_res_default</item> <item name="ag_time">@integer/ag_time_default</item> <!-- 子控件圖片默認loading底圖 --> <item name="ag_item_loading_bg">@drawable/view_no_photo</item> <!-- 是否自動輪播 --> <item name="ag_auto">true</item> <!-- 是否循環播放 --> <item name="ag_loop">true</item> <!-- 子控件佈局,ID:item_icon,item_title --> <item name="ag_item_layout">@layout/view_autogallery_item</item> </style> <!-- 重寫樣式 --> <style name="MyDivAutoGallery" parent="@style/DivAutoGallery"> <item name="ag_time">6000</item> <!-- 子控件圖片默認loading底圖 --> <item name="ag_item_loading_bg">@drawable/view_no_photo</item> </style>
- HTML多標籤解析TextView【General.View.Html.TextView】
- 大圖相冊查看控件【GalleryViewPager】
<declare-styleable name="Photo"> <!-- 大圖顯示文本 --> <attr name="textview_show" format="boolean" /> <!-- 大圖顯示toast --> <attr name="toast_show" format="boolean" /> <!-- 大圖顯示引導點 --> <attr name="pointview_show" format="boolean" /> <!-- 循環播放 --> <attr name="loop" format="boolean" /> <!-- 點擊退出 --> <attr name="chiclk_finish" format="boolean" /> <!-- 長按保存 --> <attr name="longchiclk_save" format="boolean" /> </declare-styleable> <!-- 重寫PhotoView樣式 --> <style name="DivPhotoView"> <item name="textview_show">@bool/photo_textview_show</item> <item name="toast_show">@bool/photo_toast_show</item> <item name="pointview_show">@bool/photo_point_show</item> <item name="loop">@bool/photo_loop</item> <item name="chiclk_finish">@bool/photo_chiclk_finish</item> <item name="longchiclk_save">@bool/photo_longchiclk_save</item> </style>
- 滑動展開菜單控件【SwipeMenu】