• 博客园logo
  • 会员
  • 众包
  • 新闻
  • 博问
  • 闪存
  • 赞助商
  • HarmonyOS
  • Chat2DB
    • 搜索
      所有博客
    • 搜索
      当前博客
  • 写随笔 我的博客 短消息 简洁模式
    用户头像
    我的博客 我的园子 账号设置 会员中心 简洁模式 ... 退出登录
    注册 登录
山高我为峰
博客园    首页    新随笔    联系   管理    订阅  订阅
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
      .........  
}

 

posted on 2016-07-29 16:33  山高我为峰  阅读(16248)  评论(0)    收藏  举报
刷新页面返回顶部
博客园  ©  2004-2025
浙公网安备 33010602011771号 浙ICP备2021040463号-3