【发布时间】:2015-08-05 06:12:48
【问题描述】:
我有一排(水平的LinearLayout),末尾有一个TextView,显示时间。这是它的外观:
现在我需要将所有行中的后缀 (am/pm) 垂直对齐。上面的布局不是这样,可以看到,最后一行因为显示的时间比较长而错位了。
我使用制表符 \u0009 实现了这一点。这意味着我会将文本设置为例如“7:21\u0009\u0009pm”。这会产生如下所示的预期结果:
但是,我需要知道(1) 这是否是最有效的方式 以及(2) 这是否适用于所有安卓设备。如果有其他方法可以实现这一点,请告诉我。
这里是一行的 XML 布局供您参考:
<LinearLayout
android:layout_width="match_parent"
android:layout_height="@dimen/prayer_time_row_height"
android:layout_marginLeft="48dp"
android:gravity="center_vertical"
android:orientation="horizontal">
<com.devspark.robototextview.widget.RobotoTextView
style="@style/text_subhead"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Today"
android:textColor="@color/material_light_secondary_text"
android:visibility="invisible" />
<com.devspark.robototextview.widget.RobotoTextView
style="@style/text_subhead"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Event"
android:textColor="@color/material_light_primary_text" />
<com.devspark.robototextview.widget.RobotoTextView
style="@style/text_subhead"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="12:06\u0009\u0009am"
android:textColor="@color/material_light_primary_text" />
</LinearLayout>
奖金
指出垂直对齐小时-分钟分隔符(即冒号字符)的方法的奖励积分。
【问题讨论】:
标签: android textview vertical-alignment