0
我想放大按鈕中文本的大小,因爲屏幕變得更寬。起初,它似乎我的代碼工作,但在不同的Android設備,它不起作用。它將在小屏幕上將字體更改爲大尺寸。Android,試圖放大文本,如果它放在更大的屏幕上
這是我在做什麼:
int w=getWindowManager().getDefaultDisplay().getWidth();
Button but1=new Button(this);
// but1.setTextColor(Color.parseColor("#ffd79825"));
if (w<400)
but1.setTextSize(10.0f);
else
if (w<650)
but1.setTextSize(14.0f);
else
if (w>470)
but1.setTextSize(18.0f);