View系列:Material Design: ActionBar 使用详解

Android MD (Material Design)设计

1:Android ActionBar 使用系统风格

      1: ActionBar是google给用户提供了一种全局统一的界面风格和操作方式

       2:如何修改系统的ActionBar风格,并定义成自己的 ActionBar风格,首先我们知道ActionBar可以添加自定义的布局样式(setCustomView),那么突破口就在这里了,我们可以通过自定义布局样式,在这个布局文件里面添加我们需要在ActionBar上面显示的标题和控件等

@Override  
     protected void onCreate(Bundle savedInstanceState) {  
    super.onCreate(savedInstanceState);  
    setContentView(R.layout.activity_main);  
    setCustomActionBar();  
}  
  
private void setCustomActionBar() {  
    ActionBar.LayoutParams lp =new ActionBar.LayoutParams(ActionBar.LayoutParams.MATCH_PARENT, ActionBar.LayoutParams.MATCH_PARENT, Gravity.CENTER);  
    View mActionBarView = LayoutInflater.from(this).inflate(R.layout.actionbar_layout, null);  
    ActionBar actionBar = getActionBar();  
    actionBar.setCustomView(mActionBarView, lp);  
    actionBar.setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM);  
    actionBar.setDisplayShowCustomEnabled(true);  
    actionBar.setDisplayShowHomeEnabled(false);  
    actionBar.setDisplayShowTitleEnabled(false);  
} 
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"  
    android:layout_width="match_parent"  
    android:layout_height="match_parent">  
  
    <TextView  
        android:id="@android:id/title"  
        android:layout_width="wrap_content"  
        android:layout_height="wrap_content"  
        android:layout_centerInParent="true"  
        android:text="标题"  
        android:textColor="#ffffff"/>  
</RelativeLayout>  

Android ActionBar应用实战,高仿微信主界面的设计_郭霖的专栏-CSDN博客_android 高仿微信

Android ActionBar和ToolBar的使用 - 简书参考 1、android中的ActionBar和ToolBar2、『Material Design入门学习笔记』主题与AppCompatActivity(附demo)3、An...https://www.jianshu.com/p/81d0bcb282cb

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值