android控件名,介绍一个名为Dragger的android控件

前言

最近在做一个项目的时候要求使用一个弹出的效果,正好遇见如下的一个效果,

14e11e80f5f5

感觉效果很好看就用了

项目地址如下:Dragger

开始使用:(开发环境为Android Studio)

在你的build.gradle文件中添加如下内容

repositories {

maven {

url "https://jitpack.io"

}

}

dependencies {

compile 'com.github.ppamorim:dragger:1.2'

}

新建一个Main2Activity

activity_main2.xml

android:layout_width="match_parent"

android:layout_height="match_parent"

android:background="@color/white">

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"/>

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
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值