Index: chrome/android/java/src/org/chromium/chrome/browser/payments/ui/ExpandableGridView.java |
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/payments/ui/ExpandableGridView.java b/chrome/android/java/src/org/chromium/chrome/browser/payments/ui/ExpandableGridView.java |
new file mode 100644 |
index 0000000000000000000000000000000000000000..f374399441268cfa3bb72aaa222dc33e8ca15114 |
--- /dev/null |
+++ b/chrome/android/java/src/org/chromium/chrome/browser/payments/ui/ExpandableGridView.java |
@@ -0,0 +1,34 @@ |
+// 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.payments.ui; |
+ |
+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 ExpandableGridView extends GridView { |
+ /** Constructor for when the gridview is inflated from XML. */ |
+ public ExpandableGridView(Context context, AttributeSet attrs) { |
+ super(context, attrs); |
+ } |
+ |
+ @Override |
+ public void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { |
+ // Heights of GridView is not working well in ScrollView even though has wrap_content |
+ // attributes. by setting MeasureSpec.AT_MOST, GridView can work well forcely. |
gone
2017/06/05 17:21:01
// GridView does not work well in a ScrollView whe
Hwanseung Lee
2017/06/06 12:48:30
Done.
|
+ final int heightSize = MeasureSpec.getSize(heightMeasureSpec); |
+ int heightSpec; |
+ if (getLayoutParams().height == LayoutParams.WRAP_CONTENT) { |
+ heightSpec = MeasureSpec.makeMeasureSpec(heightSize, MeasureSpec.AT_MOST); |
+ } else { |
+ heightSpec = heightMeasureSpec; |
+ } |
+ |
+ super.onMeasure(widthMeasureSpec, heightSpec); |
+ } |
+} |