微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

Android:Drawable没有显示出来

我有一个相当简单的xml文件,里面有一个图像按钮.图形布局xml设计器上的图像显示正常,当我运行开发构建时显示正常,但是一旦我创建签名的apk文件并运行它,图像就不再显示了.这只是一个空按钮.我想不出有什么理由,有什么想法吗? xml文件如下所示:
<?xml version="1.0" encoding="utf-8"?><LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/navigation_root"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >

<TextView
    android:id="@+id/navigation_text"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:padding="5dp"
    android:text="TextView"
    android:textAppearance="?android:attr/textAppearanceLarge" >
</TextView>

<SeekBar
    android:id="@+id/navigation_seekbar"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_gravity="center_vertical"
    android:layout_weight="1"
    android:padding="5dp" >
</SeekBar>

<LinearLayout
    android:id="@+id/linearLayout1"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:padding="5dp" >

    <ImageButton
        android:id="@+id/part_select_button"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:src="@drawable/chapter_select" >
    </ImageButton>

    <Button
        android:id="@+id/navigation_ok_button"
        android:layout_width="75dp"
        android:layout_height="match_parent"
        android:layout_weight="1"
        android:text="@string/ok" >
    </Button>

    <Button
        android:id="@+id/navigation_cancel_button"
        android:layout_width="75dp"
        android:layout_height="match_parent"
        android:layout_weight="1"
        android:text="@string/cancel" >
    </Button>
</LinearLayout>

图像@ drawable / chapter_select是一个相当小的(41 * 41)png文件,位于res / drawable文件夹中.

解决方法

似乎这是一个android的错误,有时可绘制文件夹中的第一个图像不会显示.在drawable文件夹中添加一个名为aaaa.png的虚拟图像,问题解决了.在这里找到答案: ImageButton does not display a particular drawable

原文地址:https://www.jb51.cc/android/316401.html

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