android:backgroundDimAmount的文档说:
"public static final int backgroundDimAmount
弹出菜单,对话框或类似内容时的默认背景暗淡量.必须是浮点值,例如"1.2".
这也可以是对资源的引用(其形式为"@〔包:]类型:名称为")("?[包:] [类型:]名称"的形式)或主题属性包含该类型的值.
常数值:16842802(0x01010032)"
什么是这个浮动,1.2,实际上是什么意思?什么数字表示100%淡出(我可以使用的浮点数是多少?)?
我AlertDialog用下面的代码创建了一个.出于某种原因,我在Honeycomb及以上版本上获得了额外的背景(见图).代码在蜂窝以下的任何地方崩溃都很好.
MyCustomDialog仅Theme.Dialog适用于<API-11和Theme.Holo.DialogAPI-11及更高版本.
更新找到了问题#2的答案.似乎构造函数AlertDialog.Builder(Context context, int theme)是在API 11中引入的.我的修复只是将行更改为:
final AlertDialog.Builder builder = (Integer.parseInt(android.os.Build.VERSION.SDK) < 11)? new AlertDialog.Builder(this) : new AlertDialog.Builder(this,R.style.JumpDialog);
Run Code Online (Sandbox Code Playgroud)
我仍然需要问题#1的帮助

