我在TextInputLayout主题中使用上述属性来使激活时的下划线颜色为绿色TextInputLayout。
<item name="colorControlActivated">#27e905</item>
Run Code Online (Sandbox Code Playgroud)
它工作正常,我得到以下结果
但正如您所看到的,colorControlActivated也会影响浮动提示颜色。我需要不同的颜色来显示浮动提示。有什么办法可以这样做吗?
我最近使用了https://material.io/tools/color/上的材料调色板生成器来生成调色板。
如您所见,该工具是 Material.io 上的官方工具。它生成了几种颜色 - 主要颜色和次要颜色,包括每种颜色的两种变体。这导致我在我的colors.xml文件中创建了这样的东西。
<!-- Color palette -->
<!-- ... -->
<!-- Colors by usage -->
<color name="colorPrimary">@color/black</color>
<color name="colorPrimaryDark">@color/blackDark</color>
<color name="colorPrimaryLight">@color/gray</color>
<color name="colorSecondary">@color/red</color>
<color name="colorSecondaryDark">@color/maroon</color>
<color name="colorSecondaryLight">@color/redLight</color>
<color name="colorTextOnPrimary">@color/white</color>
<color name="colorTextOnSecondary">@color/white</color>
Run Code Online (Sandbox Code Playgroud)
但是,如何在我的主题中应用这些颜色?Android 支持材料 (AppCompat) 主题只需要/允许三种颜色 - 主要、次要和重音。我应该使用另一个主题来应用这些属性吗?或者我只是在这里做错了什么?
我想避免在这里创建一个全新的主题,并且必须为我可能想要使用的每个组件手动设置颜色。
android android-theme android-styles material-design android-palette
我们如何使用样式自定义android警报对话框的字体
我找到了很多使用
setTypeFace()方法的解决方案。但我想使用样式自定义整个应用程序警报对话框。
我想更改标题、消息、按钮字体。
我能够使用以下代码更改消息字体。
我的警报对话框样式声明
<style name="MyAlertDialougeTheme" parent="@android:style/Theme.Material.Light.Dialog.Alert">
<item name="android:textAppearanceSmall">@style/MyTextAppearance</item>
<item name="android:textAppearanceLarge">@style/MyTextAppearance</item>
<item name="android:textAppearanceMedium">@style/MyTextAppearance</item>
</style>
Run Code Online (Sandbox Code Playgroud)
显示警报对话框的 Java 代码
AlertDialog.Builder builder = new AlertDialog.Builder(MainActivity.this,
R.style.MyAlertDialougeTheme);
builder.setTitle("Warning")
.setMessage("My message here")
.setPositiveButton("yes", null)
.setNegativeButton("no", null)
.show();
Run Code Online (Sandbox Code Playgroud)
在屏幕下方查看
请帮助我使用样式更改标题和按钮字体,我还想自定义负按钮和正按钮的字体颜色。
提前感谢您的时间和帮助!!
我在我的项目中使用CalendarView,我需要对其进行特殊的设计。我可以更改 CalendarView 中所有内容的颜色,但只能更改日历顶部月份的颜色。我尝试了xml中的所有属性。如何更改月份铭文和箭头的颜色?
<CalendarView
android:id="@+id/calendarID"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:contentDescription="Heh"
android:maxDate="31/12/2018"
android:minDate="09/01/2012"
android:showWeekNumber="false"
android:focusedMonthDateColor="@android:style/TextAppearance.Small"
android:background="#004366"
android:unfocusedMonthDateColor="@android:style/TextAppearance.Small"
android:dateTextAppearance="@android:style/TextAppearance.Small"
android:weekDayTextAppearance="@android:style/TextAppearance.Small"
android:weekSeparatorLineColor="@android:style/TextAppearance.Small"
android:selectedWeekBackgroundColor="@android:style/TextAppearance.Small"
/>
Run Code Online (Sandbox Code Playgroud)
LayoutInflater inflater = (LayoutInflater)getApplicationContext().getSystemService
(Context.LAYOUT_INFLATER_SERVICE);
LinearLayout ll= (LinearLayout)inflater.inflate(R.layout.calendar_moi, null, false);
CalendarView cv = (CalendarView) ll.getChildAt(0);
Long maxData = System.currentTimeMillis();
cv.setMaxDate(maxData);
cv.setOnDateChangeListener(new CalendarView.OnDateChangeListener() {
@Override
public void onSelectedDayChange(CalendarView view, int year, int month,
int dayOfMonth) {
}
});
new AlertDialog.Builder(ItemClassActivity.this)
.setTitle("")
.setMessage("")
.setView(ll)
.setPositiveButton("Ok", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int whichButton) {
}
}).setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface …Run Code Online (Sandbox Code Playgroud) android android-layout android-view calendarview android-styles
我想做一些非常简单的事情:更改AppBarLayout整个主题的组件背景。
这是我的主题,我不知道要覆盖哪个属性:
<style name="BaseTheme" parent="Theme.MaterialComponents.Light.NoActionBar">
<!-- Some color attributes that doesn't actually matter... -->
</style>
Run Code Online (Sandbox Code Playgroud)
这是AppBarLayout我想应用于上述主题的新主题:
<style name="DefaultAppBarLayout" parent="Widget.Design.AppBarLayout">
<item name="android:background">@android:color/transparent</item>
</style>
Run Code Online (Sandbox Code Playgroud)
我应该从另一个父级继承样式吗BaseTheme?或者<item name="attribute_name"></item>我应该将我的新风格应用到哪些方面?
<com.google.android.material.appbar.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<androidx.appcompat.widget.Toolbar
android:id="@+id/more_actionbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:title="@string/moremenu_fragment_title"/>
</com.google.android.material.appbar.AppBarLayout>
Run Code Online (Sandbox Code Playgroud)
这是我想写的代码;无需每次都指定“背景颜色=白色”
适用于它的代码;但我不想android:background="@color/colorTrueWhite"为AppBarLayout我的 XML 中的每个内容编写
<com.google.android.material.appbar.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/colorTrueWhite">
<androidx.appcompat.widget.Toolbar
android:id="@+id/more_actionbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:title="@string/moremenu_fragment_title"/>
</com.google.android.material.appbar.AppBarLayout>
Run Code Online (Sandbox Code Playgroud) 我们将我们的应用程序定位在 api 28 并在状态栏下绘制内容。为此,我们使用以下标志和样式:
window.addFlags(FLAG_LAYOUT_NO_LIMITS)
Run Code Online (Sandbox Code Playgroud)
<item name="windowNoTitle">true</item>
<item name="android:windowTranslucentStatus">true</item>
<item name="android:windowTranslucentNavigation">false</item>
<item name="android:windowDrawsSystemBarBackgrounds">false</item>
Run Code Online (Sandbox Code Playgroud)
Android Pie 上一切正常(状态栏下方和导航栏上方的内容布局)。在android Q中,导航栏是半透明的并显示在应用程序内容之上
android navigationbar android-layout android-styles android-10.0
这是我现在底部导航栏的样子:
看起来很棒吧?除此之外,现在您可以清楚地(或大部分情况下)看到每个图标,但是当您在我的设备上查看它时,您几乎看不到这些图标。
我目前有以下内容themes.xml:
...
<!-- Navigation bar colour. -->
<item name="android:navigationBarColor">@color/pink</item>
<item name="android:windowLightNavigationBar">false</item><!-- This does nothing -->
...
Run Code Online (Sandbox Code Playgroud)
目前我minSdkVersion29岁,我targetSdkVersion30岁。
我怎么能改变图标的颜色,或者如果不可能,至少让它们颜色更深,这样它们就可以看到了?
目前我有一个溢出菜单,其默认宽度为:

