回答
你必須確保你的安卓主題Android清單是這樣的:
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
</style>
而且由於Android 5不使用動作條,建議使用工具欄。你的活動已延長AppCompatActivity
import android.support.v7.app.AppCompatActivity;
//...
public class MainActivity extends AppCompatActivity {
//...
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Toolbar toolbar = (Toolbar) findViewById(R.id.appbar);
setSupportActionBar(toolbar);
}
}
您可以自定義工具欄:
<LinearLayout
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"
android:orientation="vertical"
tools:context=".MainActivity">
<android.support.v7.widget.Toolbar
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/appbar"
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:minHeight="?attr/actionBarSize"
android:background="?attr/colorPrimary"
android:elevation="4dp"
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
app:popupTheme="@style/ThemeOverlay.AppCompat.Light" >
</android.support.v7.widget.Toolbar>
</LinearLayout>
首先,感謝您的回答。 我是Android開發人員的初學者,所以這是我第一個使用導航抽屜的應用程序,我跟着教程中的每一步,所以我重新調整了在tuto應用程序中我可以看到一個導航欄,但我不知道爲什麼我不是。 – it4Astuces
我添加了你給我的代碼,但它顯示了一個錯誤,當開始說「不幸app_name已停止」的應用程序! – it4Astuces
什麼是在您的控制檯通過的例外??已包含在您的gradle這個支持庫: 依賴{ // ... 編譯 'com.android.support:appcompat-v7:22.1.1' } –
- 1. Tabwidget在android studio的工具欄/導航欄下不可見
- 2. 我的android應用程序在android市場中不可見
- 3. WordPress的導航欄不可見
- 4. 導航欄在運行時不可見
- 5. 導航欄是可見的,當我導航回主視圖
- 6. Android開發應用程序在應用程序中不可見
- 7. 導航欄上的titleview在segues後的視圖中不可見
- 8. 刪除導航欄(不可見)填充
- 9. 導航欄項目圖像不可見
- 10. Matplotlib導航工具欄不可見
- 11. 將導航欄放在Android應用程序的屏幕底部
- 12. 在WebView中刪除導航欄Android應用程序
- 13. 什麼系統應用程序在Android中繪製導航欄?
- 14. 如何在Android應用程序代碼中隱藏導航欄
- 15. 如何在android應用程序中永久隱藏導航欄?
- 16. 谷歌地圖是不可見在我的Android應用程序
- 17. 總是可見的導航欄
- 18. 檢查導航欄的可見性
- 19. 透明導航欄的可見按鈕
- 20. 我的導航欄有問題。 (見圖)
- 21. 當我試圖使對象不可見/可見時,我的android應用程序崩潰 - eclipse
- 22. 工具欄/應用程序欄上的Android溢出圖標不可見
- 23. 當我打開我的應用程序永久隱藏導航欄android
- 24. Android應用程序的底部導航欄(NativeScript)
- 25. 標記欄在Eclipse中不可見
- 26. 使用引導程序的導航欄
- 27. iphone - 導航欄應用程序崩潰
- 28. Bootstrap - 我的導航欄不可擴展
- 29. 的Android - 導航欄取代我的底部導航欄
- 30. 我的引導程序崩潰導航欄沒有響應
是什麼在清單文件的應用主題? –
android:theme =「@ style/AppTheme」 – it4Astuces