我有一个相当简单的 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" />
<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" />
<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" />
<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
android:id="@+id/navigation_cancel_button"
android:layout_width="75dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:text="@string/cancel" />
</LinearLayout>
</LinearLayout>
图片@drawable/chapter_select
是一个相当小的 (41*41) png 文件,位于 res/drawable 文件夹中。
似乎这是 Android 的一个错误,有时可绘制文件夹中的第一个图像不会显示。将名为 aaaa.png 的虚拟图像添加到可绘制文件夹中,问题得到解决。在这里找到了答案:ImageButton 不显示特定的可绘制对象 https://stackoverflow.com/questions/5177602/imagebutton-does-not-display-an-particular-drawable
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)