我想要的是:

我试过这样改变主题:
<style name="MyWorkspaceDetailTheme" parent="@android:style/Theme.Holo.Light.DarkActionBar">
<item name="android:popupMenuStyle">@style/MyPopupMenu</item>
</style>
<style name="MyPopupMenu" parent="@android:style/Widget.Holo.ListPopupWindow">
<item name="android:dropDownWidth">30dp</item>
</style>
Run Code Online (Sandbox Code Playgroud)
但没有取得任何成功.请任何人都可以帮忙.
android android-theme android-optionsmenu android-actionbar android-styles
鉴于已主题使用上下文AppTheme(如下图所示),是否有可能以编程方式获取颜色#ff11cc00没有引用R.style.MyButtonStyle,R.style.AppTheme或android.R.style.Theme_Light?
目标是获取由主题设置的按钮文本颜色,而不受特定主题或应用程序声明的资源的约束.使用android.R.style.Widget_Button并且android.R.attr.textColor没关系.
<style name="AppTheme" parent="Theme.Light">
<item name="android:buttonStyle">@style/MyButtonStyle</item>
</style>
<style name="MyButtonStyle" parent="android:style/Widget.Button">
<item name="android:textColor">#ff11cc00</item>
</style>
Run Code Online (Sandbox Code Playgroud) 我正在创建一个看起来像对话框的活动.
这是风格:
<style name="TablesDialogActivity" parent="@android:style/Theme.Holo.Dialog">
<item name="android:windowBackground">@drawable/frame_background_left</item>
</style>
Run Code Online (Sandbox Code Playgroud)
这是onCreate()的活动:
protected void onCreate(Bundle savedInstanceState) {
getWindow().setFlags(LayoutParams.FLAG_NOT_TOUCH_MODAL, LayoutParams.FLAG_NOT_TOUCH_MODAL);
getWindow().setFlags(LayoutParams.FLAG_WATCH_OUTSIDE_TOUCH, LayoutParams.FLAG_WATCH_OUTSIDE_TOUCH);
super.onCreate(savedInstanceState);
}
Run Code Online (Sandbox Code Playgroud)
并且还在活动触摸拦截器内:
@Override
public boolean onTouchEvent(MotionEvent event) {
if (event.getAction() == MotionEvent.ACTION_OUTSIDE) {
finish();
return true;
}
return false;
}
Run Code Online (Sandbox Code Playgroud)
它几乎可以工作,活动在对话界限之外触摸完成,但它也与背景活动上的按钮交互,这是不好的.有关该文档的onTouchEvent说明如果您使用了触摸事件,则应返回true.我回归真实,但似乎并非如此.