TextView 中的换行符添加填充
这是我的 TextView:
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 is my TextView:
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));
}
And when i call the object I have:
this.directoryEntries.add(new IconifiedText(currentFile
.getPath(), currentIcon, "\nInfo"));
Where "\nInfo" will be replaced by something later. When i run this, I get this:
d
Info
data
Info
dev
Info
system
Info
How do i get rid of this padding to the left of Info so they both start at the same place?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)