我有一个库,CommonLibraryWpfThemes,里面有几个Resource Dictionary XAML文件.My Themes/Generic.xml文件包含一个ResourceDictionary.MergedDictionaries声明,它将所有其他文件合并在一起.
Generic.xaml
<ResourceDictionary
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary
Source="/CommonLibraryWpfThemes;component/ResourceDictionaries/BrushDictionary.xaml" />
<ResourceDictionary
Source="/CommonLibraryWpfThemes;component/ResourceDictionaries/TextBlockDictionary.xaml" />
<ResourceDictionary
Source="/CommonLibraryWpfThemes;component/ResourceDictionaries/LabelDictionary.xaml" />
<ResourceDictionary
Source="/CommonLibraryWpfThemes;component/ResourceDictionaries/ButtonDictionary.xaml" />
<ResourceDictionary
Source="/CommonLibraryWpfThemes;component/ResourceDictionaries/WindowDictionary.xaml" />
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
Run Code Online (Sandbox Code Playgroud)
在我的应用程序项目中,我引用了CommonLibraryWpfThemes,并在我的App.xaml文件中显式引用了Generic.xml.
App.xaml - 失败
<Application
x:Class="MyApp.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<Application.Resources>
<ResourceDictionary
Source="/CommonLibraryWpfThemes;component/Themes/Generic.xaml" />
</Application.Resources>
</Application>
Run Code Online (Sandbox Code Playgroud)
这不起作用.运行我的应用程序时出现以下错误:
System.Windows.Markup.XamlParseException occurred
Message="Cannot find resource named '{_fadedOrangeBrush}'. Resource names are case sensitive. Error at object 'System.Windows.Setter' in markup file 'CommonLibraryWpfThemes;component/ResourceDictionaries/WindowDictionary.xaml' Line 18 Position 13."
Source="PresentationFramework"
LineNumber=18
LinePosition=13
Run Code Online (Sandbox Code Playgroud)
如果我直接将Generic.xaml的内容放入App.xaml,一切正常:
App.xaml - SUCCEEDS
<Application
x:Class="MyApp.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<Application.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary …
Run Code Online (Sandbox Code Playgroud) 在几个android样式教程中使用了我在android.R.style.*styles中找不到的父样式元素(http://developer.android.com/reference/android/R.style.html).
一些示例来自http://android-developers.blogspot.com/2011/04/customizing-action-bar.html操作栏文章.尼克使用父样式,如:
<style name="MyDropDownNav" parent="android:style/Widget.Holo.Light.Spinner.DropDown.ActionBar">
...
</style>
Run Code Online (Sandbox Code Playgroud)
要么
<style name="MyActionBarTabStyle" parent="android:style/Widget.Holo.Light.ActionBarView_TabView">
...
</style>
Run Code Online (Sandbox Code Playgroud)
这些父母风格来自哪里?是否可以列出所有可用的父样式?
谢谢.
我正在做的事情很简单.
您单击一个按钮(id="themes")
,它会打开一个(id="themedrop")
向下滑动的div 并列出主题.(此时我只有两个)
<button id="original">Original</button><br />
<button id="grayscale">Grayscale</button>
Run Code Online (Sandbox Code Playgroud)
现在当网站加载时,它加载style1.css(主/原始主题)
<link rel="stylesheet" type="text/css" href="style1.css">
Run Code Online (Sandbox Code Playgroud)
现在我想弄清楚的是......如何点击灰度按钮将样式表从style1.css更改为style2.css(注意:文件位于同一目录中)
任何帮助将非常感激.
我是android的新手,我正在尝试为我的应用程序中的所有复选框设置样式.我的应用程序样式设置为Theme.Holo,它是黑暗的,我希望我的列表视图上的复选框是样式Theme.Holo.Light.我不是要创建自定义样式.下面的代码似乎不起作用,根本没有任何事情发生.我需要这样做,因为我的列表视图有一个浅色纸纹理,复选框和复选框文本是白色,我想黑暗.
<style name="CustomActivityTheme" parent="@android:style/Theme.Holo">
<item name="android:checkboxStyle">@style/customCheckBoxStyle</item>
</style>
<style name="customCheckBoxStyle" parent="@android:style/Widget.Holo.Light.CompoundButton.CheckBox">
</style>
Run Code Online (Sandbox Code Playgroud)
如果为应用程序设置样式,还可以将样式设置为单个小部件吗?
我正在将旧的Dialogs切换到DialogFragment,但主题和样式似乎不起作用.
我正在使用兼容性库v4中的DialogFragment,而在onCreate方法中我尝试调用setStyle(style,theme); 有很多不同的主题,但对话框总是显示为运行Android 4.0.3的模拟器中的"旧"对话框(即,它没有在Holo主题中显示).
还有什么我应该做的吗?使用兼容性库是否会禁用Holo主题或其他内容?如果是这种情况,我应该创建两个DialogFragments,一个用于旧版本,一个用于较新版本?
谢谢!
这是我的对话框的(简化)代码.我已经尝试了Theme_Holo_Dialog_NoActionBar和Theme_DeviceDefault_Dialog_NoActionBar,但Android 4模拟器始终将对话框显示为"旧"对话框,而不是使用Holo主题.我究竟做错了什么?:(
[...]
import android.support.v4.app.DialogFragment;
[...]
public class AlertDialogFragment extends DialogFragment {
public static AlertDialogFragment newInstance(int id) {
AlertDialogFragment f = new AlertDialogFragment();
Bundle args = new Bundle();
args.putInt("id", id);
f.setArguments(args);
}
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
int style = DialogFragment.STYLE_NORMAL, theme = 0;
theme = android.R.style.Theme_Holo_Dialog_NoActionBar;
setStyle(style, theme);
}
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
mId = getArguments().getInt("id");
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity())
.setTitle(mTitle)
.setMessage(mMessage)
.setPositiveButton(getString(R.string.btn_ok), new DialogInterface.OnClickListener() {
@Override
public …
Run Code Online (Sandbox Code Playgroud) 是否有任何方法可以使WPF应用看起来像在Windows 7上运行,即使它在XP上运行?我正在寻找一些我可以粘贴的主题.我知道Codeplex上的主题项目(http://www.codeplex.com/wpfthemes),但它缺乏支持DataGrid
,这是我批判性的需要.我想也许Windows 7主题可能只是一个简单的端口,或者已存在于某个文件中.您所拥有的任何信息(即使是坏消息)都将非常感激.
更新
使用@Lars Truijens的想法,我能够获得主要控件的Windows 7外观,但遗憾的是它不能用于DataGrid
我需要的WPF Toolkit 控件.
DataGrid
Aero主题看起来像这样
DataGrid
应该是这样的
所以,如果有人有任何想法,我仍然在寻找这个问题的解决方案.也许有人为Aero主题构建了一个扩展,涵盖了WPF工具包控件?同样,非常感谢您提供的任何信息.
更新2 - 问题解决了!
要使Aero主题与WPF Toolkit控件一起使用,您只需添加第二个Aero字典,因此您的App.xaml现在应该如下所示.
<Application.Resources>
...
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary
Source="/PresentationFramework.Aero;component/themes/Aero.NormalColor.xaml" />
<ResourceDictionary
Source="pack://application:,,,/WPFToolkit;component/Themes/Aero.NormalColor.xaml" />
...
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</Application.Resources>
Run Code Online (Sandbox Code Playgroud)
另外,我建议你在DataGrid
控件中关闭网格线(因为它们看起来很糟糕):
<DataGrid GridLinesVisibility="None" ...>
Run Code Online (Sandbox Code Playgroud) 您使用什么Visual Studio颜色主题?或者只是默认值?
我试图获得一个用户选择的主题,感觉我很沮丧.在AndroidManifest.xml
工作中定义主题应该是,但(尽我所知)不能根据应用程序首选项更改:
<application
android:theme="@style/theme_sunshine"
android:icon="@drawable/icon"
android:label="@string/app_name">
Run Code Online (Sandbox Code Playgroud)
或者,在每个活动中动态设置它也可以:
someChosenTheme = PreferenceManager.getDefaultSharedPreferences(this).getString("themePreference", "theme_twilight");
setTheme(someOtherChosenTheme);
Run Code Online (Sandbox Code Playgroud)
但这看起来很混乱,我宁愿在一个地方设置整个应用程序的主题.我的第一个想法是在我的主要活动启动并在那里执行时抓住应用程序上下文:
getApplicationContext().setTheme(R.style.theme_dummy);
Run Code Online (Sandbox Code Playgroud)
我可以说,这应该是诀窍,但实际上它没有做任何事情 - 整个应用程序都有默认的Android风格.以上是否有效,如果是的话,我可能会做一些其他的愚蠢行为吗?
如果重要的话,我在API级别3工作.正确方向的产品非常感谢!
我想知道是否有可能以某种方式点击弹出对话框(或具有对话框主题的活动),并通过点击它之外来解雇它?
我做了一个快速的图片来说明它:
通常情况下,您必须按后退键才能关闭对话框,但是在Honeycomb上,由于所有的屏幕区域,可以选择只在对话框外部进行操作.
我的cocoa应用程序在新的OS X"黑暗模式"下运行时必须改变其行为.
有没有办法检测OS X样式是否设置为此模式?