android-styles 相关问题

样式是一组属性,用于指定视图或窗口的外观和格式

Android DatePicker 标题不改变颜色(.Net Maui)

我创建了一个具有 Android DatePicker 的 .Net Maui 应用程序。在目录 Platforms/Android/Resources 中,我有两个文件夹 value 和 value-night 用于 Android DatePicke 的 styles.xml...

回答 1 投票 0

colorAccent 对 Android DatePicker 深色模式 (.Net Maui) 没有影响

我创建了一个具有 Android DatePicker 的 .Net Maui 应用程序。在目录 Platforms/Android/Resources 中,我有两个文件夹 value 和 value-night 用于 Android DatePicke 的 styles.xml...

回答 1 投票 0

如何去除Dialog(不是AlertDialog也不是DialogFragment)的白角?

我像这样创建了line_dialog_border.xml: ...

回答 2 投票 0

为什么 Android Studio 在我的项目中使用自定义样式时出现问题?

在布局中引用我的项目自定义样式之一时,我都会收到有关无关输入的语法错误。语法错误 样式仍然正确应用于布局和项目

回答 1 投票 0

在 Android Studio 中哪里可以找到 styles.xml 文件?

我有一个非常简单的应用程序,它运行一个 html 文件。我真的很想改变状态栏的颜色,因为黑色的标准顶部和底部对于 p 的调色板来说太糟糕了......

回答 4 投票 0

获取Android系统强调色(Android 10系统强调色)

