简体   繁体   English

自定义操作栏布局中按钮的sherlock操作项样式

[英]sherlock action item style for button in custom action bar layout

is there a way to apply sherlock action item style (which is default touch feedback and long click feedback and click area - width/height) to button in customized action bar layout ? 有没有办法将sherlock动作项目样式(默认触摸反馈和长按反馈和单击区域 - 宽度/高度)应用于自定义操作栏布局中的按钮?

src/MainActivity.java SRC / MainActivity.java

getSupportActionBar().setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM);
getSupportActionBar().setCustomView(R.layout.actionbar_main);

res/layout/actionbar_main.xml 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>

Use Widget.Sherlock.ActionButton for the ImageButton 's style. 使用Widget.Sherlock.ActionButton作为ImageButton的样式。 To achieve the long-click toast effect you'll need to use Roman Nurik's CheetSheet class. 要实现长点击吐司效果,您需要使用Roman Nurik的CheetSheet类。

For future reference, all of the ActionBarSherlock styles and themes have the same naming convention as the native styles and themes but with 'Sherlock' instead of 'Holo'. 为了将来参考,所有ActionBarSherlock样式和主题都具有与原生样式和主题相同的命名约定,但使用'Sherlock'而不是'Holo'。 For example, 例如,

  • Widget.Holo.ActionButton becomes Widget.Sherlock.ActionButton Widget.Holo.ActionButton成为Widget.Sherlock.ActionButton
  • Theme.Holo.Light.DarkActionBar becomes Theme.Sherlock.LightDarkActionBar Theme.Holo.Light.DarkActionBar成为Theme.Sherlock.LightDarkActionBar
  • TextAppearance.Holo.Widget.ActionBar.Title becomes TextAppearance.Sherlock.Widget.ActionBar.Title TextAppearance.Holo.Widget.ActionBar.Title成为TextAppearance.Sherlock.Widget.ActionBar.Title

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM