【问题标题】:Android TextView top image not rendering properly on 2.3Android TextView 顶部图像无法在 2.3 上正确呈现
【发布时间】:2013-08-12 07:17:18
【问题描述】:

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

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

您可以在第二个屏幕截图中看到关于按钮的图像不可见。但是当我尝试在 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" 更改为大约 TextView 的 android:drawableTop="@drawable/help_button" 时,我忘记提及另一件重要的事情。它工作得很好。所以这可能是我的 about_button 图像的问题。所以我再次重新创建了关于图像并放入所有可绘制文件夹。即使在那之后,我也没有得到任何 +ve 结果。此问题仅在 2.3 或更低版本中。
谢谢

【问题讨论】:

  • 我认为问题在于您设置的可绘制填充。尝试删除它或减少填充。您可以将 top_margin 设置为 Textview,而不是填充。
  • @Nishant 我需要在 TextView 中的文本和顶部可绘制对象之间留出一些间隙。
  • 然后尝试将 padding_top 提供给 TextView 或它的 top drwable 中的任何一个,并减少填充量。
  • 仅填充量少
  • 我不明白将 padding_top 赋予 TextView 或 drawable。看到这里drawable不是一个单独的ImageView。它也是 TextView 的一部分

标签: android image android-layout textview rendering


【解决方案1】:

希望对您有所帮助:

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

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

【讨论】:

  • 让我试试这个,让你知道
猜你喜欢
  • 1970-01-01
  • 2019-08-18
  • 1970-01-01
  • 2021-12-17
  • 2020-05-02
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2012-02-04
相关资源
最近更新 更多