我有一个包含32行文本的TextView。在旋转到横向时,TextView对于屏幕来说变得太大,因此我希望它分成2,16行TextViews,但不知道这是否可行。这是我迄今为止所拥有的。TextView对于屏幕太大
我知道我可以做一个测试,看看是否getHeight()>屏幕高度,但即使它是,我不知道该怎么办。
TextView displayMethod = new TextView(getActivity());
displayMethod.setTextColor(Color.BLACK);
displayMethod.setClickable(false);
displayMethod.setBackgroundColor(Color.WHITE);
displayMethod.setTextSize(14);
displayMethod.setTypeface(Typeface.MONOSPACE);
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT);
params.setMargins(10,20,10, 0);
displayMethod.setLayoutParams(params);
int i = 0;
while (i < 32){
String x = method.getNextLine();
displayMethod.append(x + "\n");
i++;
}
linLayout.addView(displayMethod);
那么你说当你旋转到风景你想有两个TextViews并排吗? (就像在一家报纸上将一个故事分成多列) – Tyler
你可以通过在文件夹“layout-land”中定义另一个带有2列的xml布局文件来实现这一点 – user2340612
@TylerAndFriends是的,现货!它需要通过编程方式生成,但并非全部在XML文件中完成 –