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

Android5.0中TextVIew布局设置和5.0以前的冲突
同一个布局文件,Android5.0以下的都可以显示

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

而Android5.0显示不了文字

Android5.0中TextVIew布局设置跟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="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>


1楼x3599815142小时前
不明
Re: tmacsky1小时前
回复x359981514n这个放在5.0里才能对比出来