gpt4 book ai didi

android - 表情符号在缩放 TextView 时变得不可见

转载 作者:行者123 更新时间:2023-11-29 23:02:07 25 4
gpt4 key购买 nike

我有 TextView ,当我在其中添加表情符号并对其进行缩放时,我的表情符号消失了,只有文本保留在缩放后的 TextView 中。

private class ScaleGestureListener extends ScaleGestureDetector.SimpleOnScaleGestureListener {

private float mPivotX;
private float mPivotY;
private Vector2D mPrevSpanVector = new Vector2D();

@Override
public boolean onScaleBegin(View view, ScaleGestureDetector detector) {
mPivotX = detector.getFocusX();
mPivotY = detector.getFocusY();
mPrevSpanVector.set(detector.getCurrentSpanVector());
return true;
}

@Override
public boolean onScale(View view, ScaleGestureDetector detector) {
TransformInfo info = new TransformInfo();
info.deltaScale = isScaleEnabled ? detector.getScaleFactor() : 1.0f;
info.deltaAngle = isRotateEnabled ? Vector2D.getAngle(mPrevSpanVector, detector.getCurrentSpanVector()) : 0.0f;
info.deltaX = isTranslateEnabled ? detector.getFocusX() - mPivotX : 0.0f;
info.deltaY = isTranslateEnabled ? detector.getFocusY() - mPivotY : 0.0f;
info.pivotX = mPivotX;
info.pivotY = mPivotY;
info.minimumScale = minimumScale;
info.maximumScale = maximumScale;
// ((ImageEditingActivity) context).setScalingInfo(info,view,-1,view.getTranslationX(),view.getTranslationY());
move(view, info);
return false;
}
}

public void move(View view, TransformInfo info) {
computeRenderOffset(view, info.pivotX, info.pivotY);
adjustTranslation(view, info.deltaX, info.deltaY, view.getTranslationX(), view.getTranslationY());

float scale = view.getScaleX() * info.deltaScale;
scale = Math.max(info.minimumScale, Math.min(info.maximumScale, scale));
view.setScaleX(scale);
view.setScaleY(scale);

if (view.getTag() != null && view.getTag() instanceof TextLabelModel) {
TextLabelModel model = (TextLabelModel) view.getTag();
model.setScaleFactor(scale);

} else {
TextLabelModel model = new TextLabelModel();
model.setScaleFactor(scale);
view.setTag(model);
}

float rotation = adjustAngle(view.getRotation() + info.deltaAngle);
view.setRotation(rotation);
}


public void adjustTranslation(View view, float deltaX, float deltaY, float translationX, float translationY) {
float[] deltaVector = {deltaX, deltaY};
view.getMatrix().mapVectors(deltaVector);
view.setTranslationX(translationX + deltaVector[0]);
view.setTranslationY(translationY + deltaVector[1]);
}

最佳答案

我也有这个问题,通过设置解决

textView.setLayerType(View.LAYER_TYPE_SOFTWARE, null);

有关更多详细信息,请访问这些链接

Why imageView.setLayerType(View.LAYER_TYPE_SOFTWARE, null); and <application android:hardwareAccelerated="false" have different effect?

https://developer.android.com/guide/topics/graphics/hardware-accel.html

关于android - 表情符号在缩放 TextView 时变得不可见,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56849888/

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