android split控件,android – 如何启用Split Action Bar?
我想创建一个Android应用程序,它有3个滑动选项卡面板,每个都有5个按钮(保存,新建,删除,退出..).我想要的完全如下:我创建了滑动选项卡面板.对于5个按钮,我添加了分割操作栏.但它可以像普通的分割操作栏一样工作.我的AndroidManifest.xml是:package="com.belsoft.myapplication">android:allowBackup="true"an
我想创建一个Android应用程序,它有3个滑动选项卡面板,每个都有5个按钮(保存,新建,删除,退出..).
我想要的完全如下:
我创建了滑动选项卡面板.对于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
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:
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)