Android5.0中TextVIew布局设置和5.0以前的冲突

同一个布局文件,Android5.0以下的都可以显示

而Android5.0显示不了文字

布局文件:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"

    android:layout_width="match_parent"

    android:layout_height="match_parent"

    android:orientation="vertical">



    <View

        android:layout_width="fill_parent"

        android:layout_height="1px"

        android:layout_marginTop="14dp"

        android:background="@color/abc_search_url_text_pressed"/>



    <RelativeLayout

        android:id="@+id/lay_coupons"

        android:layout_width="fill_parent"

        android:layout_height="wrap_content"

        android:layout_marginBottom="14dp"

        android:visibility="visible">



        <TextView

            android:id="@+id/tv_coupons"

            android:layout_width="fill_parent"

            android:layout_height="wrap_content"

            android:layout_margin="12dp"

            android:drawablePadding="10dp"

            android:drawableRight="@android:drawable/checkbox_off_background"

            android:gravity="right"

            android:text="1个"/>



        <TextView

            android:layout_width="wrap_content"

            android:layout_height="wrap_content"

            android:layout_marginBottom="12dp"

            android:layout_marginLeft="16dp"

            android:layout_marginRight="10dp"

            android:layout_marginTop="12dp"

            android:layout_toLeftOf="@id/tv_coupons"

            android:text="我的收藏"

            android:textColor="@color/abc_search_url_text_holo"

            android:textSize="16sp"/>

    </RelativeLayout>



    <View

        android:layout_width="fill_parent"

        android:layout_height="1px"

        android:layout_below="@id/tv_coupons"

        android:background="@color/abc_search_url_text_selected"/>



</LinearLayout>


出现这种问题是我之前写的布局不规范,右边的textview设置成了铺满在5.0以前是不会不显示的,而在5.0的时候系统默认将右边的文字挤出布局所以5.0该布局就不显示左边的文字;修改之后的布局如下:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"

    android:layout_width="match_parent"

    android:layout_height="match_parent"

    android:orientation="vertical">



    <View

        android:layout_width="fill_parent"

        android:layout_height="1px"

        android:layout_marginTop="14dp"

        android:background="@color/abc_search_url_text_pressed"/>



    <RelativeLayout

        android:id="@+id/lay_coupons"

        android:layout_width="fill_parent"

        android:layout_height="wrap_content"

        android:layout_marginBottom="14dp"

        android:visibility="visible">



        <TextView

            android:id="@+id/tv_coupons"

            android:layout_width="wrap_content"

            android:layout_height="wrap_content"

            android:layout_alignParentRight="true"

            android:layout_margin="12dp"

            android:drawablePadding="10dp"

            android:drawableRight="@android:drawable/checkbox_off_background"

            android:gravity="right"

            android:text="1个"/>



        <TextView

            android:layout_width="wrap_content"

            android:layout_height="wrap_content"

            android:layout_marginBottom="12dp"

            android:layout_marginLeft="16dp"

            android:layout_marginRight="10dp"

            android:layout_marginTop="12dp"

            android:layout_alignParentLeft="true"

            android:layout_toLeftOf="@id/tv_coupons"

            android:text="我的收藏"

            android:textColor="@color/abc_search_url_text_holo"

            android:textSize="16sp"/>

    </RelativeLayout>



    <View

        android:layout_width="fill_parent"

        android:layout_height="1px"

        android:layout_below="@id/tv_coupons"

        android:background="@color/abc_search_url_text_selected"/>



</LinearLayout>


转载于:https://my.oschina.net/tmacsky/blog/534954

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值