app:showAsAction 和android:showAsAction

app:showAsAction

它有三个可选项
1.always:总是显示在界面上
2.never:不显示在界面上,只让出现在右边的三个点中
3.ifRoom:如果有位置才显示,不然就出现在右边的三个点中

 

 

android:showAsAction

这个属性可接受的值有:

1.alaways:这个值会使菜单项一直显示在ActionBar上。

2.ifRoom:如果有足够的空间,这个值会使菜单显示在ActionBar上。

3.never:这个值菜单永远不会出现在ActionBar是。

4.withText:这个值使菜单和它的图标,菜单文本一起显示。

 

When using the appcompat library, menu resources should refer to the showAsAction in the app: namespace, not the android: namespace.

Similarly, when not using the appcompat library, you should be using the android:showAsAction attribute.
I think the problem is that you are mixing Framework Activity and AppCompat menu. You should use AppCompatActivity with AppCompat Action bar and app:showAsAction;
or Activity with android:showAsAction.
public class MainActivity extends AppCompatActivity {//像这样的AppCompatActivity 需要使用app:showAsAction
    ..........  
}

 

public class MainActivity extends Activity{ //像这样的Activity 需要使用android:showAsAction
      .........  
}

 

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值