我有一个FrameLayout我想在底部的设备窗口之外,所以用户看不到它。当用户按下某个东西时,这FrameLayout是一部分的整个片段将向上移动,这应该暴露FrameLayout,因为它现在在视图中。为此,我在其所有父级上设置了一个负边距FrameLayout并将clipChildren和clipToPadding设置为 false。但是,这似乎不起作用。
我试图手动添加属性
android:clipChildren="false"
android:clipToPadding="false"
对每一个可能的父视图,没有任何运气。可以肯定的是,我什至使用这种方法循环父母并以编程方式设置这些属性:
public void disableClipOnParents(View v) {
if (v.getParent() == null) {
return;
}
if (v instanceof ViewGroup) {
((ViewGroup) v).setClipChildren(false);
}
if (v.getParent() instanceof View) {
disableClipOnParents((View) v.getParent());
}
}
当我向上滑动持有片段时,这个视图被剪裁的原因可能是什么?这是片段的布局 XML:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/colorPrimary"
android:orientation="vertical"
android:clipChildren="false"
android:clipToPadding="false">
<android.support.constraint.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/colorPrimary">
<FrameLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_marginTop="40dp"
app:layout_constraintBottom_toTopOf="parent"
app:layout_constraintDimensionRatio="H, 1:1"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent" />
</android.support.constraint.ConstraintLayout>
<RelativeLayout
android:adjustViewBounds="true"
android:id="@+id/rlPlaceholder"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/colorPrimary"
android:clipChildren="false"
android:clipToPadding="false">
<ImageView
android:id="@+id/ivCaptureImage"
android:layout_width="75dp"
android:layout_height="75dp"
android:layout_centerInParent="true"
android:src="@drawable/camera_shutter_selector" />
<FrameLayout
android:id="@+id/flStart"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/colorPrimaryLight"
android:layout_alignParentBottom="true"
android:layout_marginBottom="-40dp">
<TextView
android:layout_width="wrap_content"
android:layout_height="60dp"
android:gravity="center_vertical"
android:layout_gravity="center_horizontal"
android:textSize="18dp"
android:fontFamily="sans-serif"
android:textColor="@color/white"
android:text="START"/>
</FrameLayout>
</RelativeLayout>
</LinearLayout>
id 为flStart的FrameLayout底部是应该位于屏幕外部然后在单击事件上滑入的视图(片段的顶部滑出)。
非常感谢任何帮助