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

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

ActionBar-帶有居中ImageView的自定義視圖,側(cè)面有操作項

ActionBar-帶有居中ImageView的自定義視圖,側(cè)面有操作項

繁花不似錦 2019-12-16 10:08:15
ActionBar-帶有居中ImageView的自定義視圖,側(cè)面有操作項我需要將“首頁”活動的自定義徽標(biāo)(使用ImageView)居中在操作欄中。我正在為此項目使用ABS。這與SO上發(fā)布的另一個問題(ActionBar徽標(biāo)居中,Action項位于側(cè)面)非常相似,但是我不確定ImageView或搜索菜單是否有所作為,因為我沒有得到想要的結(jié)果(以居中的圖片為準(zhǔn)),或者如果我剛弄錯的話?;旧?,我在左側(cè)設(shè)置一個圖標(biāo),在中心插入自定義視圖,在右側(cè)添加一個搜索圖標(biāo)(OptionsMenu)。該圖像的確確實顯示在圖標(biāo)的右側(cè),但是仍然居中。任何有關(guān)如何在操作欄中居中放置ImageView的指針將不勝感激。Home.java:public void onCreate(Bundle savedInstanceState) {    super.onCreate(savedInstanceState);    setContentView(R.layout.activity_home);    LayoutInflater inflater = (LayoutInflater) getSupportActionBar().getThemedContext()            .getSystemService(LAYOUT_INFLATER_SERVICE);    final View customActionBarView = inflater.inflate(            R.layout.actionbar_custom_view_home, null);    /* Show the custom action bar view and hide the normal Home icon and title */    final ActionBar actionBar = getSupportActionBar();    actionBar.setHomeButtonEnabled(true);    actionBar.setDisplayHomeAsUpEnabled(false);    actionBar.setDisplayShowTitleEnabled(false);    actionBar.setIcon(R.drawable.ic_ab_som);    actionBar.setCustomView(customActionBarView);    actionBar.setDisplayShowCustomEnabled(true);}@Overridepublic boolean onCreateOptionsMenu(Menu menu) {    MenuInflater inflater = new MenuInflater(this);    inflater.inflate(R.menu.search, menu);    return true;}res / layout / actionbar_custom_view_home.xml:<?xml version="1.0" encoding="utf-8"?><LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"android:layout_width="fill_parent"android:layout_height="wrap_content"android:orientation="horizontal"android:layout_gravity="center"><ImageView    android:id="@+id/actionBarLogo"    android:contentDescription="@string/application_name"    android:layout_width="wrap_content"    android:layout_height="wrap_content"    android:clickable="false"    android:duplicateParentState="false"    android:focusable="false"    android:longClickable="false"    android:padding="@dimen/padding_small"    android:src="@drawable/logo_horizontal" /></LinearLayout>
查看完整描述

4 回答

?
吃雞游戲

TA貢獻(xiàn)1829條經(jīng)驗 獲得超7個贊

代碼中的ImageView相對于LinearLayout居中,而不是相對于操作欄居中。您可以將左邊緣(android:layout_marginLeft)添加到布局中以調(diào)整圖像位置。

這樣做的另一種方法不是在操作欄中添加圖標(biāo)和操作項,而是使用帶有圖標(biāo)和按鈕的自定義布局。但是在這種情況下,您將需要自己處理操作項。


查看完整回答
反對 回復(fù) 2019-12-16
  • 4 回答
  • 0 關(guān)注
  • 521 瀏覽

添加回答

舉報

0/150
提交
取消
微信客服

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

幫助反饋 APP下載

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

公眾號

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