private Dialog setupKeyBoardDialog() {
if (mContact.getLocaleId() != -1) {
final AlertDialog.Builder builder = new AlertDialog.Builder(this,R.style.MyCustomDialog);
builder.setTitle("Keyboards");
mKeyboardLayouts = new KeyboardLayoutGroup();
mKeyboardLayouts.layoutNames = new CharSequence[(int) jni.getNumKeyLayouts()];
mKeyboardLayouts.layoutValue = new ArrayList<Integer>();
for (int i = 0; i < jni.getNumKeyLayouts(); i++) {
mKeyboardLayouts.layoutNames[i] = jni.LayoutInfoForIndex(i).getName();
mKeyboardLayouts.layoutValue.add(i, (int) jni.LayoutInfoForIndex(i).getLocale_id()); …Run Code Online (Sandbox Code Playgroud) 我正在构建一个包含多项选项(复选框)的对话框:
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setMultiChoiceItems(arrayResource, selectedItems, new DialogInterface.OnMultiChoiceClickListener() {
// ...
});
AlertDialog dialog = builder.create();
dialog.show();
Run Code Online (Sandbox Code Playgroud)
我有一个复选框的自定义样式:
<style name="CustomCheckBox" parent="@android:style/Widget.CompoundButton.CheckBox">
<item name="android:button">@drawable/btn_check</item>
<item name="android:textColor">@android:color/holo_purple</item>
</style>
Run Code Online (Sandbox Code Playgroud)
通过设置应用于布局中的各个复选框时,它可以很好地工作style="@style/CustomCheckBox".
但是,如何将此样式应用于创建的对话框?或者对整个主题来说......
如果它有点相关 - 我正在使用minSdkVersion=14和targetSdkVersion=19.
更新:
现在根据MattMatt的回答,我将自定义复选框样式应用于整个主题,并为对话框设置自定义样式:
<style name="AppTheme" parent="AppBaseTheme">
<item name="android:checkboxStyle">@style/CustomCheckBox</item>
<item name="android:dialogTheme">@style/CustomDialog</item>
<item name="android:alertDialogTheme">@style/CustomDialog</item>
</style>
<style name="CustomCheckBox" parent="@android:style/Widget.CompoundButton.CheckBox">
<item name="android:button">@drawable/btn_check</item>
<item name="android:checkMark">@drawable/btn_check</item>
</style>
<style name="CustomDialog" parent="@android:style/Theme.Holo.Light.Dialog">
<item name="android:checkboxStyle">@style/CustomCheckBox</item>
<item name="android:background">#aaf</item>
</style>
Run Code Online (Sandbox Code Playgroud)
现在添加到布局的任何复选框都会获得自定义样式,我可以更改对话框的背景,但对话框中的复选框不会受到任何影响......
checkbox android android-theme android-dialog android-styles
我正在尝试更改Android中交换机的颜色.我意识到我需要新的9件.我去了http://android-holo-colors.com/并选择了我的颜色并选择了(Switch Jelly Bean).要使用Switch Jelly Bean,我必须使用:https://github.com/BoD/android-switch-backport.要将它导入我的项目,我必须添加:
<item name="switchStyle">@style/Widget.Holo.CompoundButton.Switch</item>
到我的样式,然后在xml我必须像这样使用开关:
<org.jraf.android.backport.switchwidget.Switch
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
现在用开关的一切工作正常.接下来,我从android全息颜色生成器输出所有内容并将其放入正确的文件中:
然后我添加到我的xml:
<org.jraf.android.backport.switchwidget.Switch
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:thumb="@drawable/apptheme_switch_inner_holo_light"
android:track="@drawable/apptheme_switch_track_holo_light" />
但它仍然是原始的蓝色.我相信我正在做的一切正确.一切都编译(xml,java).注意:我org.jraf.android.backport.switchwidget.Switch也在我的java中导入.有任何想法吗?
在我的Android java代码中,如何在我的主题中引用颜色"colorPrimary"?
我有以下主题定义:
<!-- Application theme. -->
<style name="AppTheme" parent="AppBaseTheme">
<item name="colorPrimary">@color/myColor1</item>
<item name="colorPrimaryDark">@color/myColor2</item>
<item name="colorControlNormal">@color/myColor3</item>
<item name="colorControlActivated">@color/myColor4</item>
</style>
Run Code Online (Sandbox Code Playgroud)
我可以直接引用颜色资源(R.color.myColor1),但我更喜欢引用主题的primaryColor设置,以便在将来colorPrimary更改时保持一致.
这可能吗?
android android-xml android-theme android-styles android-color
我想在带有自定义样式的 AlertDialog 中显示一个单选列表,例如
.
所以我创建了一个自定义主题并将其作为参数提供给 AlertDialog.Builder 的构造函数。
这是显示对话框的代码:
private void showSortDialog() {
final CharSequence[] options = new String[] {"Relevance", "Newest"};
AlertDialog.Builder builder = new AlertDialog.Builder(getActivityReference(),
R.style.RadioDialogTheme);
builder.setTitle("Sort by");
builder.setSingleChoiceItems(options, -1, new DialogInterface.OnClickListener() {
. . . .
builder.create().show();
}
Run Code Online (Sandbox Code Playgroud)
这是样式:
<style name="RadioDialogTheme" parent="Theme.AppCompat.Light.Dialog.Alert">
<item name="android:textColorAlertDialogListItem">@drawable/radiobutton_textcolor_selector
</item>
<item name="android:listChoiceIndicatorSingle">@drawable/apptheme_btn_radio_holo_light
</item>
</style>
Run Code Online (Sandbox Code Playgroud)
我能够找到我在样式中添加的几个属性,以根据它们的状态更改单选按钮/文本的颜色。但我无法自定义文本外观(我想更改大小、提供填充等)。
我确定有一些属性可以用来设置文本的样式,但我找不到它。任何人都可以帮我解决这个问题吗?谢谢。
在我的应用程序中,我有单个活动和所有其他片段
我正在设置style.xml的活动背景,如下所示
<item name="android:windowBackground">@color/very_light_gray</item>
Run Code Online (Sandbox Code Playgroud)
现在只有一个特殊的片段,我想设置背景透明,我无法做到尝试下面的片段代码片段对我来说不起作用
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
// create ContextThemeWrapper from the original Activity Context with the custom theme
final Context contextThemeWrapper = new ContextThemeWrapper(getActivity(), R.style.yourCustomTheme);
// clone the inflater using the ContextThemeWrapper
LayoutInflater localInflater = inflater.cloneInContext(contextThemeWrapper);
// inflate the layout using the cloned inflater, not default inflater
return localInflater.inflate(R.layout.yourLayout, container, false);
}
Run Code Online (Sandbox Code Playgroud)
知道怎么做吗?
android android-theme android-fragments android-activity android-support-library
我有一个简单的登录界面,包含用户名和密码.
我希望它能以EditText你在Ice Cream Sandwich和Honeycomb的Holo主题中看到的方式显示.
在我的清单文件中
<application
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@android:style/Theme.Holo">
Run Code Online (Sandbox Code Playgroud)
现在文本字段不应该看起来不同,例如没有顶部,左侧和右侧边框吗?
我似乎看起来完全一样.我确信我做的事情基本上都是错误的,但欢迎任何建议.
这是我在模拟器中看到的:

我期待更像这样:http: //developer.android.com/design/building-blocks/text-fields.html
我试图完全改变我的应用程序的主题,这是我修改和尝试的:
styles.xml 在values文件夹中
<resources>
<!--
Base application theme, dependent on API level. This theme is replaced
by AppBaseTheme from res/values-vXX/styles.xml on newer devices.
-->
<style name="AppBaseTheme" parent="android:Theme.Holo">
<!--
Theme customizations available in newer API levels can go in
res/values-vXX/styles.xml, while customizations related to
backward-compatibility can go here.
-->
</style>
<!-- Application theme. -->
<style name="AppTheme" parent="AppBaseTheme">
<!-- All customizations that are NOT specific to a particular API-level can go here. -->
</style>
</resources>
Run Code Online (Sandbox Code Playgroud)
值-V11 styles.xml
<resources>
<!--
Base application theme …Run Code Online (Sandbox Code Playgroud) java android android-appcompat android-theme android-actionbaractivity