Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
ChayChan
BottomBarLayout
提交
8a587583
B
BottomBarLayout
项目概览
ChayChan
/
BottomBarLayout
通知
1
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
12
列表
看板
标记
里程碑
合并请求
1
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
B
BottomBarLayout
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
12
Issue
12
列表
看板
标记
里程碑
合并请求
1
合并请求
1
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
8a587583
编写于
6月 28, 2017
作者:
C
chaychan
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
增加条目触摸背景的设置,可以增加触摸背景色变化和水波纹效果
上级
c136a18d
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
48 addition
and
0 deletion
+48
-0
demo/src/main/res/drawable-v21/selector_bg.xml
demo/src/main/res/drawable-v21/selector_bg.xml
+5
-0
demo/src/main/res/drawable/selector_bg.xml
demo/src/main/res/drawable/selector_bg.xml
+5
-0
demo/src/main/res/layout/activity_main.xml
demo/src/main/res/layout/activity_main.xml
+8
-0
demo/src/main/res/values/colors.xml
demo/src/main/res/values/colors.xml
+1
-0
library/src/main/java/com/chaychan/library/BottomBarItem.java
...ary/src/main/java/com/chaychan/library/BottomBarItem.java
+20
-0
library/src/main/res/values/attr.xml
library/src/main/res/values/attr.xml
+4
-0
library/src/main/res/values/colors.xml
library/src/main/res/values/colors.xml
+5
-0
未找到文件。
demo/src/main/res/drawable-v21/selector_bg.xml
0 → 100644
浏览文件 @
8a587583
<?xml version="1.0" encoding="utf-8"?>
<ripple
xmlns:android=
"http://schemas.android.com/apk/res/android"
android:color=
"@color/selector_grey"
>
<item
android:drawable=
"@color/tab_gb"
/>
</ripple>
\ No newline at end of file
demo/src/main/res/drawable/selector_bg.xml
0 → 100644
浏览文件 @
8a587583
<?xml version="1.0" encoding="utf-8"?>
<selector
xmlns:android=
"http://schemas.android.com/apk/res/android"
>
<item
android:drawable=
"@color/selector_grey"
android:state_pressed=
"true"
/>
<item
android:drawable=
"@color/tab_gb"
/>
</selector>
\ No newline at end of file
demo/src/main/res/layout/activity_main.xml
浏览文件 @
8a587583
...
...
@@ -35,6 +35,8 @@
app:textColorSelected=
"@color/tab_selected_color"
app:itemTextSize=
"8sp"
app:itemMarginTop=
"-5dp"
app:openTouchBg=
"true"
app:touchDrawable=
"@drawable/selector_bg"
/>
<com.chaychan.library.BottomBarItem
...
...
@@ -48,6 +50,8 @@
app:textColorSelected=
"@color/tab_selected_color"
app:itemTextSize=
"8sp"
app:itemMarginTop=
"-5dp"
app:openTouchBg=
"true"
app:touchDrawable=
"@drawable/selector_bg"
/>
...
...
@@ -62,6 +66,8 @@
app:textColorSelected=
"@color/tab_selected_color"
app:itemTextSize=
"8sp"
app:itemMarginTop=
"-5dp"
app:openTouchBg=
"true"
app:touchDrawable=
"@drawable/selector_bg"
/>
<com.chaychan.library.BottomBarItem
...
...
@@ -75,6 +81,8 @@
app:textColorSelected=
"@color/tab_selected_color"
app:itemTextSize=
"8sp"
app:itemMarginTop=
"-5dp"
app:openTouchBg=
"true"
app:touchDrawable=
"@drawable/selector_bg"
/>
</com.chaychan.library.BottomBarLayout>
...
...
demo/src/main/res/values/colors.xml
浏览文件 @
8a587583
...
...
@@ -7,4 +7,5 @@
<color
name=
"tab_gb"
>
#F3F5F4
</color>
<color
name=
"tab_normal_color"
>
#515051
</color>
<color
name=
"tab_selected_color"
>
#D33D3C
</color>
</resources>
library/src/main/java/com/chaychan/library/BottomBarItem.java
浏览文件 @
8a587583
...
...
@@ -2,6 +2,7 @@ package com.chaychan.library;
import
android.content.Context
;
import
android.content.res.TypedArray
;
import
android.graphics.drawable.Drawable
;
import
android.support.annotation.Nullable
;
import
android.util.AttributeSet
;
import
android.view.Gravity
;
...
...
@@ -28,9 +29,14 @@ public class BottomBarItem extends LinearLayout {
private
int
mTextColorNormal
=
0xFF999999
;
//描述文本的默认显示颜色
private
int
mTextColorSelected
=
0xFF46C01B
;
//述文本的默认选中显示颜色
private
int
mMarginTop
=
0
;
//文字和图标的距离,默认0dp
private
boolean
mOpenTouchBg
=
false
;
// 是否开启触摸背景,默认关闭
private
Drawable
mTouchDrawable
;
//触摸时的背景
private
TextView
mTextView
;
private
ImageView
mImageView
;
public
BottomBarItem
(
Context
context
)
{
this
(
context
,
null
);
}
...
...
@@ -56,6 +62,10 @@ public class BottomBarItem extends LinearLayout {
mTextColorSelected
=
ta
.
getColor
(
R
.
styleable
.
BottomBarItem_textColorSelected
,
mTextColorSelected
);
mMarginTop
=
ta
.
getDimensionPixelSize
(
R
.
styleable
.
BottomBarItem_itemMarginTop
,
UIUtils
.
dip2Px
(
mContext
,
mMarginTop
));
mOpenTouchBg
=
ta
.
getBoolean
(
R
.
styleable
.
BottomBarItem_openTouchBg
,
mOpenTouchBg
);
mTouchDrawable
=
ta
.
getDrawable
(
R
.
styleable
.
BottomBarItem_touchDrawable
);
ta
.
recycle
();
checkValues
();
...
...
@@ -73,6 +83,11 @@ public class BottomBarItem extends LinearLayout {
if
(
mIconSelectedResourceId
==
-
1
)
{
throw
new
IllegalStateException
(
"您还没有设置选中状态下的图标,请指定iconSelected的图标"
);
}
if
(
mOpenTouchBg
&&
mTouchDrawable
==
null
){
//如果有开启触摸背景效果但是没有传对应的drawable
throw
new
IllegalStateException
(
"开启了触摸效果,但是没有指定touchDrawable"
);
}
}
private
void
init
()
{
...
...
@@ -92,6 +107,11 @@ public class BottomBarItem extends LinearLayout {
layoutParams
.
topMargin
=
mMarginTop
;
mTextView
.
setLayoutParams
(
layoutParams
);
if
(
mOpenTouchBg
){
//如果有开启触摸背景
setBackground
(
mTouchDrawable
);
}
addView
(
view
);
}
...
...
library/src/main/res/values/attr.xml
浏览文件 @
8a587583
...
...
@@ -15,5 +15,9 @@
<attr
name=
"textColorSelected"
format=
"color"
/>
<!--文字和图标的顶部距离-->
<attr
name=
"itemMarginTop"
format=
"dimension"
/>
<!--是否开启触摸背景效果-->
<attr
name=
"openTouchBg"
format=
"boolean"
/>
<!--设置触摸背景-->
<attr
name=
"touchDrawable"
format=
"reference"
/>
</declare-styleable>
</resources>
\ No newline at end of file
library/src/main/res/values/colors.xml
0 → 100644
浏览文件 @
8a587583
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color
name=
"white"
>
#ffffff
</color>
<color
name=
"selector_grey"
>
#DDDDDD
</color>
</resources>
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录