Android TextView 顶部图像无法在 2.3 上正确呈现

标签 android image android-layout textview rendering

当我在 Android 版本 >=4 中运行我的 android 应用程序时,我得到了这个输出(我没有在 android 版本 3 中测试):
enter image description here

在 android 2.3 版中运行相同的应用程序时,我得到了一些不同的输出:
enter image description here

您可以在第二个屏幕截图中看到关于按钮的图像不可见。但是当我尝试在 2.3 上多次运行同一个应用程序时,有时我会看到图像可见。
这是我的代码:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >

<include layout="@layout/actionbar_with_right_button" />

<ScrollView
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_gravity="center"
    android:scrollbars="none" >

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_gravity="center"
        android:gravity="center"
        android:orientation="vertical" >

        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:clickable="true"
            android:drawablePadding="@dimen/settings_text_view_drawable_padding"
            android:drawableTop="@drawable/snooze_button"
            android:gravity="center"
            android:onClick="showRemainderSnoozeSettings"
            android:padding="@dimen/settings_text_view_padding"
            android:text="@string/snooze" />

        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:clickable="true"
            android:drawablePadding="@dimen/settings_text_view_drawable_padding"
            android:drawableTop="@drawable/help_button"
            android:gravity="center"
            android:onClick="showFaq"
            android:padding="@dimen/settings_text_view_padding"
            android:text="@string/help" />

        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:clickable="true"
            android:drawablePadding="@dimen/settings_text_view_drawable_padding"
            android:drawableTop="@drawable/about_button"
            android:gravity="center"
            android:onClick="showAbout"
            android:padding="@dimen/settings_text_view_padding"
            android:text="@string/about" />
    </LinearLayout>
</ScrollView>

我不明白为什么会这样。
谁能帮我解决这个问题。
编辑: 当我将 android:drawableTop="@drawable/about_button"更改为 about TextView 的 android:drawableTop="@drawable/help_button"时,我忘了提一件更重要的事情。它工作得很好。所以这可能是我的 about_button 图片的问题。所以我再次重新创建了关于图像并将所有可绘制文件夹放入。即使在那之后我也没有得到任何 +ve 结果。此问题仅在 2.3 或更低版本中出现。
谢谢

最佳答案

希望这对你有帮助:

这似乎是 android 的一个错误,有时 drawable folder 中的第一张图片不会显示......

我有一个类似的错误 - 一个特定的可绘制对象没有被显示,无论在什么 ImageView 中。所以我在 drawable 文件夹中添加了一个名为 aaaa.png 的虚拟图像,问题就解决了....

关于Android TextView 顶部图像无法在 2.3 上正确呈现,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18181425/

相关文章:

android - 在哪里可以看到现有应用程序的 Firebase 崩溃报告

java - Android:.java 文件可从 .apk 文件读取?

android - 使用 aapt 工具读取 apk 文件的较少信息

java - Android 包含参数 - 数据绑定(bind)不解析变量

android - 我想在对话框 fragment 中设置最大高度

Android:我可以使用 Design Support Library 而不是 Material Design UI 的 AppCompat 吗?

android - 图像太大会导致应用程序返回到以前的 Activity 吗?

image - MATLAB 的函数 imfill() 导致错误

html - "Background-Image"不能在 CSS 中使用 "height:auto"?

android - 如何在点击编辑文本时播放声音