toolbar 相关问题

工具栏标签用于与工具栏的配置,设计和使用相关的问题。

WPF 工具栏中 OverFlowButton 的颜色

有问题。当我更改 WPF 工具栏的背景颜色时,右上角的溢出按钮不会改变颜色。如何修复它? 例子: 替代文本 http://biztimes.ru/toolbar.jpg

回答 4 投票 0

如何获取QToolbar中Widget的全局位置?

我有代码: 自动工具栏 = new QToolBar(&mainWidget); 工具栏->移动(50,50); // 随机 pos,但不是 (0,0); 工具栏->addWidget(new QPushButton("1-button")); 自动第二个按钮...

回答 1 投票 0

在使用 iframe 显示 pdf 时隐藏 firefox 中的 pdf 工具栏

我正在使用 iframe 在浏览器中显示 pdf 文件。它工作正常,但我想禁用/隐藏 acrobat 工具栏(下图)。 我尝试了解决方案 #toolbar=0&statusbar=0 它在

回答 3 投票 0

MatToolbar 颜色不适用于 Angular Material v18 红色/玫瑰色

我刚刚将 Angular CLI 和 Angular Material 升级到 v18。除了 MatToolbar 之外,所有 Angular Material 组件都可以正常工作。问题是颜色输入在 mat-tool 中不起作用......

回答 1 投票 0

AppCompat 工具栏上的菜单项着色

