右对齐在Android的文字? [英] Right aligning text in android?

查看:122
本文介绍了右对齐在Android的文字?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有什么特别的,我需要做的就是在对齐文本权< TableLayout>

下面这个简单的例子似乎右对齐边在屏幕中央的文字,仿佛 layout_span 无影响。

 < TableLayout
        的xmlns:机器人=htt​​p://schemas.android.com/apk/res/android
        机器人:layout_height =FILL_PARENT
        机器人:layout_width =FILL_PARENT
        >
    <的TableRow>
        <的TextView
                机器人:文本=一些文本
                机器人:layout_width =WRAP_CONTENT
                机器人:layout_height =WRAP_CONTENT
                机器人:layout_gravity =右
                机器人:layout_span =2
                />
    < /的TableRow>
    <的TableRow>
        <按钮
                机器人:文本=按钮1
                机器人:layout_weight =50/>
        <按钮
                机器人:文本=按钮2
                机器人:layout_weight =50/>
    < /的TableRow>
< / TableLayout>
 

解决方案

修正。

删除了TextView的部分:

 安卓layout_gravity =右
机器人:layout_span =2
 

在TextView中的更新部分:

 安卓重力=右
机器人:layout_weight =1.0


 < TableLayout的xmlns:机器人=htt​​p://schemas.android.com/apk/res/android
      机器人:layout_height =FILL_PARENT
      机器人:layout_width =FILL_PARENT>

      <的TableRow>
           <的TextView
                 机器人:文本=一些文本
                 机器人:layout_width =WRAP_CONTENT
                 机器人:layout_height =WRAP_CONTENT
                 机器人:重力=右
                 机器人:layout_weight =1.0/>
      < /的TableRow>
      <的TableRow>
            <按钮
                 机器人:文本=按钮1
                 机器人:layout_weight =50/>
            <按钮
                 机器人:文本=按钮2
                 机器人:layout_weight =50/>
       < /的TableRow>
 < / TableLayout>
 

Is there anything special I need to do to get text right aligned in a <TableLayout>?

The following simple example seems to align the text right-edged on the center of the screen, almost as if layout_span had no effect.

<TableLayout
        xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_height="fill_parent"
        android:layout_width="fill_parent"
        >
    <TableRow>
        <TextView
                android:text="Some text"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_gravity="right"
                android:layout_span="2"
                />
    </TableRow>
    <TableRow>
        <Button
                android:text="Button 1"
                android:layout_weight="50"/>
        <Button
                android:text="Button 2"
                android:layout_weight="50"/>
    </TableRow>
</TableLayout>

解决方案

Fixed.

Removed Portion from TextView :

android:layout_gravity="right"
android:layout_span="2"

Updated Portion in TextView:

android:gravity="right"
android:layout_weight="1.0"


 <TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
      android:layout_height="fill_parent"
      android:layout_width="fill_parent" >

      <TableRow>
           <TextView
                 android:text="Some text"
                 android:layout_width="wrap_content"
                 android:layout_height="wrap_content"
                 android:gravity="right"
                 android:layout_weight="1.0" />
      </TableRow>
      <TableRow>
            <Button
                 android:text="Button 1"
                 android:layout_weight="50"/>
            <Button
                 android:text="Button 2"
                 android:layout_weight="50"/>
       </TableRow>
 </TableLayout>

这篇关于右对齐在Android的文字?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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