该Resources.getColor(int id)方法已被弃用.
@ColorInt
@Deprecated
public int getColor(@ColorRes int id) throws NotFoundException {
return getColor(id, null);
}
Run Code Online (Sandbox Code Playgroud)
我该怎么办?
android android-resources android-mnc android-6.0-marshmallow
新的Android API 22 getResources().getDrawable()现已弃用.现在最好的方法是只使用getDrawable().
改变了什么?
android android-resources android-drawable android-5.1.1-lollipop
我正在使用android.support.v7.widget.Toolbar并从这篇文章中了解如何将汉堡包图标的颜色更改为白色,但当我调用时,向上/向后箭头仍然是深色
setDisplayHomeAsUpEnabled(true);
Run Code Online (Sandbox Code Playgroud)
我怎样才能使箭头变白?
当我调用setDisplayHomeAsUpEnabled()时,这是我的工具栏的样子:

...这是我的styles.xml文件的相关部分:
<style name="AppTheme" parent="Theme.AppCompat.NoActionBar">
<item name="colorPrimary">@color/primary</item>
<item name="colorPrimaryDark">#194C5F</item>
<item name="colorAccent">@color/accent</item>
<item name="drawerArrowStyle">@style/WhiteDrawerIconStyle</item>
</style>
<style name="WhiteDrawerIconStyle" parent="Widget.AppCompat.DrawerArrowToggle">
<item name="spinBars">true</item>
<item name="color">@android:color/white</item>
</style>
Run Code Online (Sandbox Code Playgroud) 我无法改变后退按钮的颜色.我正在使用工具栏材料设计.在我的应用程序中,我应用工具栏的黑色背景,但默认情况下背面设计为黑色,这就是为什么我只想更改此后退按钮的颜色.请给我解决方案.
谢谢
是否可以更改操作栏上的溢出按钮(3个垂直点)的颜色?如果是这样,我们该怎么做?我没有找到溢出按钮的任何样式.
谢谢
我的android.support.v7.widgetAndroid应用中有一个工具栏.它的背景颜色是亮橙色,最好看的颜色是白色而不是黑色.
我的默认颜色是黑色而不是白色.由于它会与其他东西冲突,这几乎是不可能的.我无法将主要文本颜色更改为白色!
我设法改变了标题颜色. 我现在正在寻找的是如何改变动作按钮颜色(白色).
我的代码:
主要活动:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:app="http://schemas.android.com/apk/res-auto"
tools:context=".UI.activities.MainActivity">
<android.support.v7.widget.Toolbar
android:id="@+id/r2_toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="?attr/colorPrimary"
android:elevation="4dp"
app:titleTextColor="@color/primary_text_material_light"
app:subtitleTextColor="@color/primary_text_material_light"
android:theme="@style/R2Theme.Toolbar"/>
<fragment android:name="com.r2retail.r2retailapp.UI.fragments.SetupFragment"
android:layout_below="@+id/r2_toolbar"
android:id="@+id/list"
android:layout_weight="1"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</RelativeLayout>
Run Code Online (Sandbox Code Playgroud)
菜单栏:
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<item android:id="@+id/about"
android:icon="@drawable/ic_menu"
android:title="About"
app:showAsAction="never"/>
</menu>
Run Code Online (Sandbox Code Playgroud)
样式:
<resources>
<style name="R2Theme" parent="Theme.AppCompat.Light.NoActionBar">=
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorPrimary</item>
<item name="android:textColorPrimary">@color/secondary_text_material_dark</item>
<item name="android:textColorSecondaryInverse">@color/primary_text_material_light</item>
</style>
<style name="R2Theme.Toolbar" parent="R2Theme">
<item name="actionMenuTextColor">@color/primary_text_material_light</item>
</style>
</resources>
Run Code Online (Sandbox Code Playgroud) 我有一个简单的问题.
单击"搜索"图标时,如何将工具栏的颜色/或主题更改为白色?
每当点击搜索图标时,我希望工具栏为白色(背面箭头为黑色/灰色).我在MenuItem中添加了SearcView(android.support.v7.widget.SearchView)
至
然后在单击"返回"按钮时返回原始工具栏颜色.
我正在使用新的Android appcompat工具栏.我需要为汉堡图标和后退箭头图标设置相同的自定义颜色.使用drawerArrowStyle允许我更改汉堡图标而不是箭头.问题只出现在Lollipop设备上,任何前棒棒糖都可以.


这是代码:
工具栏:
<?xml version="1.0" encoding="utf-8"?>
<android.support.v7.widget.Toolbar xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:local="http://schemas.android.com/apk/res-auto"
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:minHeight="?attr/actionBarSize"
android:background="@color/my_primary"
local:theme="@style/My.Toolbar"
local:popupTheme="@style/ThemeOverlay.AppCompat.Light" />
Run Code Online (Sandbox Code Playgroud)
Style.xml:
<style name="Theme.Base" parent="Theme.AppCompat.Light">
<!-- All customizations that are NOT specific to a particular API-level can go here. -->
<item name="windowActionBar">false</item>
<item name="android:windowNoTitle">true</item>
<!-- colorPrimary is used for the default action bar background -->
<item name="colorPrimary">@color/my_primary</item>
<!-- colorPrimaryDark is used for the status bar -->
<item name="colorPrimaryDark">@color/black</item>
</style>
<style name="My.Theme" parent="Theme.Base">
<item name="drawerArrowStyle">@style/DrawerArrowStyle</item>
</style>
<style name="My.Toolbar" parent="Theme.AppCompat.NoActionBar">
<!-- color of the title …Run Code Online (Sandbox Code Playgroud) android android-appcompat android-5.0-lollipop android-toolbar
如何动态更改操作栏箭头的颜色?我不想使用像这里那样的主题,因为我的操作栏的颜色也会动态变化。
是否可以?
我的colors.xml文件中有一种颜色需要用于toolbar颜色
<resources>
<color name="MAIN_A">#f16264</color>
</resources>
Run Code Online (Sandbox Code Playgroud)
现在我需要MAIN_A用作颜色toolbar.
android android-layout android-activity android-actionbar android-studio