diff options
| author | Romain Guy <romainguy@google.com> | 2010-06-15 11:33:24 -0700 |
|---|---|---|
| committer | Romain Guy <romainguy@google.com> | 2010-06-15 14:00:52 -0700 |
| commit | 9295ada0ec89fa7a666be4a2f1006a4b722adf4f (patch) | |
| tree | 71a7c4f16844a6541552e2f0e6034d0c4bd5ffd8 /core/java/android/widget/LinearLayout.java | |
| parent | 7e28c0108b2926832f29503682f950ab7506f684 (diff) | |
Allow the use of styles with LinearLayout, make "useLargestChild" attr public.
Change-Id: I044f3f5bd9b90c684ded7a37ff85e3aa8d15af96
Diffstat (limited to 'core/java/android/widget/LinearLayout.java')
| -rw-r--r-- | core/java/android/widget/LinearLayout.java | 43 |
1 files changed, 40 insertions, 3 deletions
diff --git a/core/java/android/widget/LinearLayout.java b/core/java/android/widget/LinearLayout.java index bd07e1f54ffa..7254c3cfd359 100644 --- a/core/java/android/widget/LinearLayout.java +++ b/core/java/android/widget/LinearLayout.java @@ -40,6 +40,13 @@ import android.widget.RemoteViews.RemoteView; * <p> * Also see {@link LinearLayout.LayoutParams android.widget.LinearLayout.LayoutParams} * for layout attributes </p> + * + * @attr ref android.R.styleable#LinearLayout_baselineAligned + * @attr ref android.R.styleable#LinearLayout_baselineAlignedChildIndex + * @attr ref android.R.styleable#LinearLayout_gravity + * @attr ref android.R.styleable#LinearLayout_measureWithLargestChild + * @attr ref android.R.styleable#LinearLayout_orientation + * @attr ref android.R.styleable#LinearLayout_weightSum */ @RemoteView public class LinearLayout extends ViewGroup { @@ -112,7 +119,11 @@ public class LinearLayout extends ViewGroup { } public LinearLayout(Context context, AttributeSet attrs) { - super(context, attrs); + this(context, attrs, 0); + } + + public LinearLayout(Context context, AttributeSet attrs, int defStyle) { + super(context, attrs, defStyle); TypedArray a = context.obtainStyledAttributes(attrs, com.android.internal.R.styleable.LinearLayout); @@ -137,8 +148,7 @@ public class LinearLayout extends ViewGroup { mBaselineAlignedChildIndex = a.getInt(com.android.internal.R.styleable.LinearLayout_baselineAlignedChildIndex, -1); - // TODO: Better name, add Java APIs, make it public - mUseLargestChild = a.getBoolean(R.styleable.LinearLayout_useLargestChild, false); + mUseLargestChild = a.getBoolean(R.styleable.LinearLayout_measureWithLargestChild, false); a.recycle(); } @@ -167,6 +177,33 @@ public class LinearLayout extends ViewGroup { mBaselineAligned = baselineAligned; } + /** + * When true, all children with a weight will be considered having + * the minimum size of the largest child. If false, all children are + * measured normally. + * + * @return True to measure children with a weight using the minimum + * size of the largest child, false otherwise. + */ + public boolean isMeasureWithLargestChildEnabled() { + return mUseLargestChild; + } + + /** + * When set to true, all children with a weight will be considered having + * the minimum size of the largest child. If false, all children are + * measured normally. + * + * Disabled by default. + * + * @param enabled True to measure children with a weight using the + * minimum size of the largest child, false otherwise. + */ + @android.view.RemotableViewMethod + public void setMeasureWithLargestChildEnabled(boolean enabled) { + mUseLargestChild = enabled; + } + @Override public int getBaseline() { if (mBaselineAlignedChildIndex < 0) { |
