很简单,我使用此tutorial的列表视图,我尝试过使用 AutoFitTextView以及AutoResizeTextView,我已将行MATCH_PARENT的宽度也设为高度,我制作了不同的TextViews MATCH_PARENT。
我甚至尝试获取screenWidth,为图像宽度减去它,并将该结果作为textView的宽度然后调整大小,但仍然无法正常工作。
这是我在CustomList类中实现的getView:
public View getView(int position, View view, ViewGroup parent) {
LayoutInflater inflater = context.getLayoutInflater();
View rowView= inflater.inflate(R.layout.list_single, null, true);
TableRow tbrow = (TableRow) rowView.findViewById(R.id.idTableRow1);
tbrow.setLayoutParams(new TableRow.LayoutParams(TableRow.LayoutParams.MATCH_PARENT,TableRow.LayoutParams.MATCH_PARENT));
ImageView imageView = (ImageView) rowView.findViewById(R.id.img);
AutoResizeTextView tv = new AutoResizeTextView(context);
((TableRow)imageView.getParent()).addView(tv);
tv.setGravity(Gravity.CENTER);
tbrow.setGravity(Gravity.CENTER);
//Fix for android 4.0.4 versions and earlier
final String DOUBLE_BYTE_SPACE = "\u3000";
String fixString = "";
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.HONEYCOMB_MR1
&& android.os.Build.VERSION.SDK_INT <= android.os.Build.VERSION_CODES.ICE_CREAM_SANDWICH_MR1) {
fixString = DOUBLE_BYTE_SPACE;
}
tv.setLayoutParams(new TableRow.LayoutParams(TableRow.LayoutParams.MATCH_PARENT, TableRow.LayoutParams.MATCH_PARENT, 1f));
tv.setText(fixString + web[position] + fixString);
imageView.setImageDrawable(imageId[position]);
if(setParameters){
imageView.setLayoutParams(params);
}
return rowView;
}
请我绝望地寻找这个,我到处寻找,没有人帮助过我......
提前致谢。