当前位置: 首页 > news >正文

公司网站建设 入账互联网营销推广

公司网站建设 入账,互联网营销推广,中央农村工作会议2023全文,做淘宝客优惠券网站还是APP赚钱转载请注明出处 http://blog.csdn.net/xiaoyuan511https://blog.csdn.net/xiaoyuan511/article/details/53146514一、概述 现在大多数的电商APP的详情页长得几乎都差不多,几乎都是上面一个商品的图片,当你滑动的时候,会有Tab悬浮在上面&#…

转载请注明出处 http://blog.csdn.net/xiaoyuan511

https://blog.csdn.net/xiaoyuan511/article/details/53146514

一、概述

现在大多数的电商APP的详情页长得几乎都差不多,几乎都是上面一个商品的图片,当你滑动的时候,会有Tab悬浮在上面,这样做用户体验确实不错,如果Tab滑上去,用户可能还需要滑下来,在来点击Tab,这样确实很麻烦。沉浸式状态栏那,郭霖说过谷歌并没有给出沉浸式状态栏这个明白,谷歌只说了沉浸式模式(Immersive Mode)。不过沉浸式状态栏这个名字其实听不粗,随大众吧,但是Android的环境并没有IOS环境一样特别统一,比如华为rom的跟小米rom的虚拟按键完全不一样,所有Android开发者不容易。。。。。

二、淘宝的效果

这里写图片描述

三、我们的效果

这里写图片描述 
只能传2M,把我的美女都给压失真了。。。。。。

四、实现类

  • 自定义ScrollView (StickyScrollView)

  • StatusBarUtil //非常不错的状态栏工具

五、布局

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"><FrameLayoutandroid:layout_width="match_parent"android:layout_height="match_parent"><com.xiaoyuan.StickyScrollViewandroid:id="@+id/scrollView"android:layout_width="match_parent"android:layout_height="match_parent"android:focusable="true"android:focusableInTouchMode="true"><LinearLayoutandroid:id="@+id/ll_content"android:layout_width="match_parent"android:layout_height="match_parent"android:orientation="vertical"><ImageViewandroid:layout_width="match_parent"android:layout_height="500dip"android:background="@mipmap/meinv"/><TextViewandroid:id="@+id/title"android:layout_width="match_parent"android:layout_height="50dp"android:gravity="center"android:text="美" /><TextViewandroid:layout_width="match_parent"android:layout_height="50dip"android:gravity="center"android:text="女"/><TextViewandroid:layout_width="match_parent"android:layout_height="50dip"android:gravity="center"android:text="美"/><TextViewandroid:layout_width="match_parent"android:layout_height="50dip"android:gravity="center"android:text="不"/><TextViewandroid:layout_width="match_parent"android:layout_height="50dip"android:gravity="center"android:text="美"/><LinearLayoutandroid:layout_width="match_parent"android:layout_height="wrap_content"android:orientation="vertical"android:tag="sticky"><LinearLayoutandroid:layout_width="match_parent"android:layout_height="45dp"android:background="#ffffff"android:orientation="horizontal"><TextViewandroid:id="@+id/infoText"android:layout_width="0dp"android:layout_height="match_parent"android:layout_weight="1"android:gravity="center"android:text="美女信息"android:textColor="#000000"android:textSize="16dp" /><TextViewandroid:id="@+id/secondText"android:layout_width="0dp"android:layout_height="match_parent"android:layout_weight="1"android:gravity="center"android:text="美女介绍"android:textColor="#000000"android:textSize="16dp" /></LinearLayout></LinearLayout><FrameLayoutandroid:id="@+id/tabMainContainer"android:layout_width="match_parent"android:layout_height="wrap_content"android:background="#ffffff"android:minHeight="400dp"></FrameLayout></LinearLayout></com.xiaoyuan.StickyScrollView><RelativeLayoutandroid:id="@+id/ll_good_detail"android:layout_width="match_parent"android:layout_height="49dp"android:background="#00000000"android:paddingTop="@dimen/spacing_normal"><TextViewandroid:layout_width="wrap_content"android:layout_height="wrap_content"android:textColor="#ffffff"android:layout_alignParentLeft="true"android:layout_marginLeft="10dip"android:layout_centerHorizontal="true"android:text="返回"/><TextViewandroid:layout_width="wrap_content"android:layout_height="wrap_content"android:textColor="#ffffff"android:layout_centerInParent="true"android:layout_centerHorizontal="true"android:layout_marginLeft="10dip"android:text="美女"/><TextViewandroid:layout_width="wrap_content"android:layout_height="wrap_content"android:textColor="#ffffff"android:layout_alignParentRight="true"android:layout_marginRight="10dip"android:layout_centerHorizontal="true"android:text="分享"/></RelativeLayout></FrameLayout></RelativeLayout>

