Android 负边距大于视图';在棒棒糖前的装置上的s高度
似乎不可能指定大于视图维度的负值。例如,假设我有以下布局:Android 负边距大于视图';在棒棒糖前的装置上的s高度,android,margin,Android,Margin,似乎不可能指定大于视图维度的负值。例如,假设我有以下布局: <?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:background="@color/colorPrimary" andr
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:background="@color/colorPrimary"
android:layout_height="match_parent"
android:orientation="vertical">
<RelativeLayout
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="56dp"
android:background="@color/colorPrimary"
android:layout_marginTop="-2dp">
<ImageView
android:id="@+id/closeIV"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_margin="12dp"
android:src="@drawable/ic_close_white_24dp" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_toRightOf="@id/closeIV"
android:text="GALERÍA"
android:textColor="@color/white"
android:textSize="17sp"
android:textStyle="bold" />
<View
android:layout_alignParentBottom="true"
android:background="@android:color/black"
android:layout_width="match_parent"
android:layout_height="0.5dp"/>
</RelativeLayout>
<ImageView
android:id="@+id/pictureIV"
android:scaleType="centerCrop"
android:layout_width="match_parent"
android:layout_below="@+id/toolbar"
android:layout_height="wrap_content"/>
<android.support.v7.widget.RecyclerView
android:id="@+id/galleryRV"
android:layout_below="@+id/pictureIV"
android:background="@android:color/black"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentBottom="true"
android:layout_marginTop="2dp"
android:textAppearance="?android:attr/textAppearanceLarge"/>
<View
android:layout_below="@id/pictureIV"
android:layout_width="match_parent"
android:background="@drawable/grid_layout_separator"
android:layout_height="10dp"/>
</RelativeLayout>
如果我将工具栏的上边距设置为大于工具栏的高度,比如-200dp,那么postlollipop设备中的输出将是完全隐藏的工具栏,图像视图的144dp将被隐藏,而recyclerview将被拉伸200dp,你可以在Instagram的图库中看到类似的行为。但在棒棒糖制作之前的设备中,输出将是完全隐藏的工具栏,顶部的imageview和recyclerview将被拉伸56 dp。因此,似乎不可能将负边距设置为大于工具栏的高度,是否有一种解决方法可以在预列印设备中实现类似的行为?但为什么要使用负边距?我正在尝试实现类似instagram gallery的功能,如果您查看instagram,一旦你的手指通过recyclerview/listview的高度,它会拉伸并隐藏工具栏,同时向上移动图像,我可以在工具栏上使用负边距模拟post lollipop上的相同行为,但它不适用于pre。。。您将如何实现这种行为?我认为这就是所谓的折叠工具栏。不确定,但你可以检查一下你想做什么,但我认为行为不同