我目前正在嘗試將我的應用程序轉換爲棒棒糖材質設計,並遇到了與操作欄/工具欄有關的一些問題。按照我所做的方式執行所有操作,操作欄/工具欄不會顯示在棒棒糖或kitkat設備上。也許有人可以看看我的主題,樣式,activity_main(我拿着一堆片段,是唯一放置工具欄xml代碼的地方)和mainactivity。ActionBar /工具欄不顯示在棒棒糖版本的應用程序
謝謝。
值/ styles.xml
<resources>
<style name="Theme.MyTheme" parent="Theme.AppCompat.Light">
<!-- Set AppCompat’s actionBarStyle -->
<item name="actionBarStyle">@menu/action_menu</item>
<!-- The rest of your attributes -->
</style>
</resources>
值/的themes.xml
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="AppTheme" parent="AppTheme.Base"/>
<style name="AppTheme.Base" parent="Theme.AppCompat">
<item name="colorPrimary">@color/material_blue_grey_800</item>
<item name="colorPrimaryDark">@color/material_blue_grey_950</item>
<item name="android:textColor">@color/black</item>
<item name="android:windowNoTitle">true</item>
<item name="windowActionBar">false</item>
</style>
</resources>
activity_main.xml中
<android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/drawerLayout"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<FrameLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/fragment_container"
android:layout_width="match_parent"
android:layout_height="match_parent" />
<RelativeLayout
android:id="@+id/drawerView"
android:layout_width="250dp"
android:layout_height="wrap_content"
android:layout_gravity="start" >
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:minHeight="?attr/actionBarSize" />
<ListView
android:id="@+id/drawerList"
android:layout_width="250dp"
android:layout_height="match_parent"
android:layout_gravity="left"
android:background="@drawable/nav_border"
android:divider="@null" />
</RelativeLayout>
<!--
<fragment
android:id="@+id/fragment1"
android:name="com.shamu11.madlibsportable.MadlibsSelect"
android:layout_width="fill_parent"
android:layout_height="fill_parent" />
-->
</android.support.v4.widget.DrawerLayout>
mainactivity
public class MainActivity extends ActionBarActivity implements
OnItemClickListener {
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Fragment fragment = new MadlibsSelect();
fragment = new MadlibsSelect();
FragmentTransaction fm = getSupportFragmentManager().beginTransaction();
fragment.setArguments(getIntent().getExtras());
fm.add(R.id.fragment_container, fragment);
fm.commit();
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
toolbar.inflateMenu(R.menu.action_menu);
//ActionBar bar = getActionBar();
//bar.setBackgroundDrawable(new ColorDrawable(Color.parseColor("#428bca")));
...more stuff happen down here including adding nav drawer.
爆炸!謝謝! – sanic 2014-11-08 18:16:53
最糟糕的答案。其他人是否應該現在對這兩個文件進行區分? – 2016-10-30 16:08:08