[英]sherlock action item style for button in custom action bar layout
有沒有辦法將sherlock動作項目樣式(默認觸摸反饋和長按反饋和單擊區域 - 寬度/高度)應用於自定義操作欄布局中的按鈕?
SRC / MainActivity.java
getSupportActionBar().setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM);
getSupportActionBar().setCustomView(R.layout.actionbar_main);
RES /布局/ actionbar_main.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<!-- Home button -->
<ImageButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_centerVertical="true"
android:layout_marginLeft="12dp"
android:background="@drawable/ic_home"
android:contentDescription="@string/ic_home"
android:onClick="clickButtonHome" />
<!-- Centered text -->
<TextView
android:id="@+id/add_actionbar_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:text="@string/title_activity_main"
android:textAppearance="?android:attr/textAppearanceMedium" />
<!-- Cancel button -->
<ImageButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:layout_marginRight="12dp"
android:background="@drawable/ic_cancel"
android:contentDescription="@string/ic_cancel"
android:onClick="clickButtonHome" />
</RelativeLayout>
使用Widget.Sherlock.ActionButton
作為ImageButton
的樣式。 要實現長點擊吐司效果,您需要使用Roman Nurik的CheetSheet類。
為了將來參考,所有ActionBarSherlock樣式和主題都具有與原生樣式和主題相同的命名約定,但使用'Sherlock'而不是'Holo'。 例如,
Widget.Holo.ActionButton
成為Widget.Sherlock.ActionButton
Theme.Holo.Light.DarkActionBar
成為Theme.Sherlock.LightDarkActionBar
TextAppearance.Holo.Widget.ActionBar.Title
成為TextAppearance.Sherlock.Widget.ActionBar.Title
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.