jimu-decompiled/sources/com/google/android/material/internal/BaselineLayout.java
2025-05-13 19:24:51 +02:00

79 lines
2.8 KiB
Java

package com.google.android.material.internal;
import android.content.Context;
import android.util.AttributeSet;
import android.view.View;
import android.view.ViewGroup;
/* loaded from: classes.dex */
public class BaselineLayout extends ViewGroup {
private int a;
public BaselineLayout(Context context) {
super(context, null, 0);
this.a = -1;
}
@Override // android.view.View
public int getBaseline() {
return this.a;
}
@Override // android.view.ViewGroup, android.view.View
protected void onLayout(boolean z, int i, int i2, int i3, int i4) {
int childCount = getChildCount();
int paddingLeft = getPaddingLeft();
int paddingRight = ((i3 - i) - getPaddingRight()) - paddingLeft;
int paddingTop = getPaddingTop();
for (int i5 = 0; i5 < childCount; i5++) {
View childAt = getChildAt(i5);
if (childAt.getVisibility() != 8) {
int measuredWidth = childAt.getMeasuredWidth();
int measuredHeight = childAt.getMeasuredHeight();
int i6 = ((paddingRight - measuredWidth) / 2) + paddingLeft;
int baseline = (this.a == -1 || childAt.getBaseline() == -1) ? paddingTop : (this.a + paddingTop) - childAt.getBaseline();
childAt.layout(i6, baseline, measuredWidth + i6, measuredHeight + baseline);
}
}
}
@Override // android.view.View
protected void onMeasure(int i, int i2) {
int childCount = getChildCount();
int i3 = -1;
int i4 = -1;
int i5 = 0;
int i6 = 0;
int i7 = 0;
for (int i8 = 0; i8 < childCount; i8++) {
View childAt = getChildAt(i8);
if (childAt.getVisibility() != 8) {
measureChild(childAt, i, i2);
int baseline = childAt.getBaseline();
if (baseline != -1) {
i3 = Math.max(i3, baseline);
i4 = Math.max(i4, childAt.getMeasuredHeight() - baseline);
}
i6 = Math.max(i6, childAt.getMeasuredWidth());
i5 = Math.max(i5, childAt.getMeasuredHeight());
i7 = View.combineMeasuredStates(i7, childAt.getMeasuredState());
}
}
if (i3 != -1) {
i5 = Math.max(i5, Math.max(i4, getPaddingBottom()) + i3);
this.a = i3;
}
setMeasuredDimension(View.resolveSizeAndState(Math.max(i6, getSuggestedMinimumWidth()), i, i7), View.resolveSizeAndState(Math.max(i5, getSuggestedMinimumHeight()), i2, i7 << 16));
}
public BaselineLayout(Context context, AttributeSet attributeSet) {
super(context, attributeSet, 0);
this.a = -1;
}
public BaselineLayout(Context context, AttributeSet attributeSet, int i) {
super(context, attributeSet, i);
this.a = -1;
}
}