Udd*_*rne 17 android toolbar mvvmcross
当我将工具栏应用到我的应用程序中时,我遇到了这个问题,当我尝试运行app时它崩溃了.我使用了之前的所有帖子但没有运气.这是我的代码:
Style.xml
<style name="ToolBarStyle" parent="@style/Theme.AppCompat.Light">
<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>
</style>
Run Code Online (Sandbox Code Playgroud)
我试过parent ="@ style/Theme.AppCompat.Light.NoActionBar"但没有用.
Toolbar.xmal
<?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:background="?attr/colorPrimary"
android:minHeight="?attr/actionBarSize"
android:theme="@style/ToolBarStyle" />
Run Code Online (Sandbox Code Playgroud)
Manifest.axml
<application android:label="Capzure" android:theme="@style/ToolBarStyle" android:icon="@drawable/Icon"></application>
Run Code Online (Sandbox Code Playgroud)
谢谢.
Ang*_*i H 22
您的主题应如下所示,并删除@style/:
<style name="MyMaterialTheme" parent="Theme.AppCompat.NoActionBar">
<item name="windowNoTitle">true</item>
<item name="windowActionBar">false</item>
...
</style>
Run Code Online (Sandbox Code Playgroud)
然后,不要在<application/>标签中定义主题.仅使用您要使用材料设计主题的活动(即<activity>标记)来定义它.
如果您的活动延伸PreferenceActivity,AppCompatActivity或者ActionBarActivity您想要开始交易PreferenceFragment,请将您的主题更改为:
<style name="MyMaterialTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<item name="windowNoTitle">true</item>
<item name="windowActionBar">true</item>
...
</style>
Run Code Online (Sandbox Code Playgroud)
并从工具栏中删除此行:
android:theme="@style/ToolBarStyle"
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
29741 次 |
| 最近记录: |