Skip to content

Latest commit

 

History

History
162 lines (135 loc) · 5.43 KB

README.md

File metadata and controls

162 lines (135 loc) · 5.43 KB

自定义View集合

Basic_Opreation

ZoomHoverView

click to zoom in and float view 点击放大悬浮的自定义View

ZoomHoverView

Usage

ZoomHoverView

layout:

<com.zyyoona7.customviewsets.zoom_hover.ZoomHoverView
    android:id="@+id/zoom_hover_view"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:background="@color/colorPrimary"
    android:layout_gravity="center"
    zhv:zhv_column_num="5"
    zhv:zhv_divider="5dp"
    zhv:zhv_margin_parent="30dp"
    zhv:zhv_zoom_duration="200"
    zhv:zhv_zoom_to="1.5">

</com.zyyoona7.customviewsets.zoom_hover.ZoomHoverView>

java

      mAdapter = new TestZoomHoverAdapter(mList);
      final SimpleArrayMap<Integer, Integer> map = new SimpleArrayMap<>();
      map.put(0, 2);
      mZoomHoverView.setSpan(map);
      mZoomHoverView.setAdapter(mAdapter);
      //设置动画监听
      mZoomHoverView.setOnZoomAnimatorListener(new OnZoomAnimatorListener() {
          @Override
          public void onZoomInStart(View view) {
              //放大动画开始
              view.setBackground(getResources().getDrawable(android.R.drawable.dialog_holo_light_frame));
          }

          @Override
          public void onZoomInEnd(View view) {

          }

          @Override
          public void onZoomOutStart(View view) {
              //缩小动画开始
          }

          @Override
          public void onZoomOutEnd(View view) {
              view.setBackgroundColor(getResources().getColor(R.color.colorAccent));
          }
      });

      mZoomHoverView.setOnItemSelectedListener(new OnItemSelectedListener() {
          @Override
          public void onItemSelected(View view, int position) {
              Toast.makeText(ZoomHoverActivity.this,"selected position="+position,Toast.LENGTH_SHORT).show();
          }
      });
      
      //设置放大动画插值器
      mZoomHoverView.setZoomInInterpolator(interpolator);
      //设置缩小动画插值器
      mZoomHoverView.setZoomOutInterpolator(interpolator);
      //同时设置两个动画的插值器
      mZoomHoverView.setZoomInterpolator(interpolator);
      //设置选中的item
      mZoomHoverView.setSelectedItem(position);

ZoomHoverGridView

layout

<com.zyyoona7.customviewsets.zoom_hover.ZoomHoverGridView
      android:id="@+id/zoom_hover_grid_view"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:background="@color/colorPrimary"
      zhv:zhv_column_num="7"
      zhv:zhv_divider="5dp"
      zhv:zhv_margin_parent="50dp"
      zhv:zhv_zoom_duration="200"
      zhv:zhv_zoom_to="1.5"
      zhv:zhv_use_baseWH="true"
      zhv:zhv_base_width="70dp"
      zhv:zhv_base_height="70dp">

</com.zyyoona7.customviewsets.zoom_hover.ZoomHoverGridView>

java

mZoomHoverGridView.addSpanItem(0, 1, 2);
mZoomHoverGridView.addSpanItem(3, 2, 2);
mZoomHoverGridView.addSpanItem(4, 2, 1);
mZoomHoverGridView.addSpanItem(5, 1, 3);

mZoomHoverGridView.setAdapter(mAdapter);

自定义属性

<declare-styleable name="ZoomHoverView">
      <!--每行多少列-->
      <attr name="zhv_column_num" format="integer" />
      <!--分割线-->
      <attr name="zhv_divider" format="dimension" />
      <!--距离父控件的margin-->
      <attr name="zhv_margin_parent" format="dimension" />
      <!--动画持续时间-->
      <attr name="zhv_zoom_duration" format="integer" />
      <!--动画缩放的倍数-->
      <attr name="zhv_zoom_to" format="float" />
      <!--是否使用基础的宽高(ZoomHoverGridView使用)-->
      <attr name="zhv_use_baseWH" format="boolean" />
      <!--设置基础的宽(ZoomHoverGridView使用)-->
      <attr name="zhv_base_width" format="dimension" />
      <!--设置基础的高(ZoomHoverGridView使用)-->
      <attr name="zhv_base_height" format="dimension" />
</declare-styleable>

Changed

  • 新增ZoomHoverGridView继承自GridLayout,可以实现拉伸行和列
  • 修改添加拉伸的方法,放进了view中(原来在adapter中)

Thanks

GridBuilder

CardLayoutManager

代码完全从CardLayoutManager复制,谢谢作者

CardLayoutManager

Horizontal Pagination RecyclerView

PaginationRv

HeartView

License

Copyright 2017 zyyoona7

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.