- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
看看这张图片
左上角是 Android 汉堡包菜单,但它是白色的。另外,右边是一个搜索放大镜,也是白色的。问题是背景是根据呈现的内容从服务器动态加载的。
是否可以对菜单图标进行着色或提升它们,以便在出现这种情况时出现?该背景图像实际上可以是任何颜色,这实际上取决于服务器的颜色。也许也可以在它们上使用 Palette 库?
编辑:到目前为止,我的解决方案基于@Steve 的回复:
private void loadBackdrop( String inetref ) {
Log.i( TAG, "loadBackdrop : inetref=" + inetref );
String bannerUrl = MainApplication.getInstance().getMasterBackendUrl() + "/Content/GetRecordingArtwork?Inetref=" + inetref + "&Type=banner&Height=256";
Log.i(TAG, "loadBackdrop : bannerUrl=" + bannerUrl);
final ImageView imageView = (ImageView) findViewById( R.id.backdrop );
final PaletteTransformation paletteTransformation = PaletteTransformation.getInstance();
Picasso.with( this )
.load( bannerUrl )
.fit().centerCrop()
.transform( paletteTransformation )
.into(imageView, new Callback.EmptyCallback() {
@Override
public void onSuccess() {
Bitmap bitmap = ((BitmapDrawable) imageView.getDrawable()).getBitmap(); // Ew!
Palette palette = PaletteTransformation.getPalette(bitmap);
try {
int inverseColor = getComplementaryColor(palette.getVibrantColor(R.color.white));
Log.i( TAG, "loadBackdrop : inverseColor=" + inverseColor + ", Color.WHITE=" + Color.WHITE + ", Color.BLACK=" + Color.BLACK + ", Color." + ( inverseColor > ( Color.BLACK / 2 ) ? "WHITE" : "BLACK" ) );
int color = ( inverseColor > ( Color.BLACK / 2 ) ? Color.WHITE : Color.BLACK );
collapsingToolbar.setCollapsedTitleTextColor( color );
collapsingToolbar.setExpandedTitleColor( color );
Drawable newSearchMenuItem = mSearchMenuItem.getIcon();
newSearchMenuItem.mutate().setColorFilter( color, PorterDuff.Mode.SRC_IN );
mSearchMenuItem.setIcon( newSearchMenuItem );
Drawable newUpMenuItem = getResources().getDrawable( R.drawable.ic_arrow_back_white_24dp );
newUpMenuItem.mutate().setColorFilter( color, PorterDuff.Mode.SRC_IN );
getSupportActionBar().setHomeAsUpIndicator( newUpMenuItem );
} catch( Exception e ) {
Log.e( TAG, "error decoding palette from imageView", e );
}
}
@Override
public void onError() {
}
});
}
public static int getComplementaryColor( int colorToInvert ) {
float[] hsv = new float[ 3 ];
Color.RGBToHSV( Color.red( colorToInvert ), Color.green( colorToInvert ), Color.blue( colorToInvert ), hsv );
hsv[ 0 ] = ( hsv[ 0 ] + 180 ) % 360;
return Color.HSVToColor( hsv );
}
最佳答案
你应该看看this .基本上,您可以做的是为您想要着色的图标创建具有不同着色 .png 文件的自定义主题,然后根据给定的背景颜色在代码中设置这些主题;或者您可以执行与该网站上显示的内容类似的操作。希望这对您有所帮助!
编辑:你可以根据背景颜色做这样的事情:
MenuItem YOUR_MENU_ITEM = menu.findItem(R.id.YOUR_MENU_ITEM_ID);
Drawable NEW_ICON = (Drawable)YOUR_MENU_ITEM.getIcon();
NEW_ICON.mutate().setColorFilter(Color.argb(255, 200, 200, 200),PorterDuff.Mode.SRC_IN);
YOUR_MENU_ITEM.setIcon(NEW_ICON);
这会将图标染成灰色,但您可以根据需要更改滤色器的值。
What you could do to solve the issue of dynamically loaded backgrounds is to use a case or nested if statement to check background of server, and then provide a color filter option for the more common colors (red, yellow, blue, etc.) generally black/white will show up on most backgrounds so you can use those as the default value.
编辑:进行颜色匹配:
So you could do something like this which would just reverse the given color to its compliment..otherwise let me know if thats not what you are looking for
关于图像背景颜色匹配时,Android 工具栏菜单图标 "disappear",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31906627/
所以我正在尝试制作一种命运之轮游戏或刽子手。我有 33 个代表字母的按钮,1 个按钮 = 1 个字母。当用户按下其中一个时,它必须“消失”(变得禁用和不可见)。我在 SceneBuilder 中创建了
我试图让 span 元素在悬停时消失。锻炼效果不佳。 代码:(CSS) .list-item-note { font-size:9px; color:#666; font-s
使用复选框,我想更改两个单选按钮的选中状态。这工作正常,但是当再次更改复选框时,单选按钮选中视觉“消失”,而代码显示它被选中。这是怎么来的? 演示:http://jsfiddle.net/Tz99c/
每当我只是在 Eclipse 中键入一些代码,并单击灰色带状区域上的错误灯泡时,我的代码就跑掉了,我必须关闭文件并重新打开它才能看到我的代码再次编码。有人可以帮我弄清楚如何停止吗?谢谢 最佳答案 我可
我有一个相当奇怪的问题,我无法找到相关文档。我有一个使用 Delphi 内置 TDBMemo 组件的 Delphi 程序,因为该组件需要从数据库中的字段中提取数据。用户还必须能够编辑此信息,即将信息添
我正在尝试使脚本基于输入文件返回AD用户ID,显示名称和组成员身份,并将结果导出到另一个文件。 但是,组成员身份信息似乎在此过程中丢失了。 有任何想法吗? 我当前的脚本: $Result = @()
我有一个背景 Pane ,用于绘制与 BorderPane、VBox 和 HBox 结合使用时不显示的对象。此外,我的 BorderPane 没有正确定位布局(左、下、右)。我尝试过使用多个不同的 P
我在使用自定义 ArrayAdapter 的 ListActivity 中使用我的 ListView 时遇到问题。 当 ListActivity 隐藏(暂停,无论怎样)时,ArrayAdpater 中
看看这张图片 左上角是 Android 汉堡包菜单,但它是白色的。另外,右边是一个搜索放大镜,也是白色的。问题是背景是根据呈现的内容从服务器动态加载的。 是否可以对菜单图标进行着色或提升它们,以便在出
我有一个有点愚蠢的问题。问题是我的程序必须具有从数据库中删除数据的功能。是的,这不是真正的问题。但是我怎样才能删除数据而不会有其他人看到某些内容已被删除的危险。 User Table: U_ID U
我正在编写一个原型(prototype),但遇到了 GUI 问题。我希望 JPanel pCustomer 居中,但这样做它会完全消失。例如,如果我把它放在南方,一切都很好。 import javax
我正在尝试重新创建一个类似于 App Store 故事页脚中使用的 UIVisualEffectView。虽然它看起来很简单,但我无法配置模糊以在白色背景下以相同方式响应。 开箱即用,带有 .ligh
我正在尝试使用 Python 和 SQLite 更新我的用户详细信息。 目的是一次升级我的用户的所有列。 我的代码是: def update(): new_username = input("In
我的工作与网络前端开发人员/websedigner 一样独立,而且我在 Android 手机上使用 HTML5 横幅广告。在 iOS 手机和平板电脑、Chrome 或 Safari 上,它运行完美。但
我以编程方式为我的 View 设置背景图像: UIImageView *backgroundView = [[UIImageView alloc] initWithImage:[UIImage im
假设我有一个这样定义的调试函数: namespace debug { void report(std::string message); } 我能否使用一些编译器技巧,在编译时将每个调用安全地
我在幻灯片中使用响应式断点。在小屏幕上,我一次显示一张幻灯片。在大 2 上(大意味着小于 990 像素) 示例:我将断点设置为在小屏幕上一次显示一张幻灯片,并在大屏幕上禁用 slider 。我有 8
我正在尝试用 Java 实现一个基本的物理引擎,并且使用 JOGL 绑定(bind),以便可以可视化结果。我可以轻松地创建和旋转形状,但在操作视口(viewport)和移动形状时遇到了问题。 我不认为
这个问题不太可能对任何 future 的访客有帮助;它只与一个较小的地理区域、一个特定的时间点或一个非常狭窄的情况相关,通常不适用于全世界的互联网受众。如需帮助使此问题更广泛适用,visit the
我有以下问题:我试图显示一个箭头,如果我从#colorSelect 中删除 overflow:hidden ,它就会起作用。但我需要 overflow:hidden 因为我里面有流元素。 我该如何解决
我是一名优秀的程序员,十分优秀!