[英]Custom background for an ActionBar Item
我想為我的操作欄項設置自定義背景/可拖動背景。 理想情況下,將“保存作業”設置為“深藍色的白色文本”按鈕。
有什么提示嗎?
直接從以下位置進行操作欄項目的基本編輯: http : //developer.android.com/training/basics/actionbar/adding-buttons.html
<!-- Settings, should always be in the overflow -->
<item android:id="@+id/SAVE_JOB" //Save job button
android:textColorolor="Your hex color" //Whatever color you want
android:background="@drawable/yourbackground" //Whatever picture you want
android:showAsAction="always" />
yourbackground
將位於您的drawable文件夾中,並且您的十六進制顏色將采用#FFFFFF
的形式。
ActionBar actionBar = getSupportActionBar();
View actionBarView = getLayoutInflater().inflate(
R.layout.custom_bar, null);
actionBar.setCustomView(actionBarView);
actionBar.setDisplayUseLogoEnabled(false);
actionBar.setDisplayShowTitleEnabled(false);
actionBar.setDisplayShowHomeEnabled(false);
actionBar.setDisplayHomeAsUpEnabled(false);
actionBar.setDisplayOptions(0, ActionBar.DISPLAY_SHOW_CUSTOM);
actionBar.setDisplayShowCustomEnabled(true);
設置您的自定義actionbarview並在xml中執行任何操作。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.