繁体   English   中英

TextView中的换行符添加了填充

[英]Line break in TextView adds padding

这是我的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

如何摆脱Info左侧的填充,使它们都从同一位置开始?

this.directoryEntries.add(new IconifiedText(currentFile
                    .getPath(), currentIcon, "\r\nInfo"));

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM