https://developer.android.google.cn/reference/android/view/View?hl=en#attr_android:textAlignment

API 17 时添加的属性,一直没用到过,记录一下这个简单的属性
android:textAlignment 支持以下属性值

ConstantValueDescription
center4Center the paragraph, for example: ALIGN_CENTER.
gravity1Default for the root view. The gravity determines the alignment, ALIGN_NORMAL, ALIGN_CENTER, or
inherit0Default.
textEnd3Align to the end of the paragraph, for example: ALIGN_OPPOSITE.
textStart2Align to the start of the paragraph, for example: ALIGN_NORMAL.
viewEnd6Align to the end of the view, which is ALIGN_RIGHT if the view’s resolved layoutDirection is LTR, and ALIGN_LEFT otherwise.
viewStart5Align to the start of the view, which is ALIGN_LEFT if the view’s resolved layoutDirection is LTR, and ALIGN_RIGHT otherwise.

textEndviewEnd 的不同,正如上述英文描述的一样,layoutDirection 不一样的时候有所不同
下面展示在设置了 android:textDirection="rtl" 的文字显示效果

android:textAlignment="viewEnd"
android:textDirection="rtl

在这里插入图片描述

   android:textAlignment="textEnd"
   android:textDirection="rtl" 

在这里插入图片描述

Logo

为开发者提供学习成长、分享交流、生态实践、资源工具等服务,帮助开发者快速成长。

更多推荐