仿抖音底部导航(二)
继续实现仿抖音底部导航
今天要实现效果如下图
首先在原基础的布局中加入一个ImageView
<LinearLayout
android:layout_width="wrap_content"
android:orientation="vertical"
android:id="@+id/nav_top"
android:layout_centerInParent="true"
android:layout_height="wrap_content">
<TextView
android:layout_width="wrap_content"
android:text="标题"
android:id="@+id/nav_item_tv_title"
android:textColor="#F1F1F1"
android:textSize="16sp"
android:layout_height="wrap_content" />
<!--新加入的-->
<ImageView
android:id="@+id/reflash"
android:layout_width="25dp"
android:src="@mipmap/shuaxin"
android:visibility="gone"
android:layout_centerInParent="true"
android:layout_height="25dp" />
</LinearLayout>
这里附上刷新的图片素材
然后在原代码中进行修改以实现导航的动画及刷新功能
1.添加是否显示刷新图片的标记
//默认设为flase
private boolean isShowReflashImage=false;
//并添加set方法
public void setShowReflashImage(boolean showReflashImage) {
isShowReflashImage = showReflashImage;
}
2.然后修改激活和取消激活的方法
public void startActive(){
//根据上一步添加的标记来判断是否显示ImageView
if(isShowReflashImage){
textView_title.setVisibility(GONE);
imageView_Shuaxin.setVisibility(VISIBLE);
}else {
textView_title.setTextColor(Color.WHITE);
textView_title.setTextSize(18);
}
textView_line.animate().alpha(1).setDuration(200).start();
}
public void cancelActive(){
if(isShowReflashImage){
textView_title.setVisibility(VISIBLE);
imageView_Shuaxin.setVisibility(GONE);
textView_line.setAlpha(0);
}else {
textView_title.setTextColor(Color.parseColor("#F1F1F1"));
textView_title.setTextSize(16);
}
textView_line.animate().alpha(0).setDuration(200).start();
}
3.给负责刷新的ImageView添加旋转动画
private void initListener() {
final Animation rotateAnimation = new RotateAnimation(0,-360,Animation.RELATIVE_TO_SELF,0.5f,Animation.RELATIVE_TO_SELF,0.5f);
rotateAnimation.setDuration(300);
imageView_Shuaxin.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
imageView_Shuaxin.startAnimation(rotateAnimation);
}
});
}
4.最后加上刷新事件
1)新建NavItemReflashListener
public interface NavItemReflashListener {
void onReflash(View v);
}
2)给NavItemView加上NavItemReflashListener属性并设置set方法
public void setNavItemReflashListener(NavItemReflashListener navItemReflashListener) {
this.navItemReflashListener = navItemReflashListener;
}
3)在imageView_Shuaxin的点击事件中调用onReflash(View v)方法
imageView_Shuaxin.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
imageView_Shuaxin.startAnimation(rotateAnimation);
if(navItemReflashListener!=null){
navItemReflashListener.onReflash(v);
}
}
});
5.在MainActivity中将想要显示刷新控件的NavItemView设置ShowReflashImagewei为true并加上刷新事件
navItemView1.setShowReflashImage(true);
navItemView1.setNavItemReflashListener(new NavItemReflashListener() {
@Override
public void onReflash(View v) {
Toast.makeText(MainActivity.this, "刷新", Toast.LENGTH_SHORT).show();
}
});
最后附上完整代码https://gitee.com/itfittnesss/DouYin

低调大师中文资讯倾力打造互联网数据资讯、行业资源、电子商务、移动互联网、网络营销平台。
持续更新报道IT业界、互联网、市场资讯、驱动更新,是最及时权威的产业资讯及硬件资讯报道平台。
转载内容版权归作者及来源网站所有,本站原创内容转载请注明来源。
-
上一篇
2018 Google I/O 开发者大会发布的那些新技术
本文为转载文章,原文地址:https://mp.weixin.qq.com/s?__biz=MzAwODY4OTk2Mg==&mid=2652046210&idx=1&sn=f5f17891c8fb45bb975c27072da5f35b&chksm=808ca3c7b7fb2ad1fd7360f71fe42a4737722ab1aed77994d3f9c67632dd5f7863fa0f32c256&mpshare=1&scene=23&srcid=05091aqpmdfrg9gC45fLiETD%23rd Android 在过去的十年经历了指数级的增长,同时,我们也见证了开发者社区的蓬勃发展。在中国、印度和巴西等国家,使用官方 IDE 的开发者数目两年内几乎增至了 3 倍。正是因为如此强劲的增长,我们感到担负起更大的责任,要为开发者带来更好的体验并为此做出大力的投资。基于来自广大开发者的反馈,我们着重精力打造出快速、简便的移动端开发,助力开发者设计更为轻量的 app 以吸引更多用户,并提高用户参与度及留存率。此外,我们也非常高...
-
下一篇
NGcodec谈FPGA编码与HEVC和AV1
随着HEVC、AV1等更复杂算法的Codec份额逐步增长,实现高质量视频编解码需要硬件支持,软件的方式无论在服务器端和移动端都非最佳的方案。FPGA专用芯片能够降低延迟和成本。在NAB 2018大会上,资深多媒体技术咨询师Jan Ozer对Ngcodec的CEO Oliver Gunasekara进行了访谈,谈及了硬件编码在HEVC、VP9及AV1上的现状与未来。LiveVideoStack对文章进行了摘译。 文/ Jan Ozer 译 / 金歌 审校 / Ant 原文:http://www.streamingmedia.com/Articles/Editorial/Featured-Articles/NAB-2018-NGcodec-Talks-FPGA-Accelerated-Encoding-124398.aspx Jan Ozer: 可以给我讲讲你们在NAB上展示的内容么? Oliver Gunasekara: 我们公司在做视频编码技术,以及下一代视频压缩技术。这里展示的是世界上性能最强的HEVC和VP9直播视频编码器。 Jan Ozer: “性能最强”这个词我今天已经听了不下...
相关文章
文章评论
共有0条评论来说两句吧...
文章二维码
点击排行
推荐阅读
最新文章
- SpringBoot2初体验,简单认识spring boot2并且搭建基础工程
- Docker容器配置,解决镜像无法拉取问题
- Docker安装Oracle12C,快速搭建Oracle学习环境
- CentOS8,CentOS7,CentOS6编译安装Redis5.0.7
- Docker快速安装Oracle11G,搭建oracle11g学习环境
- 2048小游戏-低调大师作品
- SpringBoot2编写第一个Controller,响应你的http请求并返回结果
- Docker使用Oracle官方镜像安装(12C,18C,19C)
- SpringBoot2整合MyBatis,连接MySql数据库做增删改查操作
- MySQL数据库在高并发下的优化方案