英文:
With TextView alignment bottom, line breaks are at the top
问题
我的应用程序中,我希望将文本对齐到右下角。<br/>
目前看起来不错。<br/>
但是,我希望我的换行符遵守给定的重力,以便较长的文本位于底部。
示例:
> Lorem ipsum dolor sit amet, consectetur adipiscing<br/>
> elit. Cras sollicitudin
应该更像是:
> Lorem ipsum dolor <br/>
> sit amet, consectetur adipiscing elit. Cras sollicitudin
我的TextView看起来像这样:
```xml
<TextView
android:id="@+id/text_bottom"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textAlignment="textEnd"
android:gravity="bottom|end"
android:layout_alignParentBottom="true"/>
我期望android:gravity="bottom|end"
会给我想要的结果,但据我所知,它似乎没有改变任何内容。
<details>
<summary>英文:</summary>
*A similar question has been asked [here](https://stackoverflow.com/questions/48130545/bottom-aligned-text-line-break-upwards), though not for Android development and it hasn't been answered in a sufficient way.*
In my app I want to align text to the bottom right.<br/>
So far so good.<br/>
However, I want my line breaks to respect the given gravity, so that the longer text is at the bottom.
Example:
> Lorem ipsum dolor sit amet, consectetur adipiscing<br/>
> elit. Cras sollicitudin
should look more like
> Lorem ipsum dolor <br/>
> sit amet, consectetur adipiscing elit. Cras sollicitudin
My `TextView` looks like this:
<TextView
android:id="@+id/text_bottom"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textAlignment="textEnd"
android:gravity="bottom|end"
android:layout_alignParentBottom="true"/>
I expected `android:gravity="bottom|end"` to give me the desired result but as far as I can tell it didn't change anything.
</details>
# 答案1
**得分**: 1
这仅仅通过TextView属性是不可能的。您应该编写自己的TextView来修改行为。
<details>
<summary>英文:</summary>
That's not possible only with TextView attributes. You should write your own TextView to modify the behavior.
</details>
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论