Font size of text

后端 未结 8 1990
伪装坚强ぢ
伪装坚强ぢ 2021-01-29 04:29

I have created different layouts (layout, layout-small, layout-normal, layout-large, layout-xlarge) and for values (values, values-ldpi, values-mdpi, values-n

8条回答
  •  囚心锁ツ
    2021-01-29 05:17

    Use this code, it works based on screen size:

    Display display = getWindowManager().getDefaultDisplay();
    int displayWidth = display.getWidth();
    
    yourTextView.setTextSize(TypedValue.COMPLEX_UNIT_PX,(float)(displayWidth * 6/100));
    

提交回复
热议问题