簡體   English   中英

Android中操作欄上的自定義視圖的問題

[英]Issue with Custom view on Action Bar in android

我試圖在Android的ActionBar上設置自定義視圖,我的代碼如下:

        getSupportActionBar().setDisplayHomeAsUpEnabled(false);
        getSupportActionBar().setDisplayShowCustomEnabled(true);
        getSupportActionBar().setDisplayShowTitleEnabled(false);
        getSupportActionBar().setDisplayUseLogoEnabled(false);

        LayoutInflater inflator = (LayoutInflater) this
                .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        View v = inflator.inflate(R.layout.custom_actionbar_layout, null);

        getSupportActionBar().setCustomView(v);

我只想顯示自定義視圖,在這里我附加了重疊問題的屏幕截圖。 在此處輸入圖片說明

只需使用此代碼

ActionBar actionBar = getSupportActionBar();
// add the custom view to the action bar
actionBar.setCustomView(R.layout.actionbar_view);

或可以在此處查看詳細討論

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM