2022-10-02 23:06:56 +02:00
|
|
|
package android.widget;
|
|
|
|
|
|
|
|
|
|
import android.content.Context;
|
2023-06-22 11:45:46 +02:00
|
|
|
import android.util.AttributeSet;
|
2024-01-01 12:11:31 +01:00
|
|
|
import android.view.View;
|
2023-06-22 11:45:46 +02:00
|
|
|
import android.view.ViewGroup;
|
2022-10-02 23:06:56 +02:00
|
|
|
|
|
|
|
|
public class LinearLayout extends ViewGroup {
|
|
|
|
|
|
2023-07-14 18:02:04 +02:00
|
|
|
public LinearLayout(Context context, AttributeSet attrs) {
|
|
|
|
|
super(context, attrs);
|
2022-10-02 23:06:56 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public LinearLayout(Context context) {
|
|
|
|
|
super(context);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
2023-08-17 12:59:37 +02:00
|
|
|
protected native long native_constructor(Context context, AttributeSet attrs);
|
2022-10-02 23:06:56 +02:00
|
|
|
|
|
|
|
|
public native void setOrientation(int orientation);
|
2023-12-29 11:09:37 +01:00
|
|
|
public native int getOrientation();
|
2024-01-01 12:11:31 +01:00
|
|
|
protected native void native_setHomogenousWeight(long widget, boolean homogenous);
|
2022-10-02 23:06:56 +02:00
|
|
|
public void setWeightSum(float weightSum) {}
|
|
|
|
|
|
2024-01-01 12:11:31 +01:00
|
|
|
@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);
|
|
|
|
|
}
|
|
|
|
|
|
2023-08-22 14:41:01 +02:00
|
|
|
@Override
|
|
|
|
|
public LayoutParams generateLayoutParams(AttributeSet attrs) {
|
|
|
|
|
return new LayoutParams(getContext(), attrs);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static class LayoutParams extends ViewGroup.MarginLayoutParams {
|
|
|
|
|
public LayoutParams (Context c, AttributeSet attrs) {
|
|
|
|
|
super(c, attrs);
|
|
|
|
|
}
|
|
|
|
|
|
2023-06-22 11:45:46 +02:00
|
|
|
public LayoutParams(int width, int height) {
|
2022-10-02 23:06:56 +02:00
|
|
|
super(width, height);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public LayoutParams(int width, int height, float weight) {
|
|
|
|
|
super(width, height, weight);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|