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
Add paddings and improved margins
This commit is contained in:
@@ -343,6 +343,14 @@ JNIEXPORT void JNICALL Java_android_view_View_setBackgroundColor
|
|||||||
JNIEXPORT void JNICALL Java_android_view_View_native_1setVisibility
|
JNIEXPORT void JNICALL Java_android_view_View_native_1setVisibility
|
||||||
(JNIEnv *, jobject, jlong, jint, jfloat);
|
(JNIEnv *, jobject, jlong, jint, jfloat);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Class: android_view_View
|
||||||
|
* Method: native_setPadding
|
||||||
|
* Signature: (JIIII)V
|
||||||
|
*/
|
||||||
|
JNIEXPORT void JNICALL Java_android_view_View_native_1setPadding
|
||||||
|
(JNIEnv *, jobject, jlong, jint, jint, jint, jint);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Class: android_view_View
|
* Class: android_view_View
|
||||||
* Method: nativeSetOnLongClickListener
|
* Method: nativeSetOnLongClickListener
|
||||||
|
|||||||
@@ -315,6 +315,32 @@ JNIEXPORT void JNICALL Java_android_view_View_native_1setLayoutParams(JNIEnv *en
|
|||||||
wrapper_widget_set_layout_params(WRAPPER_WIDGET(widget), width, height);
|
wrapper_widget_set_layout_params(WRAPPER_WIDGET(widget), width, height);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#pragma GCC diagnostic push
|
||||||
|
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
|
||||||
|
JNIEXPORT void JNICALL Java_android_view_View_native_1setPadding(JNIEnv *env, jobject this, jlong widget_ptr, jint left, jint top, jint right, jint bottom) {
|
||||||
|
GtkWidget *widget = GTK_WIDGET(_PTR(widget_ptr));
|
||||||
|
if (ATL_IS_ANDROID_LAYOUT(gtk_widget_get_layout_manager(widget))) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
GtkStyleContext *style_context = gtk_widget_get_style_context(widget);
|
||||||
|
GtkCssProvider *old_provider = g_object_get_data(G_OBJECT(widget), "padding_style_provider");
|
||||||
|
if(old_provider)
|
||||||
|
gtk_style_context_remove_provider(style_context, GTK_STYLE_PROVIDER(old_provider));
|
||||||
|
GtkCssProvider *css_provider = gtk_css_provider_new();
|
||||||
|
|
||||||
|
char *css_string = g_markup_printf_escaped("*{ padding-left: %dpx; padding-top: %dpx; padding-right: %dpx; padding-bottom: %dpx; }", left, top, right, bottom);
|
||||||
|
#if GTK_CHECK_VERSION(4, 12, 0)
|
||||||
|
gtk_css_provider_load_from_string(css_provider, css_string);
|
||||||
|
#else
|
||||||
|
gtk_css_provider_load_from_data(css_provider, css_string, strlen(css_string));
|
||||||
|
#endif
|
||||||
|
g_free(css_string);
|
||||||
|
|
||||||
|
gtk_style_context_add_provider(style_context, GTK_STYLE_PROVIDER(css_provider), GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
|
||||||
|
g_object_set_data(G_OBJECT(widget), "padding_style_provider", css_provider);
|
||||||
|
}
|
||||||
|
|
||||||
JNIEXPORT void JNICALL Java_android_view_View_native_1setVisibility(JNIEnv *env, jobject this, jlong widget_ptr, jint visibility, jfloat alpha) {
|
JNIEXPORT void JNICALL Java_android_view_View_native_1setVisibility(JNIEnv *env, jobject this, jlong widget_ptr, jint visibility, jfloat alpha) {
|
||||||
GtkWidget *widget = gtk_widget_get_parent(GTK_WIDGET(_PTR(widget_ptr)));
|
GtkWidget *widget = gtk_widget_get_parent(GTK_WIDGET(_PTR(widget_ptr)));
|
||||||
|
|
||||||
|
|||||||
@@ -834,6 +834,11 @@ public class View implements Drawable.Callback {
|
|||||||
private int minWidth = 0;
|
private int minWidth = 0;
|
||||||
private int minHeight = 0;
|
private int minHeight = 0;
|
||||||
|
|
||||||
|
protected int paddingLeft = 0;
|
||||||
|
protected int paddingTop = 0;
|
||||||
|
protected int paddingRight = 0;
|
||||||
|
protected int paddingBottom = 0;
|
||||||
|
|
||||||
public static final Property<View, Float> TRANSLATION_X = new Property<View, Float>(Float.class, "translationX") {
|
public static final Property<View, Float> TRANSLATION_X = new Property<View, Float>(Float.class, "translationX") {
|
||||||
@Override
|
@Override
|
||||||
public Float get(View object) {
|
public Float get(View object) {
|
||||||
@@ -896,6 +901,47 @@ public class View implements Drawable.Callback {
|
|||||||
if (a.hasValue(com.android.internal.R.styleable.View_minHeight)) {
|
if (a.hasValue(com.android.internal.R.styleable.View_minHeight)) {
|
||||||
minHeight = a.getDimensionPixelSize(com.android.internal.R.styleable.View_minHeight, 0);
|
minHeight = a.getDimensionPixelSize(com.android.internal.R.styleable.View_minHeight, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int padding = a.getDimensionPixelSize(com.android.internal.R.styleable.View_padding, -1);
|
||||||
|
|
||||||
|
int paddingVertical = a.getDimensionPixelSize(com.android.internal.R.styleable.View_paddingVertical, -1);
|
||||||
|
int paddingHorizontal = a.getDimensionPixelSize(com.android.internal.R.styleable.View_paddingHorizontal, -1);
|
||||||
|
|
||||||
|
int paddingStart = a.getDimensionPixelSize(com.android.internal.R.styleable.View_paddingStart, -1);
|
||||||
|
int paddingEnd = a.getDimensionPixelSize(com.android.internal.R.styleable.View_paddingEnd, -1);
|
||||||
|
|
||||||
|
if(padding >= 0) {
|
||||||
|
paddingLeft = padding;
|
||||||
|
paddingTop = padding;
|
||||||
|
paddingRight = padding;
|
||||||
|
paddingBottom = padding;
|
||||||
|
} else {
|
||||||
|
if(paddingVertical >= 0) {
|
||||||
|
paddingTop = paddingVertical;
|
||||||
|
paddingBottom = paddingVertical;
|
||||||
|
} else {
|
||||||
|
paddingTop = a.getDimensionPixelSize(com.android.internal.R.styleable.View_paddingTop, 0);
|
||||||
|
paddingBottom = a.getDimensionPixelSize(com.android.internal.R.styleable.View_paddingBottom, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(paddingHorizontal >= 0) {
|
||||||
|
paddingLeft = paddingHorizontal;
|
||||||
|
paddingRight = paddingHorizontal;
|
||||||
|
} else {
|
||||||
|
paddingLeft = a.getDimensionPixelSize(com.android.internal.R.styleable.View_paddingLeft, 0);
|
||||||
|
paddingRight = a.getDimensionPixelSize(com.android.internal.R.styleable.View_paddingRight, 0);
|
||||||
|
|
||||||
|
if(paddingStart >= 0) {
|
||||||
|
paddingLeft = paddingStart;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(paddingEnd >= 0) {
|
||||||
|
paddingRight = paddingEnd;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
native_setPadding(widget, paddingLeft, paddingTop, paddingRight, paddingBottom);
|
||||||
}
|
}
|
||||||
onCreateDrawableState(0);
|
onCreateDrawableState(0);
|
||||||
}
|
}
|
||||||
@@ -1105,7 +1151,16 @@ public class View implements Drawable.Callback {
|
|||||||
}
|
}
|
||||||
this.visibility = visibility;
|
this.visibility = visibility;
|
||||||
}
|
}
|
||||||
public void setPadding(int left, int top, int right, int bottom) {}
|
|
||||||
|
public void setPadding(int left, int top, int right, int bottom) {
|
||||||
|
paddingLeft = left;
|
||||||
|
paddingTop = top;
|
||||||
|
paddingRight = right;
|
||||||
|
paddingBottom = bottom;
|
||||||
|
native_setPadding(widget, left, top, right, bottom);
|
||||||
|
}
|
||||||
|
public native void native_setPadding(long widget, int left, int top, int right, int bottom);
|
||||||
|
|
||||||
public void setBackgroundResource(int resid) {
|
public void setBackgroundResource(int resid) {
|
||||||
setBackgroundDrawable(resid == 0 ? null : getResources().getDrawable(resid));
|
setBackgroundDrawable(resid == 0 ? null : getResources().getDrawable(resid));
|
||||||
}
|
}
|
||||||
@@ -1149,27 +1204,27 @@ public class View implements Drawable.Callback {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public int getPaddingLeft() {
|
public int getPaddingLeft() {
|
||||||
return 0;
|
return paddingLeft;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getPaddingRight() {
|
public int getPaddingRight() {
|
||||||
return 0;
|
return paddingRight;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getPaddingTop() {
|
public int getPaddingTop() {
|
||||||
return 0;
|
return paddingTop;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getPaddingBottom() {
|
public int getPaddingBottom() {
|
||||||
return 0;
|
return paddingBottom;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getPaddingStart() {
|
public int getPaddingStart() {
|
||||||
return 0;
|
return paddingLeft;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getPaddingEnd() {
|
public int getPaddingEnd() {
|
||||||
return 0;
|
return paddingRight;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void postInvalidate() {
|
public void postInvalidate() {
|
||||||
|
|||||||
@@ -261,20 +261,16 @@ public class ViewGroup extends View implements ViewParent, ViewManager {
|
|||||||
int parentWidthMeasureSpec, int widthUsed,
|
int parentWidthMeasureSpec, int widthUsed,
|
||||||
int parentHeightMeasureSpec, int heightUsed) {
|
int parentHeightMeasureSpec, int heightUsed) {
|
||||||
final MarginLayoutParams lp = (MarginLayoutParams)child.getLayoutParams();
|
final MarginLayoutParams lp = (MarginLayoutParams)child.getLayoutParams();
|
||||||
final int childWidthMeasureSpec = getChildMeasureSpec(parentWidthMeasureSpec,
|
final int childWidthMeasureSpec = getChildMeasureSpec(parentWidthMeasureSpec, paddingLeft + paddingRight + lp.leftMargin + lp.rightMargin + widthUsed, lp.width);
|
||||||
/*mPaddingLeft + mPaddingRight +*/ lp.leftMargin + lp.rightMargin + widthUsed, lp.width);
|
final int childHeightMeasureSpec = getChildMeasureSpec(parentHeightMeasureSpec, paddingTop + paddingBottom + lp.topMargin + lp.bottomMargin + heightUsed, lp.height);
|
||||||
final int childHeightMeasureSpec = getChildMeasureSpec(parentHeightMeasureSpec,
|
|
||||||
/*mPaddingTop + mPaddingBottom +*/ lp.topMargin + lp.bottomMargin + heightUsed, lp.height);
|
|
||||||
child.measure(childWidthMeasureSpec, childHeightMeasureSpec);
|
child.measure(childWidthMeasureSpec, childHeightMeasureSpec);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void measureChild(View child, int parentWidthMeasureSpec,
|
protected void measureChild(View child, int parentWidthMeasureSpec,
|
||||||
int parentHeightMeasureSpec) {
|
int parentHeightMeasureSpec) {
|
||||||
final LayoutParams lp = child.getLayoutParams();
|
final LayoutParams lp = child.getLayoutParams();
|
||||||
final int childWidthMeasureSpec = getChildMeasureSpec(parentWidthMeasureSpec,
|
final int childWidthMeasureSpec = getChildMeasureSpec(parentWidthMeasureSpec, paddingLeft + paddingRight, lp.width);
|
||||||
/*mPaddingLeft + mPaddingRight*/ 0, lp.width);
|
final int childHeightMeasureSpec = getChildMeasureSpec(parentHeightMeasureSpec, paddingTop + paddingBottom, lp.height);
|
||||||
final int childHeightMeasureSpec = getChildMeasureSpec(parentHeightMeasureSpec,
|
|
||||||
/*mPaddingTop + mPaddingBottom*/ 0, lp.height);
|
|
||||||
child.measure(childWidthMeasureSpec, childHeightMeasureSpec);
|
child.measure(childWidthMeasureSpec, childHeightMeasureSpec);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -453,19 +449,50 @@ public class ViewGroup extends View implements ViewParent, ViewManager {
|
|||||||
|
|
||||||
public MarginLayoutParams(Context context, AttributeSet attributeSet) {
|
public MarginLayoutParams(Context context, AttributeSet attributeSet) {
|
||||||
super(context, attributeSet);
|
super(context, attributeSet);
|
||||||
TypedArray a = context.obtainStyledAttributes(attributeSet, R.styleable.ViewGroup_MarginLayout);
|
TypedArray a = context.obtainStyledAttributes(attributeSet, com.android.internal.R.styleable.ViewGroup_MarginLayout);
|
||||||
|
|
||||||
int margin = a.getDimensionPixelSize(com.android.internal.R.styleable.ViewGroup_MarginLayout_layout_margin, -1);
|
int margin = a.getDimensionPixelSize(com.android.internal.R.styleable.ViewGroup_MarginLayout_layout_margin, -1);
|
||||||
|
|
||||||
|
int marginVertical = a.getDimensionPixelSize(com.android.internal.R.styleable.ViewGroup_MarginLayout_layout_marginVertical, -1);
|
||||||
|
int marginHorizontal = a.getDimensionPixelSize(com.android.internal.R.styleable.ViewGroup_MarginLayout_layout_marginHorizontal, -1);
|
||||||
|
|
||||||
|
int marginStart = a.getDimensionPixelSize(com.android.internal.R.styleable.ViewGroup_MarginLayout_layout_marginStart, -1);
|
||||||
|
int marginEnd = a.getDimensionPixelSize(com.android.internal.R.styleable.ViewGroup_MarginLayout_layout_marginEnd, -1);
|
||||||
|
|
||||||
|
leftMargin = 0;
|
||||||
|
topMargin = 0;
|
||||||
|
rightMargin = 0;
|
||||||
|
bottomMargin = 0;
|
||||||
|
|
||||||
if (margin >= 0) {
|
if (margin >= 0) {
|
||||||
leftMargin = margin;
|
leftMargin = margin;
|
||||||
topMargin = margin;
|
topMargin = margin;
|
||||||
rightMargin= margin;
|
rightMargin= margin;
|
||||||
bottomMargin = margin;
|
bottomMargin = margin;
|
||||||
} else {
|
} else {
|
||||||
leftMargin = a.getDimensionPixelSize(R.styleable.ViewGroup_MarginLayout_layout_marginLeft,0);
|
if(marginVertical >= 0){
|
||||||
rightMargin = a.getDimensionPixelSize(R.styleable.ViewGroup_MarginLayout_layout_marginRight,0);
|
topMargin = marginVertical;
|
||||||
topMargin = a.getDimensionPixelSize(R.styleable.ViewGroup_MarginLayout_layout_marginTop,0);
|
bottomMargin = marginVertical;
|
||||||
bottomMargin = a.getDimensionPixelSize(R.styleable.ViewGroup_MarginLayout_layout_marginBottom,0);
|
} else {
|
||||||
|
topMargin = a.getDimensionPixelSize(com.android.internal.R.styleable.ViewGroup_MarginLayout_layout_marginTop, 0);
|
||||||
|
bottomMargin = a.getDimensionPixelSize(com.android.internal.R.styleable.ViewGroup_MarginLayout_layout_marginBottom, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (marginHorizontal >= 0) {
|
||||||
|
leftMargin = marginHorizontal;
|
||||||
|
rightMargin = marginHorizontal;
|
||||||
|
} else {
|
||||||
|
leftMargin = a.getDimensionPixelSize(com.android.internal.R.styleable.ViewGroup_MarginLayout_layout_marginLeft, 0);
|
||||||
|
rightMargin = a.getDimensionPixelSize(com.android.internal.R.styleable.ViewGroup_MarginLayout_layout_marginRight, 0);
|
||||||
|
|
||||||
|
if (marginStart >= 0) {
|
||||||
|
leftMargin = marginStart;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (marginEnd >= 0) {
|
||||||
|
rightMargin = marginEnd;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
a.recycle();
|
a.recycle();
|
||||||
|
|||||||
@@ -50,9 +50,9 @@ public abstract class AbsListView extends AdapterView {
|
|||||||
|
|
||||||
public void setCacheColorHint(int color) {}
|
public void setCacheColorHint(int color) {}
|
||||||
|
|
||||||
public int getListPaddingTop() {return 0;}
|
public int getListPaddingTop() {return paddingTop;}
|
||||||
|
|
||||||
public int getListPaddingBottom() {return 0;}
|
public int getListPaddingBottom() {return paddingBottom;}
|
||||||
|
|
||||||
public ListAdapter getAdapter() {
|
public ListAdapter getAdapter() {
|
||||||
return (ListAdapter) super.getAdapter();
|
return (ListAdapter) super.getAdapter();
|
||||||
|
|||||||
@@ -77,9 +77,9 @@ public class AbsoluteLayout extends ViewGroup {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Account for padding too
|
// Account for padding too
|
||||||
/* maxWidth += mPaddingLeft + mPaddingRight;
|
maxWidth += paddingLeft + paddingRight;
|
||||||
maxHeight += mPaddingTop + mPaddingBottom;
|
maxHeight += paddingTop + paddingBottom;
|
||||||
*/
|
|
||||||
// Check against minimum height and width
|
// Check against minimum height and width
|
||||||
maxHeight = Math.max(maxHeight, getSuggestedMinimumHeight());
|
maxHeight = Math.max(maxHeight, getSuggestedMinimumHeight());
|
||||||
maxWidth = Math.max(maxWidth, getSuggestedMinimumWidth());
|
maxWidth = Math.max(maxWidth, getSuggestedMinimumWidth());
|
||||||
@@ -111,8 +111,8 @@ public class AbsoluteLayout extends ViewGroup {
|
|||||||
AbsoluteLayout.LayoutParams lp =
|
AbsoluteLayout.LayoutParams lp =
|
||||||
(AbsoluteLayout.LayoutParams)child.getLayoutParams();
|
(AbsoluteLayout.LayoutParams)child.getLayoutParams();
|
||||||
|
|
||||||
int childLeft = /*mPaddingLeft +*/ lp.x;
|
int childLeft = paddingLeft + lp.x;
|
||||||
int childTop = /*mPaddingTop +*/ lp.y;
|
int childTop = paddingTop + lp.y;
|
||||||
child.layout(childLeft, childTop,
|
child.layout(childLeft, childTop,
|
||||||
childLeft + child.getMeasuredWidth(),
|
childLeft + child.getMeasuredWidth(),
|
||||||
childTop + child.getMeasuredHeight());
|
childTop + child.getMeasuredHeight());
|
||||||
|
|||||||
@@ -90,25 +90,25 @@ public class FrameLayout extends ViewGroup {
|
|||||||
int getPaddingLeftWithForeground() {
|
int getPaddingLeftWithForeground() {
|
||||||
// return isForegroundInsidePadding() ? Math.max(mPaddingLeft, mForegroundPaddingLeft) :
|
// return isForegroundInsidePadding() ? Math.max(mPaddingLeft, mForegroundPaddingLeft) :
|
||||||
// mPaddingLeft + mForegroundPaddingLeft;
|
// mPaddingLeft + mForegroundPaddingLeft;
|
||||||
return 0;
|
return paddingLeft;
|
||||||
}
|
}
|
||||||
|
|
||||||
int getPaddingRightWithForeground() {
|
int getPaddingRightWithForeground() {
|
||||||
// return isForegroundInsidePadding() ? Math.max(mPaddingRight, mForegroundPaddingRight) :
|
// return isForegroundInsidePadding() ? Math.max(mPaddingRight, mForegroundPaddingRight) :
|
||||||
// mPaddingRight + mForegroundPaddingRight;
|
// mPaddingRight + mForegroundPaddingRight;
|
||||||
return 0;
|
return paddingRight;
|
||||||
}
|
}
|
||||||
|
|
||||||
private int getPaddingTopWithForeground() {
|
private int getPaddingTopWithForeground() {
|
||||||
// return isForegroundInsidePadding() ? Math.max(mPaddingTop, mForegroundPaddingTop) :
|
// return isForegroundInsidePadding() ? Math.max(mPaddingTop, mForegroundPaddingTop) :
|
||||||
// mPaddingTop + mForegroundPaddingTop;
|
// mPaddingTop + mForegroundPaddingTop;
|
||||||
return 0;
|
return paddingTop;
|
||||||
}
|
}
|
||||||
|
|
||||||
private int getPaddingBottomWithForeground() {
|
private int getPaddingBottomWithForeground() {
|
||||||
// return isForegroundInsidePadding() ? Math.max(mPaddingBottom, mForegroundPaddingBottom) :
|
// return isForegroundInsidePadding() ? Math.max(mPaddingBottom, mForegroundPaddingBottom) :
|
||||||
// mPaddingBottom + mForegroundPaddingBottom;
|
// mPaddingBottom + mForegroundPaddingBottom;
|
||||||
return 0;
|
return paddingBottom;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -506,10 +506,10 @@ public class LinearLayout extends ViewGroup {
|
|||||||
if (majorGravity != Gravity.TOP) {
|
if (majorGravity != Gravity.TOP) {
|
||||||
switch (majorGravity) {
|
switch (majorGravity) {
|
||||||
case Gravity.BOTTOM:
|
case Gravity.BOTTOM:
|
||||||
childTop = getBottom() - getTop() - /*mPaddingBottom*/ 0 - mTotalLength;
|
childTop = getBottom() - getTop() - paddingBottom - mTotalLength;
|
||||||
break;
|
break;
|
||||||
case Gravity.CENTER_VERTICAL:
|
case Gravity.CENTER_VERTICAL:
|
||||||
childTop += ((getBottom() - getTop() - /*mPaddingTop*/ 0 - /*mPaddingBottom*/ 0) -
|
childTop += ((getBottom() - getTop() - paddingTop - paddingBottom) -
|
||||||
mTotalLength) / 2;
|
mTotalLength) / 2;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -827,7 +827,7 @@ public class LinearLayout extends ViewGroup {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Add in our padding
|
// Add in our padding
|
||||||
mTotalLength += /*mPaddingTop*/ 0 + /*mPaddingBottom*/ 0;
|
mTotalLength += paddingTop + paddingBottom;
|
||||||
int heightSize = mTotalLength;
|
int heightSize = mTotalLength;
|
||||||
// Check against our minimum height
|
// Check against our minimum height
|
||||||
heightSize = Math.max(heightSize, getSuggestedMinimumHeight());
|
heightSize = Math.max(heightSize, getSuggestedMinimumHeight());
|
||||||
@@ -870,7 +870,7 @@ public class LinearLayout extends ViewGroup {
|
|||||||
final int childHeightMeasureSpec = MeasureSpec.makeMeasureSpec(
|
final int childHeightMeasureSpec = MeasureSpec.makeMeasureSpec(
|
||||||
Math.max(0, childHeight), MeasureSpec.EXACTLY);
|
Math.max(0, childHeight), MeasureSpec.EXACTLY);
|
||||||
final int childWidthMeasureSpec = getChildMeasureSpec(widthMeasureSpec,
|
final int childWidthMeasureSpec = getChildMeasureSpec(widthMeasureSpec,
|
||||||
/*mPaddingLeft*/ 0 + /*mPaddingRight*/ 0 + lp.leftMargin + lp.rightMargin,
|
paddingLeft + paddingRight + lp.leftMargin + lp.rightMargin,
|
||||||
lp.width);
|
lp.width);
|
||||||
child.measure(childWidthMeasureSpec, childHeightMeasureSpec);
|
child.measure(childWidthMeasureSpec, childHeightMeasureSpec);
|
||||||
// Child may now not fit in vertical dimension.
|
// Child may now not fit in vertical dimension.
|
||||||
@@ -890,7 +890,7 @@ public class LinearLayout extends ViewGroup {
|
|||||||
lp.topMargin + lp.bottomMargin + getNextLocationOffset(child));
|
lp.topMargin + lp.bottomMargin + getNextLocationOffset(child));
|
||||||
}
|
}
|
||||||
// Add in our padding
|
// Add in our padding
|
||||||
mTotalLength += /*mPaddingTop*/ 0 + /*mPaddingBottom*/ 0;
|
mTotalLength += paddingTop + paddingBottom;
|
||||||
// TODO: Should we recompute the heightSpec based on the new total length?
|
// TODO: Should we recompute the heightSpec based on the new total length?
|
||||||
} else {
|
} else {
|
||||||
alternativeMaxWidth = Math.max(alternativeMaxWidth,
|
alternativeMaxWidth = Math.max(alternativeMaxWidth,
|
||||||
@@ -919,7 +919,7 @@ public class LinearLayout extends ViewGroup {
|
|||||||
if (!allFillParent && widthMode != MeasureSpec.EXACTLY) {
|
if (!allFillParent && widthMode != MeasureSpec.EXACTLY) {
|
||||||
maxWidth = alternativeMaxWidth;
|
maxWidth = alternativeMaxWidth;
|
||||||
}
|
}
|
||||||
maxWidth += /*mPaddingLeft*/ 0 + /*mPaddingRight*/ 0;
|
maxWidth += paddingLeft + paddingRight;
|
||||||
// Check against our minimum width
|
// Check against our minimum width
|
||||||
maxWidth = Math.max(maxWidth, getSuggestedMinimumWidth());
|
maxWidth = Math.max(maxWidth, getSuggestedMinimumWidth());
|
||||||
setMeasuredDimension(resolveSizeAndState(maxWidth, widthMeasureSpec, childState),
|
setMeasuredDimension(resolveSizeAndState(maxWidth, widthMeasureSpec, childState),
|
||||||
@@ -1157,7 +1157,7 @@ public class LinearLayout extends ViewGroup {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Add in our padding
|
// Add in our padding
|
||||||
mTotalLength += /*mPaddingLeft*/ 0 + /*mPaddingRight*/ 0;
|
mTotalLength += paddingLeft + paddingRight;
|
||||||
int widthSize = mTotalLength;
|
int widthSize = mTotalLength;
|
||||||
// Check against our minimum width
|
// Check against our minimum width
|
||||||
widthSize = Math.max(widthSize, getSuggestedMinimumWidth());
|
widthSize = Math.max(widthSize, getSuggestedMinimumWidth());
|
||||||
@@ -1208,7 +1208,7 @@ public class LinearLayout extends ViewGroup {
|
|||||||
final int childWidthMeasureSpec = MeasureSpec.makeMeasureSpec(
|
final int childWidthMeasureSpec = MeasureSpec.makeMeasureSpec(
|
||||||
Math.max(0, childWidth), MeasureSpec.EXACTLY);
|
Math.max(0, childWidth), MeasureSpec.EXACTLY);
|
||||||
final int childHeightMeasureSpec = getChildMeasureSpec(heightMeasureSpec,
|
final int childHeightMeasureSpec = getChildMeasureSpec(heightMeasureSpec,
|
||||||
/*mPaddingTop*/ 0 + /*mPaddingBottom*/ 0 + lp.topMargin + lp.bottomMargin,
|
paddingTop + paddingBottom + lp.topMargin + lp.bottomMargin,
|
||||||
lp.height);
|
lp.height);
|
||||||
child.measure(childWidthMeasureSpec, childHeightMeasureSpec);
|
child.measure(childWidthMeasureSpec, childHeightMeasureSpec);
|
||||||
// Child may now not fit in horizontal dimension.
|
// Child may now not fit in horizontal dimension.
|
||||||
@@ -1249,7 +1249,7 @@ public class LinearLayout extends ViewGroup {
|
|||||||
mTotalLength += mDividerWidth;
|
mTotalLength += mDividerWidth;
|
||||||
}
|
}
|
||||||
// Add in our padding
|
// Add in our padding
|
||||||
mTotalLength += /*mPaddingLeft*/ 0 + /*mPaddingRight*/ 0;
|
mTotalLength += paddingLeft + paddingRight;
|
||||||
// TODO: Should we update widthSize with the new total length?
|
// TODO: Should we update widthSize with the new total length?
|
||||||
// Check mMaxAscent[INDEX_TOP] first because it maps to Gravity.TOP,
|
// Check mMaxAscent[INDEX_TOP] first because it maps to Gravity.TOP,
|
||||||
// the most common case
|
// the most common case
|
||||||
@@ -1290,7 +1290,7 @@ public class LinearLayout extends ViewGroup {
|
|||||||
if (!allFillParent && heightMode != MeasureSpec.EXACTLY) {
|
if (!allFillParent && heightMode != MeasureSpec.EXACTLY) {
|
||||||
maxHeight = alternativeMaxHeight;
|
maxHeight = alternativeMaxHeight;
|
||||||
}
|
}
|
||||||
maxHeight += /*mPaddingTop*/ 0 + /*mPaddingBottom*/ 0;
|
maxHeight += paddingTop + paddingBottom;
|
||||||
// Check against our minimum height
|
// Check against our minimum height
|
||||||
maxHeight = Math.max(maxHeight, getSuggestedMinimumHeight());
|
maxHeight = Math.max(maxHeight, getSuggestedMinimumHeight());
|
||||||
setMeasuredDimension(widthSizeAndState | (childState&MEASURED_STATE_MASK),
|
setMeasuredDimension(widthSizeAndState | (childState&MEASURED_STATE_MASK),
|
||||||
@@ -1412,29 +1412,28 @@ public class LinearLayout extends ViewGroup {
|
|||||||
* @param bottom
|
* @param bottom
|
||||||
*/
|
*/
|
||||||
void layoutVertical(int left, int top, int right, int bottom) {
|
void layoutVertical(int left, int top, int right, int bottom) {
|
||||||
final int paddingLeft = /*mPaddingLeft*/ 0;
|
|
||||||
int childTop;
|
int childTop;
|
||||||
int childLeft;
|
int childLeft;
|
||||||
// Where right end of child should go
|
// Where right end of child should go
|
||||||
final int width = right - left;
|
final int width = right - left;
|
||||||
int childRight = width - /*mPaddingRight*/ 0;
|
int childRight = width - paddingRight;
|
||||||
// Space available for child
|
// Space available for child
|
||||||
int childSpace = width - paddingLeft - /*mPaddingRight*/ 0;
|
int childSpace = width - paddingLeft - paddingRight;
|
||||||
final int count = getVirtualChildCount();
|
final int count = getVirtualChildCount();
|
||||||
final int majorGravity = mGravity & Gravity.VERTICAL_GRAVITY_MASK;
|
final int majorGravity = mGravity & Gravity.VERTICAL_GRAVITY_MASK;
|
||||||
final int minorGravity = mGravity & Gravity.RELATIVE_HORIZONTAL_GRAVITY_MASK;
|
final int minorGravity = mGravity & Gravity.RELATIVE_HORIZONTAL_GRAVITY_MASK;
|
||||||
switch (majorGravity) {
|
switch (majorGravity) {
|
||||||
case Gravity.BOTTOM:
|
case Gravity.BOTTOM:
|
||||||
// mTotalLength contains the padding already
|
// mTotalLength contains the padding already
|
||||||
childTop = /*mPaddingTop*/ 0 + bottom - top - mTotalLength;
|
childTop = paddingTop + bottom - top - mTotalLength;
|
||||||
break;
|
break;
|
||||||
// mTotalLength contains the padding already
|
// mTotalLength contains the padding already
|
||||||
case Gravity.CENTER_VERTICAL:
|
case Gravity.CENTER_VERTICAL:
|
||||||
childTop = /*mPaddingTop*/ 0 + (bottom - top - mTotalLength) / 2;
|
childTop = paddingTop + (bottom - top - mTotalLength) / 2;
|
||||||
break;
|
break;
|
||||||
case Gravity.TOP:
|
case Gravity.TOP:
|
||||||
default:
|
default:
|
||||||
childTop = /*mPaddingTop*/ 0;
|
childTop = paddingTop;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
for (int i = 0; i < count; i++) {
|
for (int i = 0; i < count; i++) {
|
||||||
@@ -1491,14 +1490,13 @@ public class LinearLayout extends ViewGroup {
|
|||||||
*/
|
*/
|
||||||
void layoutHorizontal(int left, int top, int right, int bottom) {
|
void layoutHorizontal(int left, int top, int right, int bottom) {
|
||||||
final boolean isLayoutRtl = /*isLayoutRtl()*/ false;
|
final boolean isLayoutRtl = /*isLayoutRtl()*/ false;
|
||||||
final int paddingTop = /*mPaddingTop*/ 0;
|
|
||||||
int childTop;
|
int childTop;
|
||||||
int childLeft;
|
int childLeft;
|
||||||
// Where bottom of child should go
|
// Where bottom of child should go
|
||||||
final int height = bottom - top;
|
final int height = bottom - top;
|
||||||
int childBottom = height - /*mPaddingBottom*/ 0;
|
int childBottom = height - paddingBottom;
|
||||||
// Space available for child
|
// Space available for child
|
||||||
int childSpace = height - paddingTop - /*mPaddingBottom*/ 0;
|
int childSpace = height - paddingTop - paddingBottom;
|
||||||
final int count = getVirtualChildCount();
|
final int count = getVirtualChildCount();
|
||||||
final int majorGravity = mGravity & Gravity.RELATIVE_HORIZONTAL_GRAVITY_MASK;
|
final int majorGravity = mGravity & Gravity.RELATIVE_HORIZONTAL_GRAVITY_MASK;
|
||||||
final int minorGravity = mGravity & Gravity.VERTICAL_GRAVITY_MASK;
|
final int minorGravity = mGravity & Gravity.VERTICAL_GRAVITY_MASK;
|
||||||
@@ -1509,15 +1507,15 @@ public class LinearLayout extends ViewGroup {
|
|||||||
switch (Gravity.getAbsoluteGravity(majorGravity, layoutDirection)) {
|
switch (Gravity.getAbsoluteGravity(majorGravity, layoutDirection)) {
|
||||||
case Gravity.RIGHT:
|
case Gravity.RIGHT:
|
||||||
// mTotalLength contains the padding already
|
// mTotalLength contains the padding already
|
||||||
childLeft = /*mPaddingLeft*/ 0 + right - left - mTotalLength;
|
childLeft = paddingLeft + right - left - mTotalLength;
|
||||||
break;
|
break;
|
||||||
case Gravity.CENTER_HORIZONTAL:
|
case Gravity.CENTER_HORIZONTAL:
|
||||||
// mTotalLength contains the padding already
|
// mTotalLength contains the padding already
|
||||||
childLeft = /*mPaddingLeft*/ 0 + (right - left - mTotalLength) / 2;
|
childLeft = paddingLeft + (right - left - mTotalLength) / 2;
|
||||||
break;
|
break;
|
||||||
case Gravity.LEFT:
|
case Gravity.LEFT:
|
||||||
default:
|
default:
|
||||||
childLeft = /*mPaddingLeft*/ 0;
|
childLeft = paddingLeft;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
int start = 0;
|
int start = 0;
|
||||||
|
|||||||
@@ -562,7 +562,7 @@ public class TableLayout extends LinearLayout {
|
|||||||
totalWidth += width;
|
totalWidth += width;
|
||||||
}
|
}
|
||||||
|
|
||||||
int size = MeasureSpec.getSize(widthMeasureSpec) /*- mPaddingLeft - mPaddingRight*/;
|
int size = MeasureSpec.getSize(widthMeasureSpec) - paddingLeft - paddingRight;
|
||||||
|
|
||||||
if ((totalWidth > size) && (mShrinkAllColumns || mShrinkableColumns.size() > 0)) {
|
if ((totalWidth > size) && (mShrinkAllColumns || mShrinkableColumns.size() > 0)) {
|
||||||
// oops, the largest columns are wider than the row itself
|
// oops, the largest columns are wider than the row itself
|
||||||
|
|||||||
@@ -216,7 +216,7 @@ public class TableRow extends LinearLayout {
|
|||||||
int childWidthMeasureSpec = MeasureSpec.makeMeasureSpec(
|
int childWidthMeasureSpec = MeasureSpec.makeMeasureSpec(
|
||||||
Math.max(0, columnWidth - lp.leftMargin - lp.rightMargin), measureMode);
|
Math.max(0, columnWidth - lp.leftMargin - lp.rightMargin), measureMode);
|
||||||
int childHeightMeasureSpec = getChildMeasureSpec(heightMeasureSpec,
|
int childHeightMeasureSpec = getChildMeasureSpec(heightMeasureSpec,
|
||||||
/*mPaddingTop + mPaddingBottom*/ + lp.topMargin +
|
paddingTop +paddingBottom + lp.topMargin +
|
||||||
lp.bottomMargin + totalHeight,
|
lp.bottomMargin + totalHeight,
|
||||||
lp.height);
|
lp.height);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user