我通过使用不错的库https://github.com/umano/AndroidSlidingUpPanel创建了它
<com.sothree.slidinguppanel.SlidingUpPanelLayout xmlns:sothree="http://schemas.android.com/apk/res-auto"
android:id="@+id/sliding_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="bottom"
sothree:umanoDragView="@+id/dragView"
sothree:umanoInitialState="collapsed"
sothree:umanoPanelHeight="200dp"
sothree:umanoParalaxOffset="0dp">
<!-- MAIN CONTENT -->
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent" />
<!-- SLIDING LAYOUT -->
<LinearLayout
android:id="@+id/dragView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@android:color/black"
android:clickable="true"
android:focusable="true"
android:orientation="vertical">
<TextureView
android:id="@+id/texture_view"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</LinearLayout>
</com.sothree.slidinguppanel.SlidingUpPanelLayout>
并为相机滚动添加视差
slidingPanel.setPanelSlideListener(new SlidingUpPanelLayout.PanelSlideListener() {
@Override
public void onPanelSlide(View panel, float slideOffset) {
dragView.setPadding(0, (int) (parallaxOffset * slideOffset - parallaxOffset), 0, 0);
}
@Override
public void onPanelExpanded(View panel) {
Log.i(TAG, "onPanelExpanded");
resizeBtn.setSelected(true);
}
@Override
public void onPanelCollapsed(View panel) {
Log.i(TAG, "onPanelCollapsed");
resizeBtn.setSelected(false);
}
@Override
public void onPanelAnchored(View panel) {
Log.i(TAG, "onPanelAnchored");
}
@Override
public void onPanelHidden(View panel) {
Log.i(TAG, "onPanelHidden");
}
});
}