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
LinearLayout: set GtkBox to homogeneous if all child weights are equal
Real weighted allocation is not supported by GtkBox
This commit is contained in:
@@ -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 LinearLayout extends ViewGroup {
|
||||
@@ -19,8 +20,23 @@ public class LinearLayout extends ViewGroup {
|
||||
|
||||
public native void setOrientation(int orientation);
|
||||
public native int getOrientation();
|
||||
protected native void native_setHomogenousWeight(long widget, boolean homogenous);
|
||||
public void setWeightSum(float weightSum) {}
|
||||
|
||||
@Override
|
||||
protected void addViewInternal(View child, int index, ViewGroup.LayoutParams params) {
|
||||
super.addViewInternal(child, index, params);
|
||||
// check if all children have the same weight and set GtkBox to homogeneous if so
|
||||
float weight = params.weight;
|
||||
for (int i = 0; i < children.size(); i++) {
|
||||
if (children.get(i).getLayoutParams().weight != weight) {
|
||||
weight = 0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
native_setHomogenousWeight(widget, weight > 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public LayoutParams generateLayoutParams(AttributeSet attrs) {
|
||||
return new LayoutParams(getContext(), attrs);
|
||||
|
||||
Reference in New Issue
Block a user