Index: chrome/android/java/src/org/chromium/chrome/browser/widget/DynamicHeightGridView.java |
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/widget/DynamicHeightGridView.java b/chrome/android/java/src/org/chromium/chrome/browser/widget/DynamicHeightGridView.java |
new file mode 100644 |
index 0000000000000000000000000000000000000000..06b79fa4f0f8e8f2bee10195d636ed3ea17ea26f |
--- /dev/null |
+++ b/chrome/android/java/src/org/chromium/chrome/browser/widget/DynamicHeightGridView.java |
@@ -0,0 +1,41 @@ |
+// Copyright 2017 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+package org.chromium.chrome.browser.widget; |
+ |
+import android.content.Context; |
+import android.util.AttributeSet; |
+import android.widget.GridView; |
+ |
+/** |
+ * This class is a customized GridView which draws items in multiple lines automatically |
+ */ |
+public class DynamicHeightGridView extends GridView { |
gogerald1
2017/05/30 19:36:48
name it ExpandableGridView looks make more sense,
Hwanseung Lee
2017/05/31 14:34:36
Done.
|
+ /** Constructor for when the gridview is inflated from XML. */ |
+ public DynamicHeightGridView(Context context, AttributeSet attrs) { |
+ super(context, attrs); |
+ } |
+ |
+ /** Constructor for when the gridview is inflated from XML. */ |
+ public DynamicHeightGridView(Context context) { |
gogerald1
2017/05/30 19:36:48
I guess you no need this and the below constructor
Hwanseung Lee
2017/05/31 14:34:36
Done.
|
+ super(context); |
+ } |
+ |
+ /** Constructor for when the gridview is inflated from XML. */ |
+ public DynamicHeightGridView(Context context, AttributeSet attrs, int defStyle) { |
+ super(context, attrs, defStyle); |
+ } |
+ |
+ @Override |
+ public void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { |
+ int heightSpec; |
+ if (getLayoutParams().height == LayoutParams.WRAP_CONTENT) { |
+ heightSpec = MeasureSpec.makeMeasureSpec(Integer.MAX_VALUE >> 2, MeasureSpec.AT_MOST); |
gogerald1
2017/05/30 19:36:48
View.MEASURED_SIZE_MASK looks make more sense here
Hwanseung Lee
2017/05/31 14:34:36
Done.
|
+ } else { |
+ heightSpec = heightMeasureSpec; |
+ } |
+ |
+ super.onMeasure(widthMeasureSpec, heightSpec); |
+ } |
+} |