0
我正在動態實現TableLayout。它由多個TextView組成。當我在TableRow上動態添加TextView時,它們會被截斷到屏幕邊界。根據需要,需要將剪切後的文本附加到下一個TableRow。這是我的代碼。需要幫助..防止文本被剪輯並追加到下一行如果在表格佈局中修剪android
私人無效的init(){
arrayList=new ArrayList<String>();
arrayList.add("Name");
arrayList.add("Address");
arrayList.add("obj");
arrayList.add("age");
TableLayout.LayoutParams params = new TableLayout.LayoutParams(LayoutParams.FILL_PARENT,LayoutParams.WRAP_CONTENT,0.1f);
TableLayout rl = (TableLayout) this.findViewById(R.id.tblLayout);
for(int i = 0; i<50; i++)
{
tr = new TableRow(this);
for(int j=0;j<50;j++){
tv = new TextView(this);
tv.setOnTouchListener(this);
tv.setText(arrayList.get(j).toString());
Log.e("text", tv.getText().toString());
tr.addView(tv);
tv.setPadding(5, 5, 0, 0);
tr.setId(i);
}
tr.setPadding(0, 1, 0, 1);
}
謝謝。但是我怎麼能得到最後添加的TextView併爲它設置了這個屬性?不明白 – user2381124
在所有字段上創建它時進行設置。如果需要空間,它將只會變成多線。 –