【问题标题】:Custom action bar--How do I swap the menu and the app icon/title?自定义操作栏——如何交换菜单和应用程序图标/标题?
【发布时间】:2014-05-20 10:01:58
【问题描述】:

我想制作一个类似于以下的自定义操作栏:

我看到了How to align items in action bar to the left?Positioning menu items to the left of the ActionBar in Honeycomb 的问题,但他们似乎没有回答我的问题。

当我处于纵向模式时,我有一个分屏。菜单图标位于底部,顶部看起来像上图的右侧。但是,在横向模式下,图标会挤在应用图标的右侧。我希望它们显示在左侧。

这是我当前用于操作栏的 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="match_parent" >

    <ImageView
        android:id="@+id/appIcon"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentRight="true"
        android:layout_centerVertical="true"
        android:src="@android:drawable/ic_app" />

    <TextView
        android:id="@+id/tvAppTitle"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_centerVertical="true"
        android:layout_toLeftOf="@+id/appIcon"
        android:text="@string/app_name" />

</RelativeLayout>

【问题讨论】:

    标签: android android-actionbar


    【解决方案1】:

    由于我找不到使用操作栏的解决方案,所以我用

    隐藏了操作栏
    <item name="android:windowActionBar">false</item>
    <item name="android:windowNoTitle">true</item>
    

    在styles.xml 中,然后创建一个自定义布局来模拟在纵向的顶部和底部有一个操作栏,并且只在横向的顶部。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-08-08
      • 1970-01-01
      • 1970-01-01
      • 2013-12-04
      • 1970-01-01
      相关资源
      最近更新 更多