Java TextView中的换行符添加了填充
这是我的文本视图:Java TextView中的换行符添加了填充,java,android,textview,padding,Java,Android,Textview,Padding,这是我的文本视图: public IconifiedTextView(Context context, IconifiedText aIconifiedText) { super(context); /* * First Icon and the Text to the right (horizontal), not above and * below (vertical) */ this.setOrientation(HORIZONTAL
public IconifiedTextView(Context context, IconifiedText aIconifiedText) {
super(context);
/*
* First Icon and the Text to the right (horizontal), not above and
* below (vertical)
*/
this.setOrientation(HORIZONTAL);
mIcon = new ImageView(context);
mIcon.setImageDrawable(aIconifiedText.getIcon());
// left, top, right, bottom
mIcon.setPadding(0, 3, 7, 3); // 5px to the right
/*
* At first, add the Icon to ourself (! we are extending LinearLayout)
*/
addView(mIcon, new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT,
LayoutParams.WRAP_CONTENT));
mText = new TextView(context);
mText.setText(aIconifiedText.getText());
mText.setTextSize(16);
/* Now the text (after the icon) */
addView(mText, new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT,
LayoutParams.WRAP_CONTENT));
mInfo = new TextView(context);
mInfo.setText(aIconifiedText.getInfo());
/* Now the Info (below the Text) */
addView(mInfo, new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT,
LayoutParams.WRAP_CONTENT));
}
当我调用对象时,我有:
this.directoryEntries.add(new IconifiedText(currentFile
.getPath(), currentIcon, "\nInfo"));
其中“\nInfo”将被稍后的内容替换。当我运行此程序时,我得到以下结果:
d
Info
data
Info
dev
Info
system
Info
如何去掉信息左侧的填充,使它们从同一个位置开始?谢谢你的回答,但运气不好。。。它仍然凹凸不平。
this.directoryEntries.add(new IconifiedText(currentFile
.getPath(), currentIcon, "\r\nInfo"));