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

网站正在建设中 打不开怎么办/seo技术自学

网站正在建设中 打不开怎么办,seo技术自学,用php做购物网站,网站编辑工具简介:由于界面View.VISIBLE和View.GONE的动画太生硬,所以写了ExpandLayout类来平滑过渡。 基本思路,动态的设置布局的高度。先上效果图:expand.gif核心动画效果代码/*** 切换动画实现*/private void animateToggle(long animationDuration) {ValueAnimat…

简介:

由于界面View.VISIBLE和View.GONE的动画太生硬,所以写了ExpandLayout类来平滑过渡。 基本思路,动态的设置布局的高度。

先上效果图:

e749cb69af0f

expand.gif

核心动画效果代码

/**

* 切换动画实现

*/

private void animateToggle(long animationDuration) {

ValueAnimator heightAnimation = isExpand ?

ValueAnimator.ofFloat(0f, viewHeight) : ValueAnimator.ofFloat(viewHeight, 0f);

heightAnimation.setDuration(animationDuration / 2);

heightAnimation.setStartDelay(animationDuration / 2);

heightAnimation.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {

@Override

public void onAnimationUpdate(ValueAnimator animation) {

float val = (float) animation.getAnimatedValue();

setViewHeight(layoutView, (int) val);

}

});

heightAnimation.start();

}

使用:

布局文件中 (引入自定义View)

android:id="@+id/expandLayout"

android:layout_width="match_parent"

android:layout_height="wrap_content"

android:background="#FFFF00"

android:clickable="true">

android:layout_width="match_parent"

android:layout_height="wrap_content"

android:gravity="center"

android:padding="15dp"

android:text="大辉儿: 这里是可收缩布局内部" />

java代码中 初始状态是否显示,toggleExpand切换折叠/展开状态

private ExpandLayout mExpandLayout;

public void initExpandView() {

mExpandLayout = (ExpandLayout) findViewById(R.id.expandLayout);

mExpandLayout.initExpand(false);//设定初始化折叠,默认展开

button.setOnClickListener(new View.OnClickListener() {

@Override

public void onClick(View v) {

mExpandLayout.toggleExpand();

}

});

}

下面是全部代码:

布局文件:

xmlns:app="http://schemas.android.com/apk/res-auto"

android:layout_width="match_parent"

android:layout_height="match_parent"

android:orientation="vertical"

android:paddingTop="50dp">

android:id="@+id/button"

android:layout_width="match_parent"

android:layout_height="wrap_content"

android:layout_centerInParent="true"

android:background="#32CD32"

android:text="点击展开/收缩" />

android:id="@+id/expandLayout"

android:layout_width="match_parent"

android:layout_height="wrap_content"

android:background="#FFFF00"

android:clickable="true">

android:layout_width="match_parent"

android:layout_height="wrap_content"

android:gravity="center"

android:padding="15dp"

android:text="大辉儿: 这里是可收缩布局内部" />

自定义View 伸缩布局类:

package com.p.h;

import android.animation.ValueAnimator;

import android.content.Context;

import android.util.AttributeSet;

import android.view.View;

import android.view.ViewGroup;

import android.widget.RelativeLayout;

/**

* Created by : Pan_Hui on

* Time: 2020/07/27 13:14

* 带过渡动画的折叠收缩布局

*/

public class ExpandLayout extends RelativeLayout {

public ExpandLayout(Context context) {

this(context, null);

}

public ExpandLayout(Context context, AttributeSet attrs) {

this(context, attrs, 0);

}

public ExpandLayout(Context context, AttributeSet attrs, int defStyle) {

super(context, attrs, defStyle);

initView();

}

private View layoutView;

private int viewHeight;

private boolean isExpand;

private long animationDuration;

private boolean lock;

private void initView() {

layoutView = this;

isExpand = true;

animationDuration = 300;

setViewDimensions();

}

/**

* @param isExpand 初始状态是否折叠

*/

public void initExpand(boolean isExpand) {

this.isExpand = isExpand;

setViewDimensions();

}

/**

* 设置动画时间

*

* @param animationDuration 动画时间

*/

public void setAnimationDuration(long animationDuration) {

this.animationDuration = animationDuration;

}

/**

* 获取subView的总高度

* View.post()的runnable对象中的方法会在View的measure、layout等事件后触发

*/

private void setViewDimensions() {

layoutView.post(new Runnable() {

@Override

public void run() {

if (viewHeight <= 0) {

viewHeight = layoutView.getMeasuredHeight();

}

setViewHeight(layoutView, isExpand ? viewHeight : 0);

}

});

}

public static void setViewHeight(View view, int height) {

final ViewGroup.LayoutParams params = view.getLayoutParams();

params.height = height;

view.requestLayout();

}

/**

* 切换动画实现

*/

private void animateToggle(long animationDuration) {

ValueAnimator heightAnimation = isExpand ?

ValueAnimator.ofFloat(0f, viewHeight) : ValueAnimator.ofFloat(viewHeight, 0f);

heightAnimation.setDuration(animationDuration / 2);

heightAnimation.setStartDelay(animationDuration / 2);

heightAnimation.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {

@Override

public void onAnimationUpdate(ValueAnimator animation) {

int value = (int) (float) animation.getAnimatedValue();

setViewHeight(layoutView, value);

if (value == viewHeight || value == 0) {

lock = false;

}

}

});

heightAnimation.start();

lock = true;

}

public boolean isExpand() {

return isExpand;

}

/**

* 折叠view

*/

public void collapse() {

isExpand = false;

animateToggle(animationDuration);

}

/**

* 展开view

*/

public void expand() {

isExpand = true;

animateToggle(animationDuration);

}

public void toggleExpand() {

if (lock) {

return;

}

if (isExpand) {

collapse();

} else {

expand();

}

}

}

MainActivity中绑定使用自定义View

package com.p.h;

import androidx.appcompat.app.AppCompatActivity;

import android.os.Bundle;

import android.view.View;

import android.widget.Button;

public class MainActivity extends AppCompatActivity {

private Button button;

private ExpandLayout mExpandLayout;

@Override

protected void onCreate(Bundle savedInstanceState) {

super.onCreate(savedInstanceState);

setContentView(R.layout.activity_main);

button = (Button) findViewById(R.id.button);

//初始化展开View

initExpandView();

}

public void initExpandView() {

mExpandLayout = (ExpandLayout) findViewById(R.id.expandLayout);

//初始状态是否折叠false 否 true 是

mExpandLayout.initExpand(false);

button.setOnClickListener(new View.OnClickListener() {

@Override

public void onClick(View v) {

mExpandLayout.toggleExpand();

}

});

}

}

最近有点忙,没时间更新 抱歉~~~

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

相关文章:

  • 网站建设源程序清单/网站seo价格
  • 附近的广告设计和制作/网站首页排名seo搜索优化
  • 电子商务网站建设的问题/百度seo排名优化教程
  • wordpress markdown 语法高亮/整站seo排名外包
  • 铁威马怎样做网站服务器/百度网盘破解版
  • 可以做日语翻译的兼职网站/长沙seo网络优化
  • 做外国的网站卖东西/厦门谷歌推广
  • 网站备案审核需要多久/网络上市场推广
  • 大沥网站设计/账号权重查询入口站长工具
  • 关于做摄影的网站/网站优化推广服务
  • 如何安装wordpress手机站导航/重庆seo网站收录优化
  • 影视广告创意拍摄/上海优化网站seo公司
  • 沈阳专业的网站设计公司/网络推广外包公司哪家好
  • 百度网盟 网站定向投放/宁波网站关键词排名推广
  • 做h游戏视频网站有哪些/百度搜索风云榜排名
  • 网站专题策划方案/小说推文万能关键词
  • 深圳设计网站公司网站/下拉框关键词软件
  • 网页界面设计教程视频/seo搜索引擎优化招聘
  • mt7620a做网站/电子商务网站设计方案
  • 怎么搭建自己的网站挣钱/手机网站优化排名
  • wordpress 主题评论/南宁seo网络推广
  • 潜江网站设计公司/如何做网页制作
  • 志愿服务网站建设方案/长春网站seo哪家好
  • 成都住建局官网官网官方/上海seo推广整站
  • 网站配置到iis后读不了数据/在线生成个人网站免费
  • 武汉在建项目一览表/百度seo标题优化软件
  • 科技网站建设分析/补肾壮阳吃什么药效果好
  • 零代码开发/信阳seo推广
  • 国外特效网站/站长工具平台
  • 域名服务器ip/麒麟seo
  • VScode 使用遇到的问题
  • 论文学习24:Boundary-Sensitive Segmentation of SmallLiver Lesions
  • 补充日志之-配置文件解析指南(Centos7)
  • 【测试工具】JMeter基本使用及MySQL数据库压力测试
  • Flinksql bug: Heartbeat of TaskManager with id container_XXX timed out.
  • python+vue扫盲