gpt4 book ai didi

ICS 上的 Android QuickContactBadge 箭头

转载 作者:行者123 更新时间:2023-11-30 03:59:06 25 4
gpt4 key购买 nike

我正在开发一个 Android 应用程序,其中包含一个 ListView ,每个项目都有一张图片。

我在每张图片上都设置了一个 QuickContact 徽章。

在android

quick contact badge ok on android<4

但是Android ICS 4或更高版本,右下角会出现一个箭头:

quickcontact badge arrow on ics

是否可以在 quickcontact 徽章上隐藏右下角的箭头?

最佳答案

此箭头称为叠加层,对于 Lollipop 和上方,以下是隐藏它的最简单方法:

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
contactBadge.setOverlay(null);
}

为了支持 pre-Lollipop,我扩展了 QuickContactBadge:

/**
* Extend the QuickContactBadge to hide the overlay.
*/
public class MyQuickContactBadge extends QuickContactBadge {

private static final String OVERLAY_FIELD_NAME = "mOverlay";

public MyQuickContactBadge(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
init();
}

public MyQuickContactBadge(Context context, AttributeSet attrs) {
super(context, attrs);
init();
}

public MyQuickContactBadge(Context context) {
super(context);
init();
}

private void init() {

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
super.setOverlay(null);
return;
}

try {
// Pre-lollipop we use reflection to null the overlay drawable
Field overlayField = QuickContactBadge.class.getDeclaredField(OVERLAY_FIELD_NAME);

// setAccessible(true) prevents IllegalAccessException
overlayField.setAccessible(true);
overlayField.set(this, null);

} catch (NoSuchFieldException | IllegalAccessException e) {
// TODO: log exception
}
}
}

关于ICS 上的 Android QuickContactBadge 箭头,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12835684/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com