android - 9 fragment 中的补丁图像奇怪行为

标签 android android-fragments actionbarsherlock android-support-library

正如 one of my questions 中所建议的那样我必须使用带有渐变的 9 补丁图像作为 ListView 项目背景。

但是当我使用 9-patch 图像时,渐变仍然存在问题:

enter image description here

9-patch, test.9.png:

enter image description here

但是当我在渐变和底部 9 补丁线之间留下 1 px 高度的透明线时,它响应水平内容放置一切正常,而且我有漂亮的渐变。

9 补丁图像:

enter image description here

靠近看透明线:

enter image description here

结果是:

enter image description here

我有好看的渐变,但有透明线,我不需要。由于这条线,在图像上您可以看到列表后面的黑色背景。如何绘制 9-patch 图像以获得良好的渐变并且背景中没有“孔”?

我正在为 fragment 使用 actionbarsherlock。

最佳答案

Draw9patch 图像不能很好地处理渐变你会发现在几个 Android 操作系统中显示它有一些差异所以不要使用它。

使用 GradientDrawable

Changing gradient background colors on Android at runtime

Creating Nine (9) Patch png files with Gradients

关于android - 9 fragment 中的补丁图像奇怪行为,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13979298/

相关文章:

java - 如果不从已销毁的 Activity 中移除,监听器是否会造成内存泄漏?

android - 使用 navhost 在底部导航中停止 fragment 刷新

android - 来自 viewpager2 和我的父 fragment 的 SharedViewModel

android - fragment 内容未加载到 BottomNavigationView FragmentTransaction

android - 使用 ActionBarSherlock/HoloEverywhere Light 的对话框

java - 无法实例化服务 br.com.brainweb.brainfeed.milkpoint.GCMItentService

android - 在Android Studio版本4.0中意外退出“获取错误过程”

java - 当我单击带有滑动菜单的菜单图标时崩溃

Android ImageView 在 GingerBread 下面的 FrameLayout 中不匹配_parent

android - 将项目添加到操作栏(使用 ActionBarSherlock)