Fix font issue

This commit is contained in:
Victor Shcherb 2011-12-14 23:49:45 +01:00
parent 7bbf67fa95
commit bfffe28f57
2 changed files with 7 additions and 5 deletions

View file

@ -54,6 +54,7 @@ public class ContextMenuLayer extends OsmandMapLayer {
private final MapActivity activity; private final MapActivity activity;
private Drawable boxLeg; private Drawable boxLeg;
private float scaleCoefficient = 1; private float scaleCoefficient = 1;
private Rect textPadding;
public ContextMenuLayer(MapActivity activity){ public ContextMenuLayer(MapActivity activity){
this.activity = activity; this.activity = activity;
@ -83,7 +84,7 @@ public class ContextMenuLayer extends OsmandMapLayer {
textView = new TextView(view.getContext()); textView = new TextView(view.getContext());
LayoutParams lp = new LayoutParams(BASE_TEXT_SIZE, LayoutParams.WRAP_CONTENT); LayoutParams lp = new LayoutParams(BASE_TEXT_SIZE, LayoutParams.WRAP_CONTENT);
textView.setLayoutParams(lp); textView.setLayoutParams(lp);
textView.setTextSize(15 * scaleCoefficient); textView.setTextSize(15);
textView.setTextColor(Color.argb(255, 0, 0, 0)); textView.setTextColor(Color.argb(255, 0, 0, 0));
textView.setMinLines(1); textView.setMinLines(1);
// textView.setMaxLines(15); // textView.setMaxLines(15);
@ -92,6 +93,8 @@ public class ContextMenuLayer extends OsmandMapLayer {
textView.setClickable(true); textView.setClickable(true);
textView.setBackgroundDrawable(view.getResources().getDrawable(R.drawable.box_free)); textView.setBackgroundDrawable(view.getResources().getDrawable(R.drawable.box_free));
textPadding = new Rect();
textView.getBackground().getPadding(textPadding);
} }
@Override @Override
@ -107,8 +110,7 @@ public class ContextMenuLayer extends OsmandMapLayer {
canvas.translate(-tx, -ty); canvas.translate(-tx, -ty);
if (textView.getText().length() > 0) { if (textView.getText().length() > 0) {
int topMarginDiff = (int) (5 * scaleCoefficient); canvas.translate(x - textView.getWidth() / 2, ty - textView.getBottom() + textPadding.bottom - textPadding.top);
canvas.translate(x - textView.getWidth() / 2, ty - textView.getBottom() - topMarginDiff);
int c = textView.getLineCount(); int c = textView.getLineCount();
textView.draw(canvas); textView.draw(canvas);

View file

@ -547,8 +547,8 @@ public class MapInfoLayer extends OsmandMapLayer {
// Back to location icon // Back to location icon
params = new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT); params = new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
params.leftMargin = (int) (10 * scaleCoefficient); params.leftMargin = (int) (5 * scaleCoefficient);
params.rightMargin = 0; params.rightMargin = (int) (5 * scaleCoefficient);
backToLocation = new ImageView(view.getContext()); backToLocation = new ImageView(view.getContext());
backToLocation.setImageDrawable(view.getResources().getDrawable(R.drawable.back_to_loc)); backToLocation.setImageDrawable(view.getResources().getDrawable(R.drawable.back_to_loc));
backToLocation.setOnClickListener(new View.OnClickListener() { backToLocation.setOnClickListener(new View.OnClickListener() {