content: package com.cjj.android_materialdelete;
  
  
  import android.os.Build;
  import android.os.Bundle;
  import android.support.v7.app.AppCompatActivity;
  import android.support.v7.widget.Toolbar;
  import android.view.View;
  import android.view.ViewGroup;
  import android.view.WindowManager;
  import android.widget.LinearLayout;
  
  /**
   * Created by Administrator on 2015/9/6.
   */
  public class BaseActivity extends AppCompatActivity {
  
      private LinearLayout rootLayout;
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          super.setContentView(R.layout.activity_base);
          if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
              WindowManager.LayoutParams localLayoutParams = getWindow().getAttributes();
              localLayoutParams.flags = (WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS | localLayoutParams.flags);
          }
          initToolbar();
      }
  
      private void initToolbar() {
          Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
          if (toolbar != null) {
              setSupportActionBar(toolbar);
          }
      }
  
      @Override
      public void setContentView(int layoutId) {
          setContentView(View.inflate(this, layoutId, null));
      }
  
      @Override
      public void setContentView(View view) {
          rootLayout = (LinearLayout) findViewById(R.id.root_layout);
          if (rootLayout == null) return;
          rootLayout.addView(view, new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
          initToolbar();
      }
  }
  