Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1380)

Unified Diff: chrome/android/java/src/org/chromium/chrome/browser/payments/ui/ExpandableGridView.java

Issue 2902503002: [Payment] should show all accepted card icon in payment editor. (Closed)
Patch Set: q Created 3 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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..5cacde5b6af84a40cce213764dbde1447767ac66
--- /dev/null
+++ b/chrome/android/java/src/org/chromium/chrome/browser/payments/ui/ExpandableGridView.java
@@ -0,0 +1,35 @@
+// 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) {
+ // GridView does not work well in a ScrollView when it uses WRAP_CONTENT.
+ // Instead, force it to use AT_MOST.
+ // https://stackoverflow.com/questions/4523609/grid-of-images-inside-scrollview
+ 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);
+ }
+}
« no previous file with comments | « chrome/android/java/src/org/chromium/chrome/browser/payments/ui/EditorIconsField.java ('k') | chrome/android/java_sources.gni » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698