对齐文本(即使其适合文本视图并覆盖所有空间) [英] justifing a text (that is, make it fit in a textview and cover all space)

查看:93
本文介绍了对齐文本(即使其适合文本视图并覆盖所有空间)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试制作一个涉及用阿拉伯语写一些诗的应用程序,但是我很难使这首诗看起来合理,以便在阅读时显得美观.

I'm trying to make an app that involves writing some poems in Arabic language, however I'm having difficulties in making the poem look justified to look nice when reading them.

我正在使用TableLayout填写这首诗:

I'm using TableLayout to fill in the poem:

<TableLayout
        android:id="@+id/whole_line_table"
        android:layout_width="match_parent"
        android:layout_height="50dp"
        android:gravity="center_vertical"
        android:stretchColumns="1"
        >
        <TableRow
            android:padding="6dp">
            <TextView
                android:layout_width="0dp"
                android:id="@+id/poem2_textView"
                android:layout_weight="1"
                android:gravity="right"
                android:textSize="15sp"
                tools:text="Some text here"
                />

            <TextView
                android:id="@+id/poem1_textView"
                android:layout_width="0dp"
                android:layout_weight="1"
                android:gravity="right"
                android:textSize="15sp"
                tools:text="Some text here"
                android:maxLines="1"/>
        </TableRow>
    </TableLayout>

我希望这首诗出现在下图中的示例

Example of how I want the poem to appear in the image below

相反的示例

您可以看到诗歌中的每节经文如何一起开始和结束,并注意它们之间的间隔.

You can see how each verse in the poem start and end together and notice the space between them.

到目前为止,我在布局中所拥有的屏幕截图如下所示 在此处输入图片描述

Screen shot of what I have in layout so far shown below enter image description here

我希望右侧部分延伸到不止textView的一半.

I want the right part to reach to end not half the textView only.

我对开发应用程序是完全陌生的,请原谅我任何不好的编码外观

I'm totally new to developing apps so please excuse me for any bad coding look

推荐答案

设置文本宽度以填充父级,并为元素设置边距. 使用重心.

set text width to fill the parent and set margin to element. use gravity center.

       <TextView
        android:id="@+id/poem1_textView"
        android:layout_width="match_parent"
        android:layout_weight="1"
        android:gravity="center"
        android:textSize="15sp"
        android:margin="18dp"    
        tools:text="Some text here"
        />

这可以帮助您模拟对齐的文本,如果您想要更好的修复程序,或者您正在使用android 8.0.它支持文本对齐. 查看此答案,然后尝试使用那些库. Android TextView对齐文本

that could help you to simulate an justified text, if you want a better fix or if you are using android 8.0. it supports justification on texts. Look at this answer and try those libraries. Android TextView Justify Text

我希望能帮上忙.

这篇关于对齐文本(即使其适合文本视图并覆盖所有空间)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