这个问题应该很简单,但我没有找到答案。我有一个带有可选口音的应用程序,我正在尝试添加一个选项来使用 android 系统口音(像 Lawnchair 这样的应用程序有这样一个

回答 4 投票 0


在 Android 中手动输入日期时,MaterialDatePicker 文本颜色存在问题

我面临的问题是无法在对话框中手动输入日期时更改白色。我该如何改变这个颜色? 我尝试过这个但仍然不起作用。 <p>我面临的问题是无法在对话框中手动输入日期时更改白色。我该如何改变这个颜色? <a href="https://i.stack.imgur.com/n1SGJ.png" target="_blank"><img src="https://cdn.txt58.com/i/AWkuc3RhY2suaW1ndXIuY29tL24xU0dKLnBuZw==" alt=""/></a></p> <p>我尝试了这个,但仍然不起作用。</p> <pre><code>&lt;style name=&#34;MaterialCalendarTheme&#34; parent=&#34;ThemeOverlay.MaterialComponents.MaterialCalendar&#34;&gt; &lt;!-- Header panel --&gt; &lt;item name=&#34;materialCalendarHeaderLayout&#34;&gt;@style/MaterialCalendar.HeaderLayout1&lt;/item&gt; &lt;!-- Buttons --&gt; &lt;item name=&#34;buttonBarPositiveButtonStyle&#34;&gt;@style/TextButton.Dialog1&lt;/item&gt; &lt;item name=&#34;buttonBarNegativeButtonStyle&#34;&gt;@style/TextButton.Dialog1&lt;/item&gt; &lt;/style&gt; </code></pre> <pre><code>&lt;style name=&#34;MaterialCalendar.HeaderLayout1&#34; parent=&#34;Widget.MaterialComponents.MaterialCalendar.HeaderLayout&#34;&gt; &lt;!--&lt;item name=&#34;android:background&#34;&gt;?attr/colorPrimary&lt;/item&gt;--&gt; &lt;item name=&#34;android:background&#34;&gt;@color/colorPrimary&lt;/item&gt; &lt;item name=&#34;android:headerMonthTextAppearance&#34;&gt;@color/black&lt;/item&gt; &lt;/style&gt; &lt;style name=&#34;TextButton.Dialog1&#34; parent=&#34;Widget.MaterialComponents.Button.TextButton.Dialog&#34;&gt; &lt;item name=&#34;android:textColor&#34;&gt;@color/black&lt;/item&gt; &lt;/style&gt; </code></pre> </question> <answer tick="false" vote="0"> <p>如果您使用 <strong>Android Studio</strong> ,请转到 Layout 并单击您要布局的布局,然后打开 Design 并查找 textColor ,然后您就可以进行 sumach 更改,或者单击 Code ,然后在 EditText Datum 中写入 <pre><code>android:textColor=&#34;#000000&#34;</code></pre> 。试试这个并告诉我结果。</p> </answer> </body></html>

回答 0 投票 0

如何在 Android XML 中为文本添加下划线?

如何在 XML 文件中的文本下划线?我在 textStyle 中找不到选项。

回答 12 投票 0

自 Android Studio 4.1 起,Android 后台 Drawable 无法在按钮中工作

我发现从 Android Studio 4.1 开始,我无法通过在其 android:background 上设置颜色来更改 Button 的背景颜色,只是没有效果。并且自定义 Drawable 也无法正常工作。 我的

回答 6 投票 0

更改TextInputLayout的下划线颜色和浮动提示颜色

我在 TextInputLayout 主题中使用上述属性,使 TextInputLayout 激活时的下划线颜色为绿色。 #27e905...

回答 5 投票 0

我缺少哪种样式来更改 AlertDialog 按钮颜色?与 MaterialAlertDialog 配合使用效果良好

编辑:我应该提到我已经阅读了很多有关 AlertDialog 样式的答案,并尝试了我能找到的所有建议,所以请不要使其重复。 我正在测试一个示例类。 ...

回答 1 投票 0

当primaryDark为白色时更改状态栏文本颜色

我正在尝试重现 Google 日历应用程序的行为: 但我还没有找到改变状态文本颜色的方法。如果我将 colorPrimaryDark 设置为白色,我看不到图标 nei...

回答 15 投票 0

以编程方式设置 android:windowIsTranslucent

按照本教程http://cases.azoft.com/android-tutorial-floating-activity/后,我能够创建浮动活动 但是,为此,我必须在 styles.xml 中添加这一行: 按照本教程后,我能够创建浮动活动http://cases.azoft.com/android-tutorial-floating-activity/ 但是,为此,我必须在 styles.xml 中添加这一行: <item name="android:windowIsTranslucent">true</item> 仅使用 Android/Java 代码是否可以达到相同的效果? (例如在 Activity.onAttachedToWindow() 左右...) 预先感谢您的帮助。 [编辑 01] styles.xml 不得更改(而且我不应该知道其中有什么......)。但出于测试目的,我使用默认的: <resources> <style name="AppBaseTheme" parent="Theme.AppCompat.Light"> </style> <style name="AppTheme" parent="AppBaseTheme"> </style> </resources> [编辑02]Resources.Theme.applyStyle()似乎做了我想做的事情(根据API描述:“将新属性值放入主题”)。 所以我创建了以下custom_style.xml: <resources> <style name="MyCustomStyle" > <item name="android:windowIsTranslucent">true</item> </style> </resources> 然后,在onAttachedToWindow(),我打电话: getTheme().applyStyle(R.style.MyCustomStyle, true); 但是没有任何效果... 仅使用Android/Java代码是否可以达到相同的效果? 恐怕不行。您只需在 styles.xml 内完成即可。据我所知 android:windowIsTranslucent 的值无法通过编程单独更改。 当我们调用 super.onCreate(savedInstanceState); 时,Activity 类提供了一个空的图形窗口,我们可以在其中设置内容,即视图。并将主题应用于该窗口,然后将内容加载到该视图上。 因此顺序将是, 致电super.onCreate() 设置活动主题。 设置该活动的内容视图。 例如。 styles.xml <style name="AppTheme" parent="AppBaseTheme"> <!-- All customizations that are NOT specific to a particular API-level can go here. --> <item name="android:windowBackground">@drawable/background</item> <item name="android:windowNoTitle">true</item> </style> <!-- Application theme.without title bar --> <style name="AppTheme.NoTitleBar" parent="AppBaseTheme"> <!-- All customizations that are NOT specific to a particular API-level can go here. --> <item name="android:windowBackground">@drawable/background</item> <item name="android:windowNoTitle">true</item> </style> <!--Floating activity theme --> <style name="Theme_Translucent" parent="android:style/Theme.NoTitleBar.Fullscreen"> <item name="android:windowBackground">@android:color/transparent</item> <item name="android:windowFrame">@null</item> <item name="android:windowContentOverlay">@null</item> <item name="android:windowIsFloating">true</item> <item name="android:backgroundDimEnabled">true</item> <item name="android:windowIsTranslucent">true</item> <item name="android:windowNoTitle">true</item> <item name="android:windowAnimationStyle">@android:style/Animation.Dialog</item> <item name="android:windowFullscreen">true</item> </style> 然后为Floating activity设置主题,如下所示: public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setTheme(R.style.Theme_Translucent); // Set here setContentView(...) } 这样做 if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { Window w = getWindow(); // in Activity's onCreate() for instance w.setFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION, WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION); w.setFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS, WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS); } Android R 出现新方法 不能说要以编程方式执行此操作..但如果您需要执行此操作,您可以像这样尝试.. 将主题添加到清单文件中的活动中,如下所示.. android:theme="@android:style/Theme.Translucent.NoTitleBar.Fullscreen" 示例:- <activity android:name="com.example.androidhackerphonelocker.MainActivity" android:label="@string/app_name" android:theme="@android:style/Theme.Translucent.NoTitleBar.Fullscreen" > <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> 希望它能解决您的一些问题.. 也许这会有所帮助。 @Override protected void onCreate(Bundle savedInstanceState) { processSetTheme(this); getWindow().requestFeature(Window.FEATURE_NO_TITLE); getWindow().setBackgroundDrawableResource(R.color.realTranslucent); if (Build.VERSION.SDK_INT>=19){ getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION); getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS); } super.onCreate(savedInstanceState); <color name="realTranslucent">#00000000</color> 如果 android.app.Dialog window.setDimAmount(0f) window.setBackgroundDrawable(ColorDrawable(Color.TRANSPARENT)) 从 API 级别 30 开始,现在有一个 setTranslucent 方法: 将活动(尤其是具有 R.attr.windowIsTranslucent 或 R.attr.windowIsFloating 属性的活动)转换为全屏不透明活动,或将其从不透明转换回半透明。 文档

回答 7 投票 0

Android Studio(我该如何修复它?)

如何将密码文本框与用户名文本框对齐以看起来像这样的设计,或者我可以做些什么来修复它? 代码 如何将密码文本框与用户名文本框对齐,使其看起来像 或者如何修复它? 代码 <EditText android:id="@+id/aduser" android:layout_width="0dp" android:layout_height="55dp" android:layout_marginEnd="32dp" android:layout_marginStart="32dp" android:layout_marginTop="16dp" android:drawableStart="@drawable/userconfig1" android:drawablePadding="16dp" android:hint="Username" android:textColorHint="#000000" android:textStyle="bold" android:textSize="18dp" android:background="@drawable/button_bg" android:ems="10" android:inputType="text" android:textColor="#000000" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toBottomOf="@+id/imageView2" /> <com.google.android.material.textfield.TextInputLayout android:id="@+id/adpass" android:layout_width="0dp" android:layout_height="55dp" android:layout_marginStart="32dp" android:layout_marginEnd="32dp" android:layout_marginTop="24dp" android:hint="Password" app:passwordToggleEnabled="true" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toBottomOf="@+id/aduser" > <com.google.android.material.textfield.TextInputEditText android:layout_width="match_parent" android:layout_height="match_parent" android:background="@drawable/button_bg" android:drawableStart="@drawable/baseline_info_24" android:drawablePadding="16dp" android:ems="10" android:inputType="textPassword" android:textColor="#000000" android:textColorHint="#000000" android:textSize="18dp" android:textStyle="bold" /> </com.google.android.material.textfield.TextInputLayout> 我的设计如何改进?我道歉;我是 Android Studio 的新手,目前正在测试设计。 我期望的设计是用户名和密码相等并且密码的颜色与用户名不远,并且启用显示/隐藏密码。 <?xml version="1.0" encoding="utf-8"?> <androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" tools:context=".InterstitialAdsActivity"> <com.google.android.material.textfield.TextInputLayout android:id="@+id/aduserL" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginHorizontal="10dp" android:layout_marginVertical="4dp" android:hint="Username" app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toTopOf="parent"> <com.google.android.material.textfield.TextInputEditText android:id="@+id/aduser" android:layout_width="match_parent" android:layout_height="wrap_content" android:drawableStart="@drawable/ic_star" android:drawablePadding="16dp" android:ems="10" android:inputType="text" android:textColor="#000000" android:textColorHint="#000000" android:textSize="18dp" android:textStyle="bold" /> </com.google.android.material.textfield.TextInputLayout> <com.google.android.material.textfield.TextInputLayout android:id="@+id/adpass" android:layout_width="0dp" android:layout_height="wrap_content" android:layout_marginHorizontal="10dp" android:layout_marginVertical="4dp" android:hint="Password" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toBottomOf="@+id/aduserL" app:passwordToggleEnabled="true"> <com.google.android.material.textfield.TextInputEditText android:layout_width="match_parent" android:layout_height="match_parent" android:drawableStart="@drawable/ic_star" android:drawablePadding="16dp" android:ems="10" android:inputType="textPassword" android:textColor="#000000" android:textColorHint="#000000" android:textSize="18dp" android:textStyle="bold" /> </com.google.android.material.textfield.TextInputLayout> </androidx.constraintlayout.widget.ConstraintLayout> 如果您推荐观看此视频youtubeVideo

回答 1 投票 0

警报对话框消息的自定义字体

我正在为我的自定义 AlertDialog 使用以下样式。指定的字体“myfont.tff”应用于 AlertDialog 标题和按钮,但不应用于 AlertDialog 消息。我需要什么...

回答 1 投票 0

更改EditTextPreference的标题文本颜色

如何更改以下首选项 XML 中标题和摘要的颜色: 如何更改以下首选项 XML 中 title 和 summary 的颜色: <EditTextPreference android:key="username" android:title="Your Name" android:summary="Please provide your username." /> 我在我的styles.xml中尝试过这个: <style name="SettingsTheme" parent="@style/AppBaseTheme"> <item name="android:textColorPrimary">@color/green</item> <item name="android:textColorSecondary">@color/red</item> <item name="android:textColorTertiary">@color/blue</item> </style> textColorPrimary 更改标题的颜色,但它也会更改工具栏中文本的颜色(我不想要)。 textColorSecond 似乎正确地改变了摘要的颜色。 如何在不影响工具栏文本颜色的情况下更改标题颜色? 您需要像这样显式定义 EditTextPreference 的样式: <style name="SettingsTheme" parent="@style/AppBaseTheme"> <item name="android:editTextPreferenceStyle">@style/MyStyle</item> </style> <style name="MyStyle" parent="@android:style/Preference.DialogPreference.EditTextPreference"> ... </style> 这会将您在 MyStyle 中定义的任何样式仅设置为之前 EditTextPreference 默认样式的位置。 我最近也遇到了同样的问题。刚刚找到了答案。我制作了一个自定义的 EditTextPreference 并在我的代码中执行此操作来更改标题和摘要颜色,我还尝试更改图标色调(颜色)并且它正在工作,您所需要做的就是找到您需要更改的视图并应用您的视图修改如下: class MyEditTextPreference : EditTextPreference { constructor(context: Context) : super(context) constructor(context: Context, attr : AttributeSet?) : super(context, attr) constructor(context: Context, attr: AttributeSet?, i1: Int) : super(context, attr, i1) constructor(context: Context, attr: AttributeSet?, i1: Int, i2: Int) : super(context, attr, i1, i2) override fun onBindViewHolder(holder: PreferenceViewHolder) { super.onBindViewHolder(holder) (holder.findViewById(android.R.id.title) as TextView).setTextColor(Color.WHITE) (holder.findViewById(android.R.id.icon) as PreferenceImageView).imageTintList = ColorStateList.valueOf(Color.WHITE) (holder.findViewById(android.R.id.summary) as TextView).setTextColor(ResourcesCompat.getColor(context.resources, R.color.test_color, null)) } } 在你的 xml 文件中你必须使用这个 <mypackage.MyEditTextPreference app:icon="@drawable/ic_test" app:key="testKey" app:title="@string/testString" app:useSimpleSummaryProvider="true" /> 注1: 我使用了一个简单的摘要提供程序,但您可以使用您想要的任何摘要。 注2: 这些代码是用 kotlin 编写的,但您可以简单地将它们转换为 Java。 我认为最简单的方法是子类化 EditTextPreference 并在 onCreateView() 或 onBindView() 中调整标题颜色。 public class MyEditTextPreference extends EditTextPreference { // constructors omitted @Override protected void onBindView(View view) { TextView titleView = (TextView) view.findViewById(android.R.id.title); int color = getContext().getResources().getColor(R.color.preference_title); titleView.setTextColor(color); } } 然后在您的首选项 XML 中,您将使用您的类(完全限定名称): <com.package.MyEditTextPreference android:key="username" android:title="Your Name" android:summary="Please provide your username." />

回答 3 投票 0

如何制作自定义输入pin码Android?

我在 Kotlin Android 上制作项目。我怎样才能使相同的字段和相同的输入?在我看来,创建一些编辑文本并不是一个好的决定 在此输入图像描述 输入图像描述她...

回答 1 投票 0


如何设置android操作栏选项卡的高度

基本上,我想更改操作栏中选项卡的高度。这个问题在 stackoverflow 上已经被问过好几次了,例如: ActionBar 选项卡高度 我已经尝试了大部分解决方案...

回答 2 投票 0

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