码迷,mamicode.com
首页 > 移动开发 > 详细

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

时间:2014-12-25 14:38:53      阅读:182      评论:0      收藏:0      [点我收藏+]

标签:

<span style="font-family: 'Hiragino Sans GB', 'Microsoft YaHei', 微软雅黑, tahoma, arial, simsun, 宋体; background-color: rgb(255, 255, 255);">同一个布局文件,Android5.0以下的都可以显示</span>

技术分享

而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>


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

标签:

原文地址:http://blog.csdn.net/tmacsky/article/details/42145627

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!