注意:我们把要悬浮的Tab设置了android:tag=”sticky”这样的属性

六、实现代码

public class MainActivity extends AppCompatActivity implements View.OnClickListener, StickyScrollView.OnScrollChangedListener {TextView oneTextView, twoTextView;
private StickyScrollView stickyScrollView;
private int height;
private LinearLayout llContent;
private RelativeLayout llTitle;
private FrameLayout frameLayout;
private TextView title;@Override
protected void onCreate(Bundle savedInstanceState) {super.onCreate(savedInstanceState);setContentView(R.layout.activity_main);initView();initListeners();}/*** 初始化View*/
private void initView() {stickyScrollView = (StickyScrollView) findViewById(R.id.scrollView);frameLayout = (FrameLayout) findViewById(R.id.tabMainContainer);title = (TextView) findViewById(R.id.title);oneTextView = (TextView) findViewById(R.id.infoText);llContent = (LinearLayout) findViewById(R.id.ll_content);llTitle = (RelativeLayout) findViewById(R.id.ll_good_detail);oneTextView.setOnClickListener(this);twoTextView = (TextView) findViewById(R.id.secondText);twoTextView.setOnClickListener(this);stickyScrollView.setOnScrollListener(this);StatusBarUtil.setTranslucentForImageView(MainActivity.this, 0, title);FrameLayout.LayoutParams params = (FrameLayout.LayoutParams) llTitle.getLayoutParams();params.setMargins(0, getStatusHeight(), 0, 0);llTitle.setLayoutParams(params);//默认设置一个FrggetSupportFragmentManager().beginTransaction().replace(R.id.tabMainContainer, Fragment.newInstance()).commit();
}/*** 获取状态栏高度* @return*/
private int getStatusHeight() {int resourceId = MainActivity.this.getResources().getIdentifier("status_bar_height", "dimen", "android");return getResources().getDimensionPixelSize(resourceId);}@Override
public void onClick(View v) {if (v.getId() == R.id.infoText) {getSupportFragmentManager().beginTransaction().replace(R.id.tabMainContainer, Fragment.newInstance()).commit();} else if (v.getId() == R.id.secondText) {getSupportFragmentManager().beginTransaction().replace(R.id.tabMainContainer, Fragment1.newInstance()).commit();}
}private void initListeners() {//获取内容总高度final ViewTreeObserver vto = llContent.getViewTreeObserver();vto.addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {@Overridepublic void onGlobalLayout() {height = llContent.getHeight();//注意要移除llContent.getViewTreeObserver().removeGlobalOnLayoutListener(this);}});//获取Fragment高度ViewTreeObserver viewTreeObserver = frameLayout.getViewTreeObserver();viewTreeObserver.addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {@Overridepublic void onGlobalLayout() {height = height - frameLayout.getHeight();//注意要移除frameLayout.getViewTreeObserver().removeGlobalOnLayoutListener(this);}});//获取title高度ViewTreeObserver viewTreeObserver1 = llTitle.getViewTreeObserver();viewTreeObserver1.addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {@Overridepublic void onGlobalLayout() {height = height - llTitle.getHeight() - getStatusHeight();//计算滑动的总距离stickyScrollView.setStickTop(llTitle.getHeight() + getStatusHeight());//设置距离多少悬浮//注意要移除llTitle.getViewTreeObserver().removeGlobalOnLayoutListener(this);}});}@Override
public void onScrollChanged(int l, int t, int oldl, int oldt) {if (t <= 0) {llTitle.setBackgroundColor(Color.argb((int) 0, 255, 255, 255));StatusBarUtil.setTranslucentForImageView(MainActivity.this, 0, title);} else if (t > 0 && t <= height) {float scale = (float) t / height;int alpha = (int) (255 * scale);llTitle.setBackgroundColor(Color.argb((int) alpha, 227, 29, 26));//设置标题栏的透明度及颜色StatusBarUtil.setTranslucentForImageView(MainActivity.this, alpha, title);//设置状态栏的透明度} else {llTitle.setBackgroundColor(Color.argb((int) 255, 227, 29, 26));StatusBarUtil.setTranslucentForImageView(MainActivity.this, 255, title);}
}}

注意:stickyScrollView.setStickTop(int height)我们通过这个方法可以设置Tab距离多高开始悬浮

我们通过监听ScrollView滑动距离来不断改变我们标题栏跟状态栏的透明度来达到效果,在这里我们计算了几个高度(滑动距离)。最后来算出滑动总距离,根据滑动的距离跟滑动的总距离来算出透明度的数值。

StatusBarUtil.setTranslucentForImageView(MainActivity.this, 0, title);我们通过工具来实现图片深入状态栏。里面的传的View是图片下面的View。

六、总结

效果倒是不错,美女也不错、但是在Android4.4之前根本就没有沉浸式这个东西,大家可以下载源码来研究。自己动手实现一遍记得比较清楚。工作了。太忙了。最后感谢一下dota群的高叔(博客地址不知道)提供思路。

七、源码

csdn下载 
githu下载

八、欢迎大家访问我的网站和我的公众号

极客导航—程序员自己的导航网站

极客导航

欢迎关注我的公众号 
关注我

http://www.lbrq.cn/news/2556307.html

相关文章:

  • 网站做迅雷下载链接关键词上首页软件
  • 凡科网站是什么做的网络优化工程师前景
  • 模板网站如何大量复制上线快速关键词排名首页
  • 华容网站定制如何做企业网页
  • 网站制作容易吗软件推广
  • 个人注册公司费用简述seo的优化流程
  • 怎样做企业的网站广州市口碑seo推广外包
  • 手机有软件做ppt下载网站有哪些内容国外网页模板
  • 江门网站建设开发广州seo优化外包公司
  • 成都专业网站制作多少钱企点qq
  • 做网站的镜像是什么意思网站百度权重查询
  • 品牌型网站建设方案模板免费下载网站
  • 有哪些做平面设计好的网站有哪些500强企业seo服务商
  • 新乡网站制作2345浏览器下载安装
  • 微站是什么网络营销案例
  • 怎么做网站链接的快捷方式广西百度seo
  • 湖南响应式网站建设费用站长网站统计
  • 天津做app和网站的公司网站建设教程
  • 校园局域网站建设费用效果好的东莞品牌网站建设
  • 苏州建行网站首页太原网站排名推广
  • 徐州免费建站模板抖音seo查询工具
  • 小说盗版网站怎么做的让手机变流畅的软件下载
  • 网站的新闻栏与产品栏如何做seo建站营销
  • 德州网站建设推广价格长春网站优化哪家好
  • wordpress显示多页选项快速seo排名优化
  • 做MAD生肉网站怎么让百度搜索靠前
  • 商务网站欣赏佛山网站建设十年乐云seo
  • php网站只能打开首页网络营销促销方案
  • 泉州3d建模培训威海seo
  • 哈尔滨网站建设费用如何优化网络环境
  • 在线免费的AI文本转语音工具TTSMaker介绍
  • 【Kubernetes 指南】基础入门——Kubernetes 集群(二)
  • 从O(n²)到O(n log n):深度剖析快速排序的内存优化与cache-friendly实现
  • es的histogram直方图聚合和terms分组聚合
  • linux git ssh配置过程
  • React中的this绑定