预期:
但是,操作项会显示大写文字:
我尝试使用样式但没有成功。这里有一个版本:
<!-- Base application theme. -->
<style name="MyTheme" parent="Theme.AppCompat.Light">
<item name="colorPrimary">@android:color/white</item>
<item name="colorPrimaryDark">@android:color/white</item>
<item name="android:textAllCaps">false</item>
<item name="android:capitalize">none</item>
<item name="android:windowNoTitle">true</item>
<item name="android:actionButtonStyle">@style/ActionButton</item>
<item name="android:textAppearance">@style/Text</item>
<item name="android:actionMenuTextAppearance">@style/ActionMenu</item>
<item name="windowActionBar">false</item>
</style>
<style name="ActionButton" parent="Base.Widget.AppCompat.ActionButton">
<item name="textAllCaps">false</item>
</style>
<style name="ActionMenu" parent="Base.TextAppearance.AppCompat.Widget.ActionBar.Menu">
<item name="textAllCaps">false</item>
</style>
<style name="Text" parent="TextAppearance.AppCompat">
<item name="textAllCaps">false</item>
</style>
</resources>
菜单:
<?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/action_item"
android:title="action item"
app:showAsAction="always" />
</menu>
布局:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:background="@android:color/darker_gray"
android:layout_width="match_parent"
android:layout_height="wrap_content">
</android.support.v7.widget.Toolbar>
</LinearLayout>
谁真的知道应该更改哪个属性才能获得所需的结果?
答案 0 :(得分:3)
您可以尝试这种方式,为菜单标题制作文字布局:
<?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/action_item"
app:actionLayout="@layout/action_title"
app:showAsAction="always" />
</menu>
布局action_title
:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
>
<TextView
android:id="@+id/action_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="action item"
android:textSize="10sp"
android:textColor="@color/black"
/>
</LinearLayout>
现在action title
应该显示你提供的内容