You've already forked android_translation_layer
mirror of
https://gitlab.com/android_translation_layer/android_translation_layer.git
synced 2025-10-27 11:48:10 -07:00
ScrollView: implement custom onMeasure()
This commit is contained in:
@@ -13,6 +13,7 @@ JNIEXPORT jlong JNICALL Java_android_widget_ScrollView_native_1constructor(JNIEn
|
||||
GtkWidget *scrolled_window = gtk_scrolled_window_new();
|
||||
wrapper_widget_set_child(WRAPPER_WIDGET(wrapper), scrolled_window);
|
||||
gtk_widget_set_name(scrolled_window, "ScrollView");
|
||||
(*env)->SetBooleanField(env, this, _FIELD_ID(_CLASS(this), "haveCustomMeasure", "Z"), true);
|
||||
return _INTPTR(scrolled_window);
|
||||
}
|
||||
|
||||
|
||||
@@ -1632,4 +1632,6 @@ public class View extends Object {
|
||||
public boolean getGlobalVisibleRect(Rect visibleRect) {
|
||||
return native_getGlobalVisibleRect(widget, visibleRect);
|
||||
}
|
||||
|
||||
public boolean onCheckIsTextEditor() {return false;}
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ package android.widget;
|
||||
|
||||
import android.content.Context;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
||||
public class ScrollView extends ViewGroup {
|
||||
@@ -20,5 +21,21 @@ public class ScrollView extends ViewGroup {
|
||||
@Override
|
||||
protected native void native_removeView(long widget, long child);
|
||||
|
||||
@Override
|
||||
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
|
||||
int width = 0;
|
||||
int height = 0;
|
||||
if (getChildCount() > 0) {
|
||||
View child = getChildAt(0);
|
||||
LayoutParams lp = child.getLayoutParams();
|
||||
int childWidthMeasureSpec = getChildMeasureSpec(widthMeasureSpec, 0, lp.width);
|
||||
int childHeightMeasureSpec = MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED);
|
||||
child.measure(childWidthMeasureSpec, childHeightMeasureSpec);
|
||||
width = child.getMeasuredWidth();
|
||||
height = child.getMeasuredHeight();
|
||||
}
|
||||
setMeasuredDimension(resolveSize(width, widthMeasureSpec), resolveSize(height, heightMeasureSpec));
|
||||
}
|
||||
|
||||
public void setFillViewport(boolean fillViewport) {}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user