最新《RabbitMQ消息中间件技术精讲》

public static void main(String[] args) {
        //使用DateTimeFormatter获取当前周数
        DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern("w");
        //2018年第一天
        System.out.println(LocalDateTime.of(2018, 1, 1, 0, 0, 0).format(dateTimeFormatter));
        //2018年最后一天
        System.out.println(LocalDateTime.of(2018, 12, 31, 0, 0, 0).format(dateTimeFormatter));
        //2019年第一天
        System.out.println(LocalDateTime.of(2019, 1, 1, 0, 0, 0).format(dateTimeFormatter));
        //2019年最后一天
        System.out.println(LocalDateTime.of(2019, 12, 31, 0, 0, 0).format(dateTimeFormatter));
        //这天是星期六
        System.out.println(LocalDateTime.of(2019, 4, 6, 0, 0, 0).format(dateTimeFormatter));
        //这天是星期日
        System.out.println(LocalDateTime.of(2019, 4, 7, 0, 0, 0).format(dateTimeFormatter));
        //这天是星期一
        System.out.println(LocalDateTime.of(2019, 4, 8, 0, 0, 0).format(dateTimeFormatter));
    }
public static void main(String[] args) {
        //使用DateTimeFormatter获取当前周数
        WeekFields weekFields = WeekFields.of(DayOfWeek.MONDAY,1);
        //2018年第一天
        System.out.println(LocalDateTime.of(2018, 1, 1, 0, 0, 0).get(weekFields.weekOfYear()));
        //2018年最后一天
        System.out.println(LocalDateTime.of(2018, 12, 31, 0, 0, 0).get(weekFields.weekOfYear()));
        //2019年第一天
        System.out.println(LocalDateTime.of(2019, 1, 1, 0, 0, 0).get(weekFields.weekOfYear()));
        //2019年最后一天
        System.out.println(LocalDateTime.of(2019, 12, 31, 0, 0, 0).get(weekFields.weekOfYear()));
        //这天是星期六
        System.out.println(LocalDateTime.of(2019, 4, 6, 0, 0, 0).get(weekFields.weekOfYear()));
        //这天是星期日
        System.out.println(LocalDateTime.of(2019, 4, 7, 0, 0, 0).get(weekFields.weekOfYear()));
        //这天是星期一
        System.out.println(LocalDateTime.of(2019, 4, 8, 0, 0, 0).get(weekFields.weekOfYear()));
    }

书籍打开动画的思路.png

  1. 获取RecyclerView(或GridView)中的子View里面的ImageView在屏幕的位置,因为获取的是Window下的位置,所以Y轴位置取出来还要减去状态栏的高度

  2. 图书的封面和内容页(其实是两个ImageView)设置成刚刚取出的子View里面的ImageView的位置和大小。

  3. 设置动画,这边缩放动画的轴心点的计算方式需要注意一下,等下文讲解代码的时候再具体解释,还有就是利用Camera类(非平常的相机类)实现的打开和关闭动画(如果你对Camera不熟悉,建议先看GcsSloop大佬的这篇Matrix Camera)。

三. 具体实现

我会在这个过程中一步一步教你如何实现这个效果:

1. 布局


activity_open_book.xml:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".ui.activity.OpenBookActivity">

    <android.support.v7.widget.RecyclerView
        android:id="@+id/recycle"
        android:layout_width="match_parent"
        android:layout_height="match_parent"/>

    <ImageView
        android:id="@+id/img_content"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:visibility="gone"
        android:contentDescription="@string/app_name" />

    <ImageView
        android:id="@+id/img_first"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:scaleType="centerCrop"
        android:visibility="gone"
        android:contentDescription="@string/app_name" />

</RelativeLayout>
 

猜你喜欢

转载自blog.csdn.net/beikai123456/article/details/89181054