【问题标题】:How can I display my content better?如何更好地展示我的内容?
【发布时间】:2023-03-14 09:59:01
【问题描述】:

这是我内容的当前格式

项目符号与下一段在同一行开始。 现在我想实现这样的目标

我希望段落从离子弹不远的地方开始。我怎样才能做到这一点?

这是我的xml

<me.biubiubiu.justifytext.library.JustifyTextView
            android:textColor="@color/black"
            android:paddingTop="2dp"
            android:id="@+id/practices"
            android:layout_below="@+id/thumbnail"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:textSize="15sp" />

【问题讨论】:

  • 您可以使用 Webview 小部件,它可以根据需要格式化数据,也可以使用 html 代码的功能。

标签: android xml android-layout listview


【解决方案1】:

bullets 之后在string 中添加两个空格字符,您可以使用 replaceAllString

String bulletCode = "#8226";
String spaceCode = "&#160";
myContent.replaceAll(bulletCode, bulletCode+spaceCode+spaceCode);

【讨论】:

  • 让我试试看
  • 我试过这个。空格字符添加得很好,但是下一行仍然与项目符号在同一级别开始
【解决方案2】:

我已经通过这个方法达到了要点,你可以试试这个

String BULLET_SYMBOL = "&#8226";

    private String text = Html.fromHtml(BULLET_SYMBOL + " +1 new goat every 12 months for 36 months")
                + System.getProperty("line.separator")
                + System.getProperty("line.separator")
                + Html.fromHtml(BULLET_SYMBOL + " 10-30% estimated ROI")
                + System.getProperty("line.separator")
                + System.getProperty("line.separator")
            + Html.fromHtml(BULLET_SYMBOL + " New animal if dead or infertile");

    JustifyTextView practices = (JustifyTextView)findViewById(R.id.practices);
    practices.setText(text);

System.getProperty("line.separator") 用于换行

【讨论】:

    【解决方案3】:

    为了显示带有项目符号的排版,您需要使用适当的正则表达式以便根据需要缩进。

    您可以使用以下示例:

    \u2022\s\d\. \s[A-z]
    

    这应该可以帮助您实现预期目标。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2019-04-06
      • 1970-01-01
      • 2015-12-14
      • 2014-05-29
      • 1970-01-01
      • 2018-07-01
      • 2017-01-23
      • 1970-01-01
      相关资源
      最近更新 更多