做的Andr​​oid ActionBar的取消 [英] Android Done Cancel Actionbar

查看:110
本文介绍了做的Andr​​oid ActionBar的取消的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有什么方法来创建自定义动作条类似下面的屏幕,采用actionbarsherlock库

Is there any way to create custom actionbar like below screen, using actionbarsherlock library

推荐答案

下面是你实际上如何做到这一点的XML

Here is how you actually do it in xml

使用罗马在蜂窝布局及以上

use Roman's layout in Honeycomb and above

/layout-v11/actionbar_custom_view_done_discard.xml

/layout-v11/actionbar_custom_view_done_discard.xml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:divider="?android:attr/dividerVertical"
    android:dividerPadding="12dp"
    android:orientation="horizontal"
    android:showDividers="middle" >

    <include layout="@layout/actionbar_discard_button" />

    <include layout="@layout/actionbar_done_button" />

</LinearLayout>

/layout-v11/actionbar_discard_button.xml

/layout-v11/actionbar_discard_button.xml

<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/actionbar_discard"
    style="?android:actionButtonStyle"
    android:layout_width="0dp"
    android:layout_height="match_parent"
    android:layout_weight="1"
    android:background="@drawable/selectable_background_mystyle" >

    <TextView style="?android:actionBarTabTextStyle"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="center"
        android:paddingRight="20dp"
        android:drawableLeft="@drawable/ic_menu_cancel"
        android:drawablePadding="8dp"
        android:gravity="center_vertical"
        android:text="@string/menu_cancel" />
</FrameLayout>

/layout-v11/actionbar_done_button.xml

/layout-v11/actionbar_done_button.xml

<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/actionbar_done"
    style="?android:actionButtonStyle"
    android:layout_width="0dp"
    android:layout_height="match_parent"
    android:layout_weight="1"
    android:background="@drawable/selectable_background_mystyle" >

    <TextView
        style="?android:actionBarTabTextStyle"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="center"
        android:drawableLeft="@drawable/ic_menu_save"
        android:drawablePadding="8dp"
        android:gravity="center_vertical"
        android:paddingRight="20dp"
        android:text="@string/menu_save" />

</FrameLayout>

和动作条夏洛克反向移植它

and backport it with ActionBar Sherlock

/layout/actionbar_custom_view_done_discard.xml

/layout/actionbar_custom_view_done_discard.xml

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="horizontal" >

   <include layout="@layout/actionbar_discard_button" />

    <View
        android:layout_width="0.5dp"
        android:layout_height="match_parent"
        android:layout_marginTop="12dp"
        android:layout_marginBottom="12dp"
        android:background="#55FFFFFF" />

    <include layout="@layout/actionbar_done_button" />

</LinearLayout>

/layout/actionbar_discard_button.xml

/layout/actionbar_discard_button.xml

<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/actionbar_discard"
    android:layout_width="0dp"
    android:layout_height="match_parent"
    android:layout_weight="1"
    android:paddingRight="20dp"
    android:background="@drawable/selectable_background_mystyle" >

    <TextView
        style="@style/Widget.Sherlock.ActionBar.TabText"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="center"
        android:drawableLeft="@drawable/ic_menu_cancel"
        android:drawablePadding="8dp"
        android:gravity="center_vertical"
        android:text="@string/menu_cancel" />

</FrameLayout>

/layout/actionbar_done_button.xml

/layout/actionbar_done_button.xml

<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/actionbar_done"
    android:layout_width="0dp"
    android:layout_height="match_parent"
    android:layout_weight="1"
    android:paddingRight="20dp"
    android:background="@drawable/selectable_background_mystyle" >

    <TextView
        style="@style/Widget.Sherlock.ActionBar.TabText"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="center"
        android:drawableLeft="@drawable/ic_menu_save"
        android:drawablePadding="8dp"
        android:gravity="center_vertical"
        android:text="@string/menu_save" />

</FrameLayout>

这篇关于做的Andr​​oid ActionBar的取消的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