android:textSize=“26sp”
android:text=“抽屉的内容”/>
<Button
android:layout_width=“match_parent”
android:layout_height=“wrap_content”
android:text=“我是打酱油的”
android:background="#ff00ff"
/>
Activity中的实现效果的代码:(透明动画)
Activity代码如下:
public class MyDemo extends AppCompatActivit
《Android学习笔记总结+最新移动架构视频+大厂安卓面试真题+项目实战源码讲义》
【docs.qq.com/doc/DSkNLaERkbnFoS0ZF】 完整内容开源分享
y {
private ImageView demo_lv_up1;
private ImageView demo_lv_up2;
private LinearLayout demo_ll_handle;
private RelativeLayout demo_ll_content;
private SlidingDrawer demo_sd;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_my_demo);
initView();
//动画的实现
initAnimation();
//抽屉的点击事件
setOnDrawerListener();
}
private void initView() {
demo_lv_up1 = (ImageView) findViewById(R.id.demo_lv_up1);
demo_lv_up2 = (ImageView) findViewById(R.id.demo_lv_up2);
demo_ll_handle = (LinearLayout) findViewById(R.id.demo_ll_handle);
demo_ll_content = (RelativeLayout) findViewById(R.id.demo_ll_content);
demo_sd = (SlidingDrawer) findViewById(R.id.demo_sd);
}
//动画的实现
private void initAnimation() {
demo_lv_up1.setImageResource(R.mipmap.drawer_arrow_up);
demo_lv_up2.setImageResource(R.mipmap.drawer_arrow_up);
//半透明-不透明
AlphaAnimation animation = new AlphaAnimation(0.2f, 1.0f);
animation.setDuration(500);
animation.setRepeatCount(Animation.INFINITE);
animation.setRepeatMode(Animation.REVERSE);
demo_lv_up1.startAnimation(animation);
//不透明-半透明
AlphaAnimation animation1 = new AlphaAnimation(1.0f, 0.2f);
animation1.setDuration(500);
animation1.setRepeatCount(Animation.INFINITE);
animation1.setRepeatMode(Animation.REVERSE);
demo_lv_up2.startAnimation(animation1);
}
//抽屉的点击事件
private void setOnDrawerListener() {
//打开抽屉
demo_sd.setOnDrawerOpenListener(new SlidingDrawer.OnDrawerOpenListener() {
@Override
public void onDrawerOpened() {
//关闭动画,改变箭头方向
closeAnimation();
}
});
demo_sd.setOnDrawerCloseListener(new SlidingDrawer.OnDrawerCloseListener() {
@Override
public void onDrawerClosed() {
//改变箭头方向,开启动画
initAnimation();
}
});
}
//关闭动画且改变箭头方向
private void closeAnimation() {
demo_lv_up1.clearAnimation();
demo_lv_up2.clearAnimation();
//改变箭头方向
demo_lv_up1.setImageResource(R.mipmap.drawer_arrow_down);