项目上要用到类似高德地图搜索结果后的结果展示的可拉伸控件。
由于没有找到合适的软件,制作的效果有点差,将就看下。
自己的效果:
虽然说效果没有高德的好(就是在下滑的时候不能准确折叠到中间),但是基本满足了项目的需要。如果各位大神有更好的方法,欢迎留言提供方法。
刚开始以为这是抽屉效果(slidingdrawer),结果发现这个类已经被谷歌抛弃,且content也不能滑动,得自定义控件实现。但是我的自定义控件水平不高,苦思一天还是写不出来,只能各种查类似的效果,终于找到了比较接近的CoordinatorLayout。
@deprecated
This class is not supported anymore. It is recommended you base your own implementation on the source code for the Android Open Source Project if you must use it in your application.
关于CoordinatorLayout — 协调布局 这个新控件我了解的不多,等我找找资料后再写一篇文章。我就先说说效果的实现。
布局文件:
<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout
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:id="@+id/coordinator"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#88bbbbbb"
android:gravity="center"
tools:context="com.joysuch.collapseviewdemo.MainActivity">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/girl"/>
<RelativeLayout
android:id="@+id/design_bottom_sheet_bar"
android:layout_width="match_parent"