第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問題,去搜搜看,總會(huì)有你想問的

請(qǐng)問如何在Android4.2中更改ActionBar的背景色選項(xiàng)菜單?

請(qǐng)問如何在Android4.2中更改ActionBar的背景色選項(xiàng)菜單?

qq_花開花謝_0 2019-10-20 12:08:53
如何在Android4.2中更改ActionBar的背景色選項(xiàng)菜單?我想更改Android4.2中選項(xiàng)(溢出)菜單的背景色。我已經(jīng)嘗試了所有的方法,但它仍然顯示默認(rèn)的顏色設(shè)置的主題。我使用了以下代碼&XML吐露。MainActivity.javapublic class MainActivity extends Activity {@SuppressLint("NewApi")@Overrideprotected void onCreate(Bundle savedInstanceState) {     super.onCreate(savedInstanceState);     setContentView(R.layout.activity_main);     getActionBar().setIcon(R.drawable.ic_launcher);          getActionBar().setTitle("Sample Menu");     getActionBar().setBackgroundDrawable(new                 ColorDrawable(Color.parseColor("#33B5E5")));      int titleId = Resources.getSystem().getIdentifier("action_bar_title", "id", "android");     TextView titleText = (TextView)findViewById(titleId);     titleText.setTextColor(Color.parseColor("#ffffff"));}@Overridepublic boolean onCreateOptionsMenu(Menu menu) {     // Inflate the menu; this adds items to the action bar if it is present.     getMenuInflater().inflate(R.menu.main, menu);     setMenuBackground();     return true;}protected void setMenuBackground(){                          // Log.d(TAG, "Enterting setMenuBackGround");       getLayoutInflater().setFactory( new Factory() {著色劑<color name="menubg">#33B5E5</color>在上面的圖片中,我要將菜單背景從黑色更改為動(dòng)作欄中的藍(lán)色。..我怎么能做到這一點(diǎn),我做錯(cuò)了什么?
查看完整描述

3 回答

?
MMTTMM

TA貢獻(xiàn)1869條經(jīng)驗(yàn) 獲得超4個(gè)贊

如果人們還在訪問一個(gè)可行的解決方案,下面是對(duì)我有用的內(nèi)容:-這是Appcompat支持庫。這是ActionBar樣式的延續(xù)。在此解釋

下面是styes.xml文件。

<resources>
    <!-- Base application theme. -->
    <style name="AppTheme" parent="Theme.AppCompat.Light">
        <!-- This is the styling for action bar -->
        <item name="actionBarStyle">@style/MyActionBar</item>
        <!--To change the text styling of options menu items</item>-->
        <item name="android:itemTextAppearance">@style/MyActionBar.MenuTextStyle</item>
        <!--To change the background of options menu-->
        <item name="android:itemBackground">@color/skyBlue</item>
    </style>

    <style name="MyActionBar" parent="@style/Widget.AppCompat.Light.ActionBar.Solid.Inverse">
        <item name="background">@color/red</item>
        <item name="titleTextStyle">@style/MyActionBarTitle</item>
    </style>

    <style name="MyActionBarTitle" parent="@style/TextAppearance.AppCompat.Widget.ActionBar.Title">
        <item name="android:textColor">@color/white</item>
    </style>

    <style name="MyActionBar.MenuTextStyle"
        parent="style/TextAppearance.AppCompat.Widget.ActionBar.Title">
        <item name="android:textColor">@color/red</item>
        <item name="android:textStyle">bold</item>
        <item name="android:textSize">25sp</item>
    </style></resources>

這就是它的樣子-Menuitem背景顏色是天藍(lán)色,Menuitem文本顏色是粉紅色,文本大小為25 sp:-



查看完整回答
反對(duì) 回復(fù) 2019-10-21
  • 3 回答
  • 0 關(guān)注
  • 660 瀏覽

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)