gpt4 book ai didi

android - clipChiren 设置为 false 仍然剪裁

转载 作者:塔克拉玛干 更新时间:2023-11-02 08:32:07 25 4
gpt4 key购买 nike

我正在使用翻译动画将鸡蛋(ImageButton)移到纸箱(ImageView)之外,但它一直在剪裁,所以我查看了整个stackoverflow以找到解决方案,但在尝试实现所有解决方案之后,它仍然被剪裁。

任何人都可以阐明为什么我的仍在剪裁,这是 XML:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:gravity="top"
android:clipChildren="false"
android:clipToPadding="false"
android:layout_height="match_parent">
<ImageButton
android:id="@+id/imageButton1"
android:background="@drawable/transparentblackbackground"
android:layout_below="@+id/relativeLayout1"
android:layout_height="match_parent"
android:layout_width="match_parent"
android:clipChildren="false" android:clipToPadding="false" >
</ImageButton>

<!-- Total Carton for Animation -->
<RelativeLayout
android:orientation="vertical"
android:layout_width="440dp"
android:id="@+id/opencarton"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:clipChildren="false"
android:clipToPadding="false" >



<!-- The carton that holds the eggs -->
<RelativeLayout
android:orientation="vertical"
android:layout_width="260dp"
android:id="@+id/opencarton"
android:layout_height="512dp"
android:layout_centerInParent="true"
android:clipChildren="false"
android:clipToPadding="false">

<ImageButton
android:id="@+id/blackbgnd"
android:background="@drawable/clearbackground"
android:layout_height="600dp"
android:layout_width="400dp"
android:clipChildren="false"
android:clipToPadding="false"
android:gravity="center">
</ImageButton>

<!-- Top of Carton image -->
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/topcomponent"
android:src="@drawable/topofcarton"
android:layout_alignParentTop="true"
android:layout_alignParentRight="true"
android:clipChildren="false"
android:clipToPadding="false">
</ImageView>

<!-- First Row Of eggs goes here in future -->
<ImageButton android:clipChildren="false" android:clipToPadding="false" android:layout_height="158dp" android:id="@+id/egg1" android:background="@drawable/goldegg" android:layout_width="79dp" android:layout_alignTop="@id/topcomponent" android:layout_alignParentLeft="true" android:layout_marginLeft="10dp" android:layout_marginTop="3dp"></ImageButton>
<ImageButton android:clipChildren="false" android:clipToPadding="false" android:layout_height="158dp" android:id="@+id/egg2" android:background="@drawable/goldegg" android:layout_width="79dp" android:layout_alignTop="@id/topcomponent" android:layout_alignParentLeft="true" android:layout_marginLeft="90dp" android:layout_marginTop="3dp"></ImageButton>
<ImageButton android:clipChildren="false" android:clipToPadding="false" android:layout_height="158dp" android:id="@+id/egg3" android:background="@drawable/goldegg" android:layout_width="79dp" android:layout_alignTop="@id/topcomponent" android:layout_alignParentLeft="true" android:layout_marginLeft="170dp" android:layout_marginTop="3dp"></ImageButton>

................

</RelativeLayout>
</RelativeLayout>
</RelativeLayout>

最佳答案

好吧,我浪费了大约一个小时来解决类似的问题。

我想您正在使用一些转换或调用 postInvalidateDelayed() 或类似方法强制刷新来“手动”为对象设置动画。

问题是(对我来说)你需要在顶 View 上调用它,否则 Canvas 会自动剪裁到你正在刷新的项目。因此,在最顶层的 View 上调用 invalidate()(或类似方法)应该会导致使用未剪裁太多的 Canvas 进行重绘。

在您的情况下,我注意到您定义了两个“opencarton”id,您应该刷新最上面的一个或最上面的 RelativeLayout。

关于android - clipChiren 设置为 false 仍然剪裁,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10156067/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com