介绍一个名为dragger的android控件
来源:互联网 发布:淘宝禁售商品管理规范 编辑:程序博客网 时间:2024/05/19 15:43
前言
最近在做一个项目的时候要求使用一个弹出的效果,正好遇见如下的一个效果,
感觉效果很好看就用了
项目地址如下:Dragger
开始使用:(开发环境为Android Studio)
- 在你的build.gradle文件中添加如下内容
repositories { maven { url "https://jitpack.io" }}
dependencies { compile 'com.github.ppamorim:dragger:1.2'}
- 新建一个Main2Activity
activity_main2.xml
<?xml version="1.0" encoding="utf-8"?><FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:background="@color/white"> <ImageView android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center" android:padding="16dp" android:src="@mipmap/dragger" android:background="@color/gray"/></FrameLayout>
Main2Activity.java
public class Main2Activity extends DraggerActivity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main2); DraggerView draggerView = (DraggerView) findViewById(R.id.dragger_view); draggerView.setDraggerPosition(DraggerPosition.BOTTOM); }}
- 修改MainActivity.java
在activity_main.xml中添加一个button后在MainActivity.java里面添加如下代码
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); Button btn = (Button) findViewById(R.id.btn); btn.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { Intent intent = new Intent(MainActivity.this, Main2Activity.class); startActivity(intent); } }); }
解释
新建的Main2Activity其实就是那个效果中弹出的Activity,通过MainActivity中的按钮跳转到Main2Activity后执行
draggerView的setDraggerPosition的方法,其中参数为DraggerPosition.BOTTOM表示的是向下弹出,其他几种详见官方的例子
一些其他可以使用的方法
setDraggerCallback(DraggerCallback) //Interface that's provides some infos of the animation.setSlideEnabled(boolean) //Enable or disable the drag, useful to use with ScrollViews.setHorizontalDragRange(float) //Draggable distance that the draggableView can use, horizontally.setVerticalDragRange(float) //Draggable distance that the draggableView can use, vertically.setRunAnimationOnFinishInflate(boolean) //Run the initial animation, useful if you only want the drag function.setDraggerLimit(float) //Set the max limit drag, default is 0.5 (center of the screen).setDraggerPosition(DraggerPosition) //Set the position of archor.setTension(float) //Tension of the animation. This represent with the friction, how much time the animation will be executed.setFriction(float) //Friction of the animation. This represent with the tension, how much friction is applied at the tension animation.show() //Show the drag view with Rebound animation.closeActivity() //Simply close the activity with Rebound animation, based of the DraggerPosition choosen.
阅读全文
0 0
- 介绍一个名为dragger的android控件
- android studio 配置dragger
- Android 之dragger使用
- Android提供了一个名为SQLiteDatabase的类
- C#源代码—在windows窗体中添加一个名为lblShow的Lable控件
- C#源代码—在windows窗体中添加一个名为lblShow的Lable控件2
- C#源代码—在windows窗体中添加一个名为lblShow的Lable控件3
- 一个ObjectDataSource 控件,该控件从名为 AuthorsDB 的数据访问层组件公开数据(代码示例)
- 发现一个名为“Douyu”的国人项目
- 编写一个名为checking的脚步
- 【Windows一个名为“安全模式”的平台】
- 定义一个名为CPerson的类
- 新建一个名为books的XML文件
- 请添加一个名为 jquery 的 scriptresourcemapping
- 设计一个名为Account的类
- 一个名为小七的女子
- 设计一个名为MyPoint的类
- 设计一个名为Circle2D的类
- promise.then,process.nextTick, setTimeout 以及 setImmediate 的执行顺序
- H指数计算
- HihoCoder ——1305
- Java数据类型之时间
- maven 命令
- 介绍一个名为dragger的android控件
- 读取字符串中的数字
- 弱校胡策 银魂
- 单例模式应用之聊天界面
- 树状数组
- R语言数据挖掘(3)——关联分析
- Numpy学习笔记
- 机器学习
- binbinyang---Android的Menu同时显示Title的文字和图片,并且动态变化Title的坑(有二个解决办法,亲测)