View.setTranslationY(): queue allocate when called on CoordinatorLayout

androidx adjusts the translation a little bit and immediately
reverts it to trigger a layout pass on the CoordinatorLayout.

Calling gtk_widget_queue_allocate here makes CoordinatorLayout behave
correctly, but it causes strange issues with other Views. Therefore, it is
done only for CoordinatorLayouts for now.
This commit is contained in:
Julian Winkler
2024-03-27 23:01:46 +01:00
parent 66e5d77959
commit 654d551377
3 changed files with 19 additions and 1 deletions

View File

@@ -287,6 +287,14 @@ JNIEXPORT void JNICALL Java_android_view_View_native_1requestLayout
JNIEXPORT void JNICALL Java_android_view_View_native_1setBackgroundDrawable
(JNIEnv *, jobject, jlong, jlong);
/*
* Class: android_view_View
* Method: native_queueAllocate
* Signature: (J)V
*/
JNIEXPORT void JNICALL Java_android_view_View_native_1queueAllocate
(JNIEnv *, jobject, jlong);
/*
* Class: android_view_View
* Method: nativeInvalidate

View File

@@ -536,3 +536,8 @@ JNIEXPORT jboolean JNICALL Java_android_view_View_native_1getMatrix(JNIEnv *env,
GtkWidget *widget = gtk_widget_get_parent(GTK_WIDGET(_PTR(widget_ptr)));
return gtk_widget_compute_transform(gtk_widget_get_parent(widget), widget, _PTR(matrix_ptr));
}
JNIEXPORT void JNICALL Java_android_view_View_native_1queueAllocate(JNIEnv *env, jobject this, jlong widget_ptr)
{
gtk_widget_queue_allocate(GTK_WIDGET(_PTR(widget_ptr)));
}