am 8d6730fd: am b89e969c: Merge "Fix font scaling issues in FastScroller and SubtitleView" into klp-dev

* commit '8d6730fd30dd6aa4b186591f210dd5e74d117921':
  Fix font scaling issues in FastScroller and SubtitleView
This commit is contained in:
Alan Viverette
2013-10-04 15:10:19 -07:00
committed by Android Git Automerger
2 changed files with 12 additions and 8 deletions

View File

@@ -33,6 +33,7 @@ import android.text.TextUtils.TruncateAt;
import android.util.IntProperty;
import android.util.MathUtils;
import android.util.Property;
import android.util.TypedValue;
import android.view.Gravity;
import android.view.MotionEvent;
import android.view.View;
@@ -471,11 +472,11 @@ class FastScroller {
final Resources res = context.getResources();
final int minSize = res.getDimensionPixelSize(R.dimen.fastscroll_overlay_size);
final ColorStateList textColor = ta.getColorStateList(TEXT_COLOR);
final float textSize = res.getDimension(R.dimen.fastscroll_overlay_text_size);
final float textSize = res.getDimensionPixelSize(R.dimen.fastscroll_overlay_text_size);
final TextView textView = new TextView(context);
textView.setLayoutParams(params);
textView.setTextColor(textColor);
textView.setTextSize(textSize);
textView.setTextSize(TypedValue.COMPLEX_UNIT_PX, textSize);
textView.setSingleLine(true);
textView.setEllipsize(TruncateAt.MIDDLE);
textView.setGravity(Gravity.CENTER);

View File

@@ -113,10 +113,10 @@ public class SubtitleView extends View {
// TODO: Move these to a default style.
final Resources res = getContext().getResources();
final DisplayMetrics m = res.getDisplayMetrics();
mCornerRadius = res.getDimension(com.android.internal.R.dimen.subtitle_corner_radius);
mOutlineWidth = res.getDimension(com.android.internal.R.dimen.subtitle_outline_width);
mShadowRadius = res.getDimension(com.android.internal.R.dimen.subtitle_shadow_radius);
mShadowOffsetX = res.getDimension(com.android.internal.R.dimen.subtitle_shadow_offset);
mCornerRadius = res.getDimensionPixelSize(com.android.internal.R.dimen.subtitle_corner_radius);
mOutlineWidth = res.getDimensionPixelSize(com.android.internal.R.dimen.subtitle_outline_width);
mShadowRadius = res.getDimensionPixelSize(com.android.internal.R.dimen.subtitle_shadow_radius);
mShadowOffsetX = res.getDimensionPixelSize(com.android.internal.R.dimen.subtitle_shadow_offset);
mShadowOffsetY = mShadowOffsetX;
mTextPaint = new TextPaint();
@@ -169,9 +169,12 @@ public class SubtitleView extends View {
invalidate();
}
/**
* Sets the text size in pixels.
*
* @param size the text size in pixels
*/
public void setTextSize(float size) {
final DisplayMetrics metrics = getContext().getResources().getDisplayMetrics();
final float pixels = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_SP, size, metrics);
if (mTextPaint.getTextSize() != size) {
mTextPaint.setTextSize(size);
mInnerPaddingX = (int) (size * INNER_PADDING_RATIO + 0.5f);