gpt4 book ai didi

Android:clipChildren=false 和 onClickListner 用于剪裁的 child

转载 作者:太空狗 更新时间:2023-10-29 14:43:44 26 4
gpt4 key购买 nike

我有一个问题。

我们有布局自定义框架布局,具有缩放和平移功能

public class MyFrameLayout extends FrameLayout {
...
@Override
protected void onDraw(Canvas canvas) {
super.onDraw(canvas);

getChildAt(0).setTranslationX(vTranslate.x);
getChildAt(0).setTranslationY(vTranslate.y);
getChildAt(0).setScaleX(mScale.scaleFactor);
getChildAt(0).setScaleY(mScale.scaleFactor);
}

该类监听触摸手势并翻译/缩放其子级。我将它用作我的包含内容的 ViewGroup 的父 View 组。

<MyFrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/gray"
android:clipChildren="false">

<android.support.constraint.ConstraintLayout
android:id="@+id/calc_constraint_layout"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:clipChildren="false"/>

约束布局的内容以编程方式添加,它比屏幕或父组大。因此我们设置了 clipChildren=false。但是在转换前越界的 child 不响应 onClick 事件。

部分图片:

开始屏幕 enter image description here

翻译后: enter image description here

6% 的节点只是不响应点击。请帮帮我。

添加: enter image description here

最佳答案

嗯。我找不到制作约束布局(白色布局)以适应具有 wrap_content 值的内容的方法。我的解决方法是根据节点树的宽度和高度动态增加约束布局的宽度和高度。

当您添加额外的节点时 - 布局措施会增长,您会看到它是如何调整的。然后为了修复它,我不得不重写父布局中的 onLayout() 方法(它在屏幕截图上是绿色的,但它是自定义的 ZoomableLayout)。

现在一切正常。但我不确定这个实现是否丑陋。

关于Android:clipChildren=false 和 onClickListner 用于剪裁的 child ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43370044/

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