android split控件,android – 如何启用Split Action Bar?

我想创建一个Android应用程序,它有3个滑动选项卡面板,每个都有5个按钮(保存,新建,删除,退出..).

我想要的完全如下:

CA3Ux.png

我创建了滑动选项卡面板.对于5个按钮,我添加了分割操作栏.但它可以像普通的分割操作栏一样工作.我的AndroidManifest.xml是:

package="com.belsoft.myapplication">

android:allowBackup="true"

android:icon="@mipmap/ic_launcher"

android:label="@string/app_name"

android:supportsRtl="true"

android:uiOptions="splitActionBarWhenNarrow"

android:theme="@style/AppTheme">

android:name=".MainActivity"

android:label="@string/app_name"

android:theme="@style/AppTheme.NoActionBar">

我哪里错了?

解决方法:

要实现splitActionBar:

只需将android:uiOptions =“splitActionBarWhenNarrow”添加到AndroidManifest.xml中的活动标签,就像这样……

`

android:name=".MainActivity"

android:uiOptions="splitActionBarWhenNarrow">`

您可以阅读更多here和here

NOTE: It is available ONLY for handset devices with a screen width

of 400dp.

要创建自定义底部工具栏:

如果要为所有设备设置它,请在此处查看我的答案(查找以创建自定义底部工具栏开头的帖子):

Creating custom bottom toolbar

I’ve already created a simple app which should demonstrate you how to

begin

47a4f0dbc2b929bda5fe6d8382666c38.png

Creating a custom ViewGroup

Here’s my activity_main.xml layout file:

06001

As you can see my parent ViewGroup is RelativeLayout, which simply

allows me to create a view at the bottom of screen.

Notice that I set layout padding to zero (I think: setting layout

margin to zero here is not necessary, the same effect). If you’d

change it, the toolbar won’t use full width and it won’t stick with

bottom of the screen.

Then I added a Linear Layout with hardcoded height which is:

06002

I wanted it, that my bottom toolbar would take full available width so

I set it as match_parent.

Next, I added some ImageButton views with images from Android

library.

There you have two possibilities:

if you really want to have a toolbar like in above example just remove in every ImageButton view this line:

06003

After removing weights and some buttons you would get a view pretty

similar to expected:

6e859c6ce4e3dbd0b6f8bbe0b534bda2.png

if you want to take the full width and make every button with the same size use in your project weight as in this mine example.

Now let’s go to my AndroidManifest.xml

06004

In that file I’d added as you can see only one additional line:

06005

to make sure that device keyboard won’t hide my custom bottom toolbar.

From: 07002

如果您有任何疑问,请随意提问.

希望它有所帮助

标签:android,android-actionbar,splitactionbar

来源: https://codeday.me/bug/20190829/1761131.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值