亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

如何使用默認的 Navigation Drawer Activity 將項目添加到

如何使用默認的 Navigation Drawer Activity 將項目添加到

皈依舞 2023-02-23 10:14:10
所以我NavigationDrawer在android studio中創建了默認的Activity。我的問題是我想添加一個小徽標或可能更改它,ActionBar但我似乎無法找到允許我這樣做的 xml 文件。 我所說的 ActionBar 是什么意思HomeActivity.java [此文件運行 Navigation Drawer Activity]app_bar_home.xml [這是我認為包含對頂部欄的引用的文件]<?xml version="1.0" encoding="utf-8"?><android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"    xmlns:app="http://schemas.android.com/apk/res-auto"    xmlns:tools="http://schemas.android.com/tools"    android:layout_width="match_parent"    android:layout_height="match_parent"    tools:context=".HomeActivity">    <android.support.design.widget.AppBarLayout        android:layout_width="match_parent"        android:layout_height="wrap_content"        android:theme="@style/AppTheme.AppBarOverlay">        <android.support.v7.widget.Toolbar            android:id="@+id/toolbar"            android:layout_width="match_parent"            android:layout_height="?attr/actionBarSize"            android:background="@color/colorAccent"            app:popupTheme="@style/AppTheme.PopupOverlay" />    </android.support.design.widget.AppBarLayout>    <include layout="@layout/content_home" />    <android.support.design.widget.FloatingActionButton        android:id="@+id/fab"        android:layout_width="wrap_content"        android:layout_height="wrap_content"        android:layout_gravity="bottom|end"        android:layout_margin="@dimen/fab_margin"        app:srcCompat="@android:drawable/ic_media_play" /></android.support.design.widget.CoordinatorLayout>
查看完整描述

3 回答

?
ABOUTYOU

TA貢獻1812條經驗 獲得超5個贊

您獲得了正確的 XML,現在在 Toolbar 標記中執行類似的操作。1. 在工具欄中添加圖像作為背景或 2. 在工具欄中添加 ImageView 標簽


<?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="@drawable/toolbartitle" //either add a background here like this if it helps 

    local:theme="@style/MyMaterialTheme.Base"

    local:popupTheme="@style/ThemeOverlay.AppCompat.Light" />

或者


 <android.support.v7.widget.Toolbar

                android:id="@+id/toolbar"

                android:layout_width="match_parent"

                android:layout_height="?attr/actionBarSize"

                android:background="@color/color_blue"

                app:popupTheme="@style/AppTheme.PopupOverlay">


                <ImageView

                    android:id="@+id/tv_header_title"

                    android:layout_width="wrap_content"

                    android:layout_height="wrap_content"

                    android:layout_gravity="center"

                    android:src="@mipmap/header_title" />

            </android.support.v7.widget.Toolbar>


查看完整回答
反對 回復 2023-02-23
?
呼喚遠方

TA貢獻1856條經驗 獲得超11個贊

設計你自己的 ActionBar,或者簡單地添加適當的

app:showAsAction="always"

在右側菜單的 menu.xml 文件中.....


查看完整回答
反對 回復 2023-02-23
?
繁花不似錦

TA貢獻1851條經驗 獲得超4個贊

菜單文件夾中以您的抽屜活動命名的菜單文件如下代碼所示,您可以根據需要更改它


<?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_settings"

        android:orderInCategory="100"

        android:title="@string/action_settings"

        app:showAsAction="never" />

</menu>


查看完整回答
反對 回復 2023-02-23
  • 3 回答
  • 0 關注
  • 144 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號