【问题标题】:XML drawables not showing up on actual devicesXML drawable 未显示在实际设备上
【发布时间】:2016-06-23 16:49:46
【问题描述】:

这与其他问题不同,因此请尝试理解我的问题。 我有

test.xml

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="ring" >

<size
    android:height="30dp"
    android:width="30dp" />

<solid android:color="#009688" />

我的 TextView 如下

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context="com.bradley.learndrawable.MainActivity" >

<TextView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:background="@drawable/test"
    android:text="2"
    android:textStyle="bold"
    android:gravity="center"
    android:textColor="#FFFFFF" />

它应该将文本视图显示为一个绿色的圆圈和一个白色的数字。 它在图形视图上运行良好,但在实际设备上却不行。

我已将可绘制对象复制到每个可绘制文件夹。 对我来说还是没有好运气。

帮助! :)

Screenshot of Graphical View

【问题讨论】:

  • 应该只是在可绘制文件夹中,之后什么都没有。
  • 我用的是Eclipse哥☺
  • 如果将文本颜色设置为黑色会怎样?文字是否可见?
  • 是的,文字是可见的,我之前也试过,但背景不可见

标签: android xml shape xml-drawable


【解决方案1】:

你可以试试android:layerType="software"。我不确定这是否能解决问题,但它可以工作

【讨论】:

  • 如果您不确定答案,可以将其发布在 cmets 中
  • @JuanCruzSoler 啊,这很聪明,下次我一定会这样做。谢谢!
猜你喜欢
  • 2017-04-04
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2013-08-17
相关资源
最近更新 更多