如何强制操作栏位于 ICS 的底部? [英] How can I force the Action Bar to be at the bottom in ICS?

查看:27
本文介绍了如何强制操作栏位于 ICS 的底部?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Ice Cream Sandwich (Android 4.0) 添加了在手机屏幕底部具有 Action Bar 的选项,这是我希望在我的应用程序中拥有的功能.中对我有用.这是清单:

<应用程序android:hardwareAccelerated="true"android:icon="@drawable/cw"android:label="@string/app_name"><activity android:label="@string/app_name"android:name=".InflationDemo"android:uiOptions="splitActionBarWhenNarrow"><意图过滤器><action android:name="android.intent.action.MAIN"/><category android:name="android.intent.category.LAUNCHER"/></意图过滤器></活动></应用程序><使用-sdk android:minSdkVersion="4"android:targetSdkVersion="11"/><supports-screens android:anyDensity="true"机器人:大屏幕=真"机器人:正常屏幕=真"机器人:smallScreens =真"android:xlargeScreens="true"/></清单>

<块引用>

此外,我注意到在运行 ICS 的 Galaxy Nexus 上,消息应用程序的底部是操作栏,顶部只有标题,因此必须可以以某种方式强制操作栏位于底部.

如果你指的是对话列表,那就是顶部和底部的ActionBar,使用splitActionBarWhenNarrow和以下设置代码:

private void setupActionBar() {ActionBar actionBar = getActionBar();ViewGroup v = (ViewGroup)LayoutInflater.from(this).inflate(R.layout.conversation_list_actionbar, null);actionBar.setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM,ActionBar.DISPLAY_SHOW_CUSTOM);actionBar.setCustomView(v,新的 ActionBar.LayoutParams(ActionBar.LayoutParams.WRAP_CONTENT,ActionBar.LayoutParams.WRAP_CONTENT,Gravity.CENTER_VERTICAL |重力.右));mUnreadConvCount = (TextView)v.findViewById(R.id.unread_conv_count);}

Ice Cream Sandwich (Android 4.0) adds the option of having the Action Bar at the bottom of the screen on phones, and that's something I'd love to have in an application of mine. The docs mention uiOptions="splitActionBarWhenNarrow" for when you want something, i.e. tabs, at the top and Action Bar shortcuts at the bottom. I've tried adding the line in the application manifest, as described in the docs, but haven't got it working thus far.

Here's an example:

Also, I noticed that on my Galaxy Nexus, which runs ICS, that the messaging application has the Action Bar the bottom and nothing but the title on the top, so it must be possible to somehow force the Action Bar to be at the bottom.

Any ideas?

解决方案

I've tried adding the line in the application manifest, as described in the docs, but haven't got it working thus far.

It worked for me in this sample project. Here is the manifest:

<?xml version="1.0" encoding="utf-8"?>
<manifest package="com.commonsware.android.actionbarbc"
          xmlns:android="http://schemas.android.com/apk/res/android">

  <application android:hardwareAccelerated="true"
               android:icon="@drawable/cw"
               android:label="@string/app_name">
    <activity android:label="@string/app_name"
              android:name=".InflationDemo"
              android:uiOptions="splitActionBarWhenNarrow">
      <intent-filter>
        <action android:name="android.intent.action.MAIN" />
        <category android:name="android.intent.category.LAUNCHER" />
      </intent-filter>
    </activity>
  </application>
  <uses-sdk android:minSdkVersion="4"
            android:targetSdkVersion="11" />
  <supports-screens android:anyDensity="true"
                    android:largeScreens="true"
                    android:normalScreens="true"
                    android:smallScreens="true"
                    android:xlargeScreens="true" />
</manifest>

Also, I noticed that on my Galaxy Nexus, which runs ICS, that the messaging application has the Action Bar the bottom and nothing but the title on the top, so it must be possible to somehow force the Action Bar to be at the bottom.

If you are referring to the conversation list, that is the ActionBar at the top and bottom, using splitActionBarWhenNarrow and the following setup code:

private void setupActionBar() {
    ActionBar actionBar = getActionBar();

    ViewGroup v = (ViewGroup)LayoutInflater.from(this)
        .inflate(R.layout.conversation_list_actionbar, null);
    actionBar.setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM,
            ActionBar.DISPLAY_SHOW_CUSTOM);
    actionBar.setCustomView(v,
            new ActionBar.LayoutParams(ActionBar.LayoutParams.WRAP_CONTENT,
                    ActionBar.LayoutParams.WRAP_CONTENT,
                    Gravity.CENTER_VERTICAL | Gravity.RIGHT));

    mUnreadConvCount = (TextView)v.findViewById(R.id.unread_conv_count);
}

这篇关于如何强制操作栏位于 ICS 的底部?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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