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

Side by Side Diff: ui/android/java/src/org/chromium/ui/widget/TextViewWithLeading.java

Issue 1955813002: Create TextViewWithLeading. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 7 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 unified diff | Download patch
« no previous file with comments | « ui/android/java/res/values/attrs.xml ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 package org.chromium.ui.widget;
6
7 import android.content.Context;
8 import android.content.res.TypedArray;
9 import android.util.AttributeSet;
10 import android.widget.TextView;
11
12 import org.chromium.ui.R;
13
14 /**
15 * A TextView with the added leading property.
16 * Leading is the distance between the baselines of successive lines of text (so the space between
17 * rules on ruled paper). This class performs the calculation to setup leading c orrectly and allows
18 * it to be set in XML. It overwrites android:lineSpacingExtra and android:lineS pacingMultiplier.
19 */
20 public class TextViewWithLeading extends TextView {
21 // TODO(peconn): Add a lint check to ensure no lineSpacingExtr or lineSpacin gMultiplier.
22 public TextViewWithLeading(Context context, AttributeSet attrs) {
23 super(context, attrs);
24
25 TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.TextVie wWithLeading, 0, 0);
26 if (a.hasValue(R.styleable.TextViewWithLeading_leading)) {
27 final float leading = a.getDimension(R.styleable.TextViewWithLeading _leading, 0f);
28 final float oldLeading = getPaint().getFontMetrics(null);
Ted C 2016/05/11 17:25:53 out of curiosity, did you try this on pre-L? Dan
29 setLineSpacing(leading - oldLeading, 1f);
30 }
31
32 a.recycle();
33 }
34 }
OLDNEW
« no previous file with comments | « ui/android/java/res/values/attrs.xml ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698