当我将 AppCompat 库中的可绘制对象用于工具栏菜单项时,着色会按预期工作。像这样: 当我将 AppCompat 库中的可绘制对象用于我的 Toolbar 菜单项时,着色会按预期工作。像这样: <item android:id="@+id/action_clear" android:icon="@drawable/abc_ic_clear_mtrl_alpha" <-- from AppCompat android:title="@string/clear" /> 但是,如果我使用自己的可绘制对象,或者实际上将可绘制对象从 AppCompat 库复制到我自己的项目中,它根本不会着色。 <item android:id="@+id/action_clear" android:icon="@drawable/abc_ic_clear_mtrl_alpha_copy" <-- copy from AppCompat android:title="@string/clear" /> AppCompatToolbar中是否有一些特殊的魔法只能为该库中的可绘制对象着色?有什么方法可以让它与我自己的绘图一起使用吗? 使用 compileSdkVersion = 21 和 targetSdkVersion = 21 在 API 级别 19 设备上运行此程序,并使用 AppCompat 中的所有内容 abc_ic_clear_mtrl_alpha_copy 是 abc_ic_clear_mtrl_alpha 中的 AppCompat png 的精确副本 编辑: 着色基于我在主题中为 android:textColorPrimary 设置的值。 例如<item name="android:textColorPrimary">#00FF00</item>会给我一种绿色色调。 截图 使用 AppCompat 的可绘制对象按预期进行着色 着色不适用于从 AppCompat 复制的可绘制对象 在新的支持库v22.1之后,您可以使用类似这样的东西: @Override public boolean onCreateOptionsMenu(Menu menu) { getMenuInflater().inflate(R.menu.menu_home, menu); Drawable drawable = menu.findItem(R.id.action_clear).getIcon(); drawable = DrawableCompat.wrap(drawable); DrawableCompat.setTint(drawable, ContextCompat.getColor(this,R.color.textColorPrimary)); menu.findItem(R.id.action_clear).setIcon(drawable); return true; } app:iconTint 属性在支持库中的 SupportMenuInflater 中实现(至少在 28.0.0 中)。 已使用 API 15 及更高版本成功测试。 菜单资源文件: <menu xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto"> <item android:id="@+id/menu_settings" android:icon="@drawable/ic_settings_white_24dp" app:iconTint="?attr/appIconColorEnabled" <!-- using app name space instead of android --> android:menuCategory="system" android:orderInCategory="1" android:title="@string/menu_settings" app:showAsAction="never" /> <item android:id="@+id/menu_themes" android:icon="@drawable/ic_palette_white_24dp" app:iconTint="?attr/appIconColorEnabled" android:menuCategory="system" android:orderInCategory="2" android:title="@string/menu_themes" app:showAsAction="never" /> <item android:id="@+id/action_help" android:icon="@drawable/ic_help_white_24dp" app:iconTint="?attr/appIconColorEnabled" android:menuCategory="system" android:orderInCategory="3" android:title="@string/menu_help" app:showAsAction="never" /> </menu> (在本例中,?attr/appIconColorEnabled是应用程序主题中的自定义颜色属性,图标资源是矢量绘图。) 在 ColorFilter 上设置 MenuItem(色调)很简单。这是一个例子: Drawable drawable = menuItem.getIcon(); if (drawable != null) { // If we don't mutate the drawable, then all drawable's with this id will have a color // filter applied to it. drawable.mutate(); drawable.setColorFilter(color, PorterDuff.Mode.SRC_ATOP); drawable.setAlpha(alpha); } 如果您想支持不同的主题并且不想仅仅为了颜色或透明度而有额外的副本,上面的代码非常有帮助。 单击此处获取帮助程序类,以在菜单中的所有可绘制对象上设置ColorFilter,包括溢出图标。 在 onCreateOptionsMenu(Menu menu) 中,只需在扩充菜单后致电 MenuColorizer.colorMenu(this, menu, color); 即可;瞧;你的图标有颜色。 因为如果你看一下AppCompat中TintManager的源代码,你会看到: /** * Drawables which should be tinted with the value of {@code R.attr.colorControlNormal}, * using the default mode. */ private static final int[] TINT_COLOR_CONTROL_NORMAL = { R.drawable.abc_ic_ab_back_mtrl_am_alpha, R.drawable.abc_ic_go_search_api_mtrl_alpha, R.drawable.abc_ic_search_api_mtrl_alpha, R.drawable.abc_ic_commit_search_api_mtrl_alpha, R.drawable.abc_ic_clear_mtrl_alpha, R.drawable.abc_ic_menu_share_mtrl_alpha, R.drawable.abc_ic_menu_copy_mtrl_am_alpha, R.drawable.abc_ic_menu_cut_mtrl_alpha, R.drawable.abc_ic_menu_selectall_mtrl_alpha, R.drawable.abc_ic_menu_paste_mtrl_am_alpha, R.drawable.abc_ic_menu_moreoverflow_mtrl_alpha, R.drawable.abc_ic_voice_search_api_mtrl_alpha, R.drawable.abc_textfield_search_default_mtrl_alpha, R.drawable.abc_textfield_default_mtrl_alpha }; /** * Drawables which should be tinted with the value of {@code R.attr.colorControlActivated}, * using the default mode. */ private static final int[] TINT_COLOR_CONTROL_ACTIVATED = { R.drawable.abc_textfield_activated_mtrl_alpha, R.drawable.abc_textfield_search_activated_mtrl_alpha, R.drawable.abc_cab_background_top_mtrl_alpha }; /** * Drawables which should be tinted with the value of {@code android.R.attr.colorBackground}, * using the {@link android.graphics.PorterDuff.Mode#MULTIPLY} mode. */ private static final int[] TINT_COLOR_BACKGROUND_MULTIPLY = { R.drawable.abc_popup_background_mtrl_mult, R.drawable.abc_cab_background_internal_bg, R.drawable.abc_menu_hardkey_panel_mtrl_mult }; /** * Drawables which should be tinted using a state list containing values of * {@code R.attr.colorControlNormal} and {@code R.attr.colorControlActivated} */ private static final int[] TINT_COLOR_CONTROL_STATE_LIST = { R.drawable.abc_edit_text_material, R.drawable.abc_tab_indicator_material, R.drawable.abc_textfield_search_material, R.drawable.abc_spinner_mtrl_am_alpha, R.drawable.abc_btn_check_material, R.drawable.abc_btn_radio_material }; /** * Drawables which contain other drawables which should be tinted. The child drawable IDs * should be defined in one of the arrays above. */ private static final int[] CONTAINERS_WITH_TINT_CHILDREN = { R.drawable.abc_cab_background_top_material }; 这几乎意味着他们将特定的资源ID列入白名单以进行着色。 但我想你总能看到他们如何对这些图像进行着色并做同样的事情。就像在可绘制对象上设置 ColorFilter 一样简单。 我个人更喜欢这个方法link 使用以下内容创建 XML 布局: <?xml version="1.0" encoding="utf-8"?> <bitmap xmlns:android="http://schemas.android.com/apk/res/android" android:src="@drawable/ic_action_something" android:tint="@color/color_action_icons_tint"/> 并从菜单中引用此绘图: <item android:id="@+id/option_menu_item_something" android:icon="@drawable/ic_action_something_tined" 本线程中的大多数解决方案要么使用更新的 API,要么使用反射,或者使用密集视图查找来获取膨胀的 MenuItem。 但是,有一种更优雅的方法可以做到这一点。您需要一个自定义工具栏,因为您的“应用自定义色调”用例与公共样式/主题 API 不能很好地配合。 public class MyToolbar extends Toolbar { ... some constructors, extracting mAccentColor from AttrSet, etc @Override public void inflateMenu(@MenuRes int resId) { super.inflateMenu(resId); Menu menu = getMenu(); for (int i = 0; i < menu.size(); i++) { MenuItem item = menu.getItem(i); Drawable icon = item.getIcon(); if (icon != null) { item.setIcon(applyTint(icon)); } } } void applyTint(Drawable icon){ icon.setColorFilter( new PorterDuffColorFilter(mAccentColor, PorterDuff.Mode.SRC_IN) ); } } 只需确保调用您的 Activity/Fragment 代码即可: toolbar.inflateMenu(R.menu.some_menu); toolbar.setOnMenuItemClickListener(someListener); 没有反射,没有视图查找,也没有那么多代码,是吧? 现在你可以忽略荒谬的onCreateOptionsMenu/onOptionsItemSelected。 这是我使用的解决方案;您可以在 onPrepareOptionsMenu() 或等效位置之后调用它。 mutate() 的原因是如果您碰巧在多个位置使用图标;如果没有变异,它们都会呈现相同的色调。 public class MenuTintUtils { public static void tintAllIcons(Menu menu, final int color) { for (int i = 0; i < menu.size(); ++i) { final MenuItem item = menu.getItem(i); tintMenuItemIcon(color, item); tintShareIconIfPresent(color, item); } } private static void tintMenuItemIcon(int color, MenuItem item) { final Drawable drawable = item.getIcon(); if (drawable != null) { final Drawable wrapped = DrawableCompat.wrap(drawable); drawable.mutate(); DrawableCompat.setTint(wrapped, color); item.setIcon(drawable); } } private static void tintShareIconIfPresent(int color, MenuItem item) { if (item.getActionView() != null) { final View actionView = item.getActionView(); final View expandActivitiesButton = actionView.findViewById(R.id.expand_activities_button); if (expandActivitiesButton != null) { final ImageView image = (ImageView) expandActivitiesButton.findViewById(R.id.image); if (image != null) { final Drawable drawable = image.getDrawable(); final Drawable wrapped = DrawableCompat.wrap(drawable); drawable.mutate(); DrawableCompat.setTint(wrapped, color); image.setImageDrawable(drawable); } } } } } 这不会解决溢出问题,但为此,你可以这样做: 布局: <android.support.v7.widget.Toolbar ... android:theme="@style/myToolbarTheme" /> 款式: <style name="myToolbarTheme"> <item name="colorControlNormal">#FF0000</item> </style> 这适用于 appcompat v23.1.0。 这对我有用: override fun onCreateOptionsMenu(menu: Menu?): Boolean { val inflater = menuInflater inflater.inflate(R.menu.player_menu, menu) //tinting menu item: val typedArray = theme.obtainStyledAttributes(IntArray(1) { android.R.attr.textColorSecondary }) val textColor = typedArray.getColor(0, 0) typedArray.recycle() val item = menu?.findItem(R.id.action_chapters) val icon = item?.icon icon?.setColorFilter(textColor, PorterDuff.Mode.SRC_IN); item?.icon = icon return true } 或者你可以在drawable xml中使用tint: <vector xmlns:android="http://schemas.android.com/apk/res/android" android:width="24dp" android:height="24dp" android:tint="?android:textColorSecondary" android:viewportWidth="384" android:viewportHeight="384"> <path android:fillColor="#FF000000" android:pathData="M0,277.333h384v42.667h-384z" /> <path android:fillColor="#FF000000" android:pathData="M0,170.667h384v42.667h-384z" /> <path android:fillColor="#FF000000" android:pathData="M0,64h384v42.667h-384z" /> </vector> @Override public boolean onCreateOptionsMenu(Menu menu) { getMenuInflater().inflate(R.menu.menu_home, menu); //One item tint menu.get(itemId).getIcon().setTint(Color); //or all for(int i=0;i<menu.size();i++){ menu.get(i).getIcon().setTint(Color); } return true; } 我发现当我使用 android:iconTint 属性时,菜单项的颜色应用在设计预览中,但没有应用在应用程序中。但是,使用 app:iconTint 应用应用程序中的颜色,而不是设计预览中的颜色。

回答 10 投票 0

有什么方法可以保存Mui DataGrid Toolbar的状态吗?

我正在使用带有默认工具栏的 React Mui DataGrid 组件。用户可以使用工具栏以多种方式配置网格,例如排序顺序/隐藏列/过滤器/更改密度等。是...

回答 3 投票 0

在使用 .toolbar 修饰符时,SwiftUI 中是否允许多个 NavigationStack 用于嵌套导航场景?

我正在开发一个 SwiftUI 应用程序,主屏幕上有一个项目列表。选择某个项目后,它会导航到该项目的详细视图。在这个详细视图上,还有其他

回答 1 投票 0

如何从工具栏中关闭键盘?

这个问题最好用代码来描述。 结构ContentView:视图{ 枚举 FocusedField { 案例类型1 案例类型2 } @State private var text: String = "" @焦点...

回答 1 投票 0

如何排列 SwiftUI 工具栏项目?

我有一个带有 4 个按钮的 SwiftUI 工具栏,但是我实现的代码不正确,因为在更改模拟器中的设备类型时,按钮最终出现在奇怪的位置。 更糟糕的是,当看到...

回答 1 投票 0

Coreldraw X3:在工具栏上添加宏

我一直通过“工具”->“Visual Basic”->“播放”使用宏。 有人知道如何将此宏添加到工具栏上吗? 蒂亚!

回答 2 投票 0

如何在窗口底部添加工具栏?

在我的 macOS 应用程序上,顶部有一个主工具栏。 但是,我想在底部添加一个新的底部工具栏(较小)。 像这样的例子: 似乎无法像在 iOS 上那样在 macOS 上执行此操作: .

回答 2 投票 0

带有 SwiftUI 的 macOS 底部的工具栏

在我的 macOS 应用程序上,顶部有一个主工具栏。 但是,我想在底部添加一个新的底部工具栏(较小)。 像这样的例子: 似乎无法像在 iOS 上那样在 macOS 上执行此操作: .

回答 2 投票 0

当我在 SwiftUI 中应用工具栏配色方案修改器时,为什么底部工具栏项目的位置会发生变化?

因此,当工具栏项目超过 2 个时,默认项目位置是左侧层次结构中的所有项目 (ToolbarItem) 和右侧层次结构中的最后一个项目 (ToolbarItem)。 之后...

回答 1 投票 0

Excel VBA 在我打开的文件中隐藏 Excel 工具栏、功能区等,而不会弄乱任何其他打开的工作簿

我使用以下代码隐藏所有栏并打开工作簿以提供应用程序的外观。从现在开始,我将其称为我的 EXCEL 应用程序样式文件。 我用来隐藏所有内容并定义......的代码

回答 3 投票 0

如何解析位置:针对 iOS (iPhone/iPad) 上的底部工具栏进行了修复

我有一个栏,通过使用position:fixed固定在我网站上每个页面的底部。问题在于,在 iPhone 或 iPad 等设备上,此属性不受尊重。 我尝试使用java...

回答 10 投票 0

WPF 名称/图像未显示在设计视图中

我正在开发一个 Visual Studio 扩展,使用 CrispImage UIElement 和此处的名字功能。然而,尽管在运行时显示,但它们在设计时并不显示。还在

回答 1 投票 0

使用热图+散点自动缩放图形会引入额外的填充

以下代码 将 numpy 导入为 np 导入plotly.graph_objects作为go def make_blob(n: int) -> np.ndarray: xx, yy = np.meshgrid(np.arange(n), np.arange(n)) 返回 np.exp(-((xx - n // 2) *...

回答 1 投票 0

如何在 SSMS 版本之间传输工具栏布局?

我已从 SSMS 19 升级到 20。我的键盘快捷键和窗格的位置(例如对象资源管理器)已被记住,但我的工具栏中的项目和这些工具的位置...

回答 1 投票 0

Android 工具栏出现在屏幕底部而不是顶部

我试图在事件发生后在屏幕底部设置一个工具栏,但该工具栏被绑定到屏幕顶部。知道如何将其设置在屏幕底部吗? 应用程序:第...

回答 3 投票 0

将 UIBarButtonItem 数组转换为 ToolbarItem 数组

我是 swiftUI 新手。我们的项目中有 UIKit 和 swiftUI 代码,并且有一些自定义逻辑来添加一些 UIBarButtonItem。我需要传递 viewController.navigationItem.rightBarButtonItems 数组

回答 1 投票 0

© www.soinside.com 2019 - 2024. All rights reserved.