TextView中文字超过一行向下移的问题

有时候textview中写文字超过一行虽然会换行,但是文本框会向下移动一些距离,不在textview中,例如:

本来的文本框内容应该在: 

这里原因是什么我也不太清楚,但是对比了其他的不会偏移的view最后发现,只要在view外侧加上一个layout就可以 

原本的代码是:

<LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="horizontal" >

        <TextView
            android:id="@+id/run_set_name"
            android:layout_width="0dp"
            android:layout_height="36dp"
            android:layout_weight="0.4"
            android:background="@drawable/data_table_text_shape"
            android:gravity="center"
            android:minHeight="36dp"
            android:text="@string/parameter_name"
            android:textColor="@color/black_color"
            android:textSize="15sp" />

        <TextView
            android:id="@+id/run_set_value"
            android:layout_width="0dp"
            android:layout_height="36dp"
            android:layout_weight="0.6"
            android:background="@drawable/data_table_text_shape"
            android:gravity="center"
            android:minHeight="35dp"
            android:text="11111111111111111111"
            android:textColor="@color/black_color"
            android:textSize="15sp" />


    </LinearLayout>

之后在两个view上面加了分别加了两个layout:

 <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="horizontal"
        android:weightSum="1" >

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="horizontal"
            android:layout_weight="0.6" >


            <TextView
                android:id="@+id/run_set_name"
                android:layout_width="match_parent"
                android:layout_height="36dp"
                android:background="@drawable/data_table_text_shape"
                android:gravity="center"
                android:minHeight="36dp"
                android:text="@string/parameter_value"
                android:textColor="@color/black_color"
                android:textSize="15sp" />
        </LinearLayout>
        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="horizontal"
            android:layout_weight="0.4" >

            <TextView
                android:id="@+id/run_set_value"
                android:layout_width="match_parent"
                android:layout_height="36dp"
                android:background="@drawable/data_table_text_shape"
                android:gravity="center"
                android:minHeight="36dp"
                android:text="@string/parameter_value"
                android:textColor="@color/black_color"
                android:textSize="15sp" />

        </LinearLayout>
    </LinearLayout>

就正常显示了

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值