gpt4 book ai didi

android - 在 TextView 中缩进项目符号列表

转载 作者:IT老高 更新时间:2023-10-28 21:56:12 25 4
gpt4 key购买 nike

我有一个 TextView,我用 strings.xml 中的字符串资源中的文本填充它。字符串资源包含

  • 元素以在 TextView 内创建项目符号列表。我的问题是我想控制项目符号列表中跨越多行的行的缩进。默认文本不缩进过去的项目符号,所以它看起来有点难看。是否可以使用样式参数或以其他方式创建项目符号?

    提前致谢。

    编辑:真的回答了吗?如那些链接中所述,我在生成项目符号列表时没有任何问题,但我在正确布局时遇到了问题。缩进是这样的:

    • 超出宽度的文字

    而且我希望“行中”至少开始缩进至项目符号后面的文本。这就是我努力实现的目标。

  • 最佳答案

    我很惊讶似乎没有人遇到这个问题。我的意思是,项目符号列表在关于对话框、常见问题解答等中并不少见,并且项目符号不必包含太多文本以跨越多行并遇到此问题。

    无论如何,我现在必须这样解决它:

    <?xml version="1.0" encoding="utf-8"?>
    <ScrollView
    android:id="@+id/ScrollViewTipsLayout"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    xmlns:android="http://schemas.android.com/apk/res/android">

    <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/TipsLayout"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content">

    <TableLayout
    android:layout_height="wrap_content"
    android:id="@+id/TableLayout01"
    android:layout_width="wrap_content"
    >
    <TableRow>
    <TextView android:id="@+id/tvIngress"
    android:layout_height="wrap_content"
    android:layout_width="wrap_content"
    android:text="@+string/tv_picking_content_ingress"
    android:layout_span="2"
    android:singleLine="false"
    android:layout_weight="1"
    />
    </TableRow>
    <TableRow>
    <TextView android:id="@+id/tvCleaningDot1"
    android:layout_height="wrap_content"
    android:text="•"
    android:singleLine="false"
    />
    <TextView android:id="@+id/tvCleaningFirst"
    android:layout_height="wrap_content"
    android:text="@+string/tv_picking_content_first"
    android:layout_width="0dp"
    android:layout_weight="1"
    android:gravity="left"
    android:singleLine="false"
    />
    </TableRow>
    <TextView android:id="@+id/tvCleaningDot2"
    android:layout_height="wrap_content"
    android:text="•"
    android:singleLine="false"
    />
    <TextView android:id="@+id/tvCleaningSecond"
    android:layout_height="wrap_content"
    android:text="@+string/tv_picking_content_second"
    android:layout_width="0dp"
    android:layout_weight="1"
    android:gravity="left"
    android:singleLine="false"
    />
    </TableRow>
    </TableLayout>
    </RelativeLayout>

    我使用它在项目符号列表中呈现静态文本,因此我不必费心在代码中动态创建项目符号 + 文本。如果有人对如何以更好的方式完成同样的事情有任何建议,请启发我。

    顺便说一句,如果使用上面第二个链接中建议的解决方案:

    android:text="<ol><li>item 1\n</li><li>item 2\n</li></ol>

    跨越多行的项目符号中的第二行、第三行等不会得到与第一行相同的缩进,这非常难看。

    关于android - 在 TextView 中缩进项目符号列表,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3715776/

    25 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com