1
나는 지역화를 사용하는 응용 프로그램을 가지고 있으며, 일부 언어에서는 공간이 넓어서 내가하고있는 일은 크기를 조정하는 것입니다. 이것은 지금까지 제 코드입니다. : 나는이 방에 따라 텍스트 크기를 설정하는 방법,안드로이드 스케일 텍스트
if(Build.VERSION.SDK_INT >= 11.0){
TypedValue tv = new TypedValue();
getTheme().resolveAttribute(android.R.attr.actionBarSize, tv, true);
actionBarWidth = getResources().getDimensionPixelSize(tv.resourceId);
}
View infoButton = findViewById(R.id.info_button);
int infoWidth = infoButton.getMeasuredWidth();
DisplayMetrics metrics = new DisplayMetrics();
Display Screen = getWindowManager().getDefaultDisplay();
Screen.getMetrics(metrics);
int screenWidth = metrics.widthPixels;
int titleWidth = screenWidth - infoWidth - actionBarWidth;
TextView titleText = (TextView) findViewById(R.id.title_text);
titleText.setText("hello hello hello hello hello hello");
TextPaint paint = titleText.getPaint();
Rect rect = new Rect();
String text = String.valueOf(titleText.getText());
int textLength = text.length();
paint.getTextBounds(text, 0, textLength,rect);
if(rect.width() > titleWidth){
float size = titleText.getTextSize();
float factor = activityHelper.getScreenMetrics();
float product = size*factor;
titleText.setTextSize(TypedValue.COMPLEX_UNIT_PX, product);
size = titleText.getTextSize();
}
그래서이 텍스트가 대규모하게하지만 난 그것을 완벽하게는이 방 안의 텍스트 크기를 조절되어 수행 할 작업을?
편집 :
내가 텍스트 작은 매번이 공간에 필요한 적합한 경우 검사 루프를 만드는 동안 루프를 추가 할 수 있을까요?