2017-12-17 10 views

答えて

0

それはあなたが簡単なスタイルを使用して、それのアイコンを変更することができ、オーバーフローボタンと呼ばれています。

<style name="AppTheme.Base" parent="Theme.AppCompat.Light"> 
    <item name="actionOverflowButtonStyle">@style/OverFlow</item> 
</style> 

<style name="OverFlow" parent="Widget.AppCompat.ActionButton.Overflow"> 
    <item name="android:src">@drawable/new_icon</item> 
</style> 

またはJavaコードで

toolbar.setOverflowIcon(ContextCompat.getDrawable(this, R.drawable.new_icon)); 
0

あなたは、このようなアイコンの何かの色を変更することができます。

@Override 
public boolean onCreateOptionsMenu(Menu menu) { 
    // Inflate the menu; this adds items to the action bar if it is present. 
    getMenuInflater().inflate(R.menu.menu_main, menu); 

    MenuItem menuItem = menu.findItem(R.id.my_item_id); 

    if (menuItem != null) { 
     tintMenuIcon(this, menuItem, android.R.color.my_color); 
    } 

    return true; 
} 

public void tintMenuIcon(Context context, MenuItem item, @ColorRes int color) { 
    Drawable normalDrawable = item.getIcon(); 
    Drawable wrapDrawable = DrawableCompat.wrap(normalDrawable); 
    DrawableCompat.setTint(wrapDrawable, context.getResources().getColor(color)); 

    item.setIcon(wrapDrawable); 
} 

そして、あなたは

ActionBar actionBar = getSupportActionBar(); 
if(actionBar != null){ 
    actionBar.setTitle("My Title"); 
} 

を行うことができますが、getSupportActionBar()を呼び出す前に、アクションバーを設定することを忘れないでくださいタイトルをチャゲします。

関連する問題