Android5.0中TextVIew布局设置和5.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>
时间: 2024-08-04 12:59:31

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

在VC++6.0中给对话框设置背景色或者背景图片

/*********************************************************** *说明: 在VC++6.0中给对话框设置背景色或者背景图片 *备注:测试代码的对话框程序的工程名为:BJ *原理:在OnPaint()中加入代码 ***********************************************************/ // 注意:去掉相应以 /* */ 注释的注释符号后代码生效 void CBJDlg::OnPaint() {

Yii2.0中Yii::$app与Yii 1.0中Yii:app()的理解

一直不明白Yii::$app与Yii::app(),查找yii框架源码后如下记录分享 (1)在Yii1.0中Yii::app()返回的是你在index.php里创建的CWebApplication实例,在对应的CWebApplication,入口文件: Yii::createWebApplication($configFile)->run(); 对应的类中查找: public static function createWebApplication($config=null){return se

Yii2.0中session有效期设置原理

1.session设置方法 $session = Yii::$app->session;//当session没有值 或 过期时间到 则重新付值if(!isset($session['user']) || $session['user']['expire_time'] < time()){$data = ['title' => 'data', //数据'expire_time' => time() + 10, //这里设置10秒过期];$session['user'] = $data

在ASP.NET Core 2.0中使用CookieAuthentication

在ASP.NET Core中关于Security有两个容易混淆的概念一个是Authentication(认证),一个是Authorization(授权).而前者是确定用户是谁的过程,后者是围绕着他们允许做什么,今天的主题就是关于在ASP.NET Core 2.0中如何使用CookieAuthentication认证. 在ASP.NET Core 2.0中使用CookieAuthentication跟在1.0中有些不同,需要在ConfigureServices和Configure中分别设置,前者我

WCF学习之旅—WCF4.0中的简化配置功能(十五)

六 WCF4.0中的简化配置功能 WCF4.0为了简化服务配置,提供了默认的终结点.绑定和服务行为.也就是说,在开发WCF服务程序的时候,即使我们不提供显示的 服务终结点,WCF框架也能为我们的服务提供一些默认配置功能的服务终结点.当然也包含默认的绑定和默认的服务行为.这一切都是为了简化配置过程,避免一 些不必要的错误. 下面我们就来通过代码示例来体验一下WCF4.0提供简化配置的功能. (1)默认终结点 默认终结点(Default Endpoints)指的是,如果开发人员没有为服务显示配置服务

避免在ASP.NET Core 3.0中为启动类注入服务

本篇是如何升级到ASP.NET Core 3.0系列文章的第二篇. Part 1 - 将.NET Standard 2.0类库转换为.NET Core 3.0类库 Part 2 - IHostingEnvironment VS IHostEnvironent - .NET Core 3.0中的废弃类型 Part 3 - 避免在ASP.NET Core 3.0中为启动类注入服务(本篇) Part 4 - 将终端中间件转换为ASP.NET Core 3.0中的端点路由 Part 5 - 将集成测试的

C# 8.0中的新功能

微信公众号:Fintech极客 作者为软件开发工程师,就职于金融信息科技类公司,通过CFA一级,分享计算机和金融相结合领域的技术和知识. C# 8.0中的新功能 C# 8.0已经推出来好长一段时间了, 由于公司目前主要使用的还是6.0版本,加上之前个人事情较多,一直没有总结,今天主要查看和测试微软官方文档中的内容:https://docs.microsoft.com/en-us/dotnet/csharp/whats-new/csharp-8 只读成员(Readonly members) 在st

C# 8.0中的模式匹配

C# 8.0中的模式匹配相对C# 7.0来说有了进一步的增强,对于如下类: class Point{    public int X { get; }    public int Y { get; }    public Point(int                x, int     y) => (X, Y) = (x, y);    public void Deconstruct(out int x, out int y) => (x, y) = (X, Y);} 首先来看C# 7.

Django1.0和2.0中的rest_framework的超链接字段的处理

大家看到这个标题是不是有点懵逼,其实我就是想要一个这样的效果 比如我get一条书籍的数据,在一对多的字段中我们显示一个url,看起来是不是很绚! 下面我们就来实现这么一个东西 首先我们一对多字段中的一表是 出版社表,因为我们这里要显示某个出版社的url,所以我们首先必须要为出版社的设计一个url """ from django.conf.urls import url from django.contrib import admin from django.conf.urls