Auto Scale Text Size

前端 未结 3 1589
情书的邮戳
情书的邮戳 2021-01-02 09:06

I\'m looking for a way to when I change a screen size it will proportionally resize the text. Currently I tried Auto Scale TextView Text to Fit within Bounds but it doesn\'

3条回答
  •  孤城傲影
    2021-01-02 09:27

    I use this, proportionally at the width of the screen.

    DisplayMetrics displaymetrics = new DisplayMetrics();
            getWindowManager().getDefaultDisplay().getMetrics(displaymetrics);
            width_screen=displaymetrics.widthPixels;
    Mytext.setTextSize(TypedValue.COMPLEX_UNIT_PX, (width_screen/CONST));
    

    the CONST is a number I use for to scale the font, in the dimension I want. It works for my needs.

提交回复
热议问题