android.support.v7.app.ActionBar#LayoutParams ( )源码实例Demo

下面列出了android.support.v7.app.ActionBar#LayoutParams ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: KSYMediaPlayer_Android   文件: MainActivity.java
public void setActionBarLayout(int layoutId, Context mContext) {
    ActionBar actionBar = getSupportActionBar();
    if (null != actionBar) {
        actionBar.setDisplayShowHomeEnabled(false);
        actionBar.setDisplayShowCustomEnabled(true);
        actionBar.setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM);
        LayoutInflater inflator = (LayoutInflater) this
                .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        View v = inflator.inflate(layoutId, new LinearLayout(mContext), false);
        ActionBar.LayoutParams layout = new ActionBar.LayoutParams(
                ActionBar.LayoutParams.MATCH_PARENT, ActionBar.LayoutParams.MATCH_PARENT);
        actionBar.setCustomView(v, layout);
        media_net = (Button)findViewById(R.id.media_network);
        media_history = (Button)findViewById(R.id.media_history);
        media_setting = (Button)findViewById(R.id.media_setting);
        media_net.setOnClickListener(this);
        media_setting.setOnClickListener(this);
        media_history.setOnClickListener(this);
    }else{
        Toast.makeText(MainActivity.this, "ActionBar不存在", Toast.LENGTH_SHORT).show();
    }

}
 
源代码2 项目: KSYMediaPlayer_Android   文件: NetMediaActivty.java
public void setActionBarLayout(int layoutId, Context mContext) {
    ActionBar actionBar = getSupportActionBar();
    if (null != actionBar) {
        actionBar.setDisplayShowHomeEnabled(false);
        actionBar.setDisplayShowCustomEnabled(true);
        actionBar.setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM);
        LayoutInflater inflator = (LayoutInflater) this
                .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        View v = inflator.inflate(layoutId, new LinearLayout(mContext), false);
        ActionBar.LayoutParams layout = new ActionBar.LayoutParams(
                ActionBar.LayoutParams.MATCH_PARENT, ActionBar.LayoutParams.MATCH_PARENT);
        actionBar.setCustomView(v, layout);

        netHistory = (Button) findViewById(R.id.net_history);
        netScan = (Button) findViewById(R.id.net_scan);
        netSetting = (Button) findViewById(R.id.net_setting);
        netScan.setOnClickListener(this);
        netHistory.setOnClickListener(this);
        netSetting.setOnClickListener(this);

    }else{
        Toast.makeText(NetMediaActivty.this, "ActionBar不存在", Toast.LENGTH_SHORT).show();
    }

}
 
源代码3 项目: actor-platform   文件: BaseActivity.java
protected void setToolbar(View view, ActionBar.LayoutParams params, boolean enableBack) {
    if (getSupportActionBar() == null) {
        throw new RuntimeException("Action bar is not set!");
    }
    getSupportActionBar().setDisplayShowCustomEnabled(true);
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    getSupportActionBar().setDisplayShowTitleEnabled(false);
    getSupportActionBar().setDisplayUseLogoEnabled(false);
    getSupportActionBar().setCustomView(view, params);
    if (enableBack) {
        getSupportActionBar().setDisplayShowHomeEnabled(true);
    } else {
        getSupportActionBar().setDisplayShowHomeEnabled(false);
        getSupportActionBar().setDisplayHomeAsUpEnabled(false);
        Toolbar parent = (Toolbar) view.getParent();
        parent.setContentInsetsAbsolute(0, 0);
    }
}
 
源代码4 项目: V.FlyoutTest   文件: ActionBarDisplayOptions.java
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.action_bar_display_options);

    findViewById(R.id.toggle_home_as_up).setOnClickListener(this);
    findViewById(R.id.toggle_show_home).setOnClickListener(this);
    findViewById(R.id.toggle_use_logo).setOnClickListener(this);
    findViewById(R.id.toggle_show_title).setOnClickListener(this);
    findViewById(R.id.toggle_show_custom).setOnClickListener(this);
    findViewById(R.id.toggle_navigation).setOnClickListener(this);
    findViewById(R.id.cycle_custom_gravity).setOnClickListener(this);
    findViewById(R.id.toggle_visibility).setOnClickListener(this);

    // Configure several action bar elements that will be toggled by display options.
    mCustomView = getLayoutInflater().inflate(R.layout.action_bar_display_options_custom, null);
    mCustomViewLayoutParams = new ActionBar.LayoutParams(
            LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);

    final ActionBar bar = getSupportActionBar();
    bar.setCustomView(mCustomView, mCustomViewLayoutParams);
    bar.addTab(bar.newTab().setText("Tab 1").setTabListener(this));
    bar.addTab(bar.newTab().setText("Tab 2").setTabListener(this));
    bar.addTab(bar.newTab().setText("Tab 3").setTabListener(this));
}
 
源代码5 项目: SimpleAdapterDemo   文件: BaseActivity.java
@Override
    protected void initActionBar(ActionBar actionBar) {
        if (actionBar == null)
            return;

        int padding = CompatResourceUtils.getDimensionPixelSize(this, R.dimen.space_12);
        FrameLayout customView = new FrameLayout(this);
//        customView.setPadding(padding, 0, padding, 0);
        ActionBar.LayoutParams barParams = new ActionBar.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, WindowUtils.getActionBarSize(this));
        actionBar.setDisplayShowCustomEnabled(true);
        actionBar.setCustomView(customView, barParams);
        //添加标题
        tvTitle = new TextView(this);
        tvTitle.setTextColor(Color.WHITE);
        tvTitle.setTextSize(TypedValue.COMPLEX_UNIT_SP, 18);
        tvTitle.setGravity(Gravity.CENTER);
        customView.addView(tvTitle, new FrameLayout.LayoutParams(FrameLayout.LayoutParams.MATCH_PARENT, FrameLayout.LayoutParams.MATCH_PARENT));
        //添加返回按钮
        ivBack = new ImageView(this);
        ivBack.setPadding(padding / 2, 0, padding / 2, 0);
        ivBack.setScaleType(ImageView.ScaleType.CENTER_INSIDE);
        ivBack.setImageResource(R.drawable.ic_chevron_left_white_24dp);
        ivBack.setBackground(WindowUtils.getSelectableItemBackgroundBorderless(this));
        customView.addView(ivBack, new FrameLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.MATCH_PARENT));
        ivBack.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                onBackPressed();
            }
        });
        //添加menu菜单
        actionMenuView = new ActionMenuView(this);
        FrameLayout.LayoutParams menuParams = new FrameLayout.LayoutParams(FrameLayout.LayoutParams.WRAP_CONTENT, FrameLayout.LayoutParams.WRAP_CONTENT);
        menuParams.gravity = Gravity.END | Gravity.CENTER_VERTICAL;
        customView.addView(actionMenuView, menuParams);
    }
 
源代码6 项目: CameraMaskDemo   文件: BaseActivity.java
@Override
    protected void initActionBar(ActionBar actionBar) {
        if (actionBar == null)
            return;

        int padding = CompatResourceUtils.getDimensionPixelSize(this, R.dimen.space_12);
        FrameLayout customView = new FrameLayout(this);
//        customView.setPadding(padding, 0, padding, 0);
        ActionBar.LayoutParams barParams = new ActionBar.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, WindowUtils.getActionBarSize(this));
        actionBar.setDisplayShowCustomEnabled(true);
        actionBar.setCustomView(customView, barParams);
        //添加标题
        tvTitle = new TextView(this);
        tvTitle.setTextColor(Color.WHITE);
        tvTitle.setTextSize(TypedValue.COMPLEX_UNIT_SP, 18);
        tvTitle.setGravity(Gravity.CENTER);
        customView.addView(tvTitle, new FrameLayout.LayoutParams(FrameLayout.LayoutParams.MATCH_PARENT, FrameLayout.LayoutParams.MATCH_PARENT));
        //添加返回按钮
        ivBack = new ImageView(this);
        ivBack.setPadding(padding / 2, 0, padding / 2, 0);
        ivBack.setScaleType(ImageView.ScaleType.CENTER_INSIDE);
        ivBack.setImageResource(R.drawable.ic_chevron_left_white_24dp);
        ivBack.setBackground(WindowUtils.getSelectableItemBackgroundBorderless(this));
        customView.addView(ivBack, new FrameLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.MATCH_PARENT));
        ivBack.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                onBackPressed();
            }
        });
        //添加menu菜单
        actionMenuView = new ActionMenuView(this);
        FrameLayout.LayoutParams menuParams = new FrameLayout.LayoutParams(FrameLayout.LayoutParams.WRAP_CONTENT, FrameLayout.LayoutParams.WRAP_CONTENT);
        menuParams.gravity = Gravity.END | Gravity.CENTER_VERTICAL;
        customView.addView(actionMenuView, menuParams);
    }
 
源代码7 项目: WheelViewDemo   文件: BaseActivity.java
@Override
    protected void initActionBar(ActionBar actionBar) {
        if (actionBar == null)
            return;

        int padding = CompatResourceUtils.getDimensionPixelSize(this, R.dimen.space_12);
        FrameLayout customView = new FrameLayout(this);
//        customView.setPadding(padding, 0, padding, 0);
        ActionBar.LayoutParams barParams = new ActionBar.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, WindowUtils.getActionBarSize(this));
        actionBar.setDisplayShowCustomEnabled(true);
        actionBar.setCustomView(customView, barParams);
        //添加标题
        tvTitle = new TextView(this);
        tvTitle.setTextColor(Color.WHITE);
        tvTitle.setTextSize(TypedValue.COMPLEX_UNIT_SP, 18);
        tvTitle.setGravity(Gravity.CENTER);
        customView.addView(tvTitle, new FrameLayout.LayoutParams(FrameLayout.LayoutParams.MATCH_PARENT, FrameLayout.LayoutParams.MATCH_PARENT));
        //添加返回按钮
        ivBack = new ImageView(this);
        ivBack.setPadding(padding / 2, 0, padding / 2, 0);
        ivBack.setScaleType(ImageView.ScaleType.CENTER_INSIDE);
        ivBack.setImageResource(R.drawable.ic_chevron_left_white_24dp);
        ivBack.setBackground(WindowUtils.getSelectableItemBackgroundBorderless(this));
        customView.addView(ivBack, new FrameLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.MATCH_PARENT));
        ivBack.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                onBackPressed();
            }
        });
        //添加menu菜单
        actionMenuView = new ActionMenuView(this);
        FrameLayout.LayoutParams menuParams = new FrameLayout.LayoutParams(FrameLayout.LayoutParams.WRAP_CONTENT, FrameLayout.LayoutParams.WRAP_CONTENT);
        menuParams.gravity = Gravity.END | Gravity.CENTER_VERTICAL;
        customView.addView(actionMenuView, menuParams);
    }
 
源代码8 项目: Mobike   文件: MyToolBar.java
private void initview() {
        if (mView == null) {
            mInflater = LayoutInflater.from(getContext());
            mView = mInflater.inflate(R.layout.toolbar, null);
            mLRippleView = (RippleView) mView.findViewById(R.id.more);
            mRRippleView = (RippleView) mView.findViewById(R.id.more1);
            toolbar_rightButton = (ImageView) mView.findViewById(R.id.id_btn_right);
            toolbar_title = (TextView) mView.findViewById(R.id.id_tv_title);
            toolbar_searchview = (EditText) mView.findViewById(R.id.id_et_search);
            toolbar_leftButton = (ImageView) mView.findViewById(R.id.id_ib_navigation);
            ActionBar.LayoutParams lp = new LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
                    ViewGroup.LayoutParams.WRAP_CONTENT);
            addView(mView, lp);
//            if (showSearchView) {
//                showSearchview();
//                hideTitle();
//            } else {
//                hideSearchview();
//                showTitle();
//                if (title != null) {
//                    toolbar_title.setText(title);
//                }
//            }
//            Log.d("left_button_icon", "initview:5"+left_button_icon);
//            if (left_button_icon != null) {
//
//                toolbar_leftButton.setBackground(left_button_icon);
//                toolbar_leftButton.setVisibility(VISIBLE);
//            }
//
//            if (right_button_icon != null) {
//                toolbar_rightButton.setImageDrawable(right_button_icon);
//                toolbar_rightButton.setVisibility(VISIBLE);
//            }

        }

    }
 
源代码9 项目: ExpressHelper   文件: DetailsActivity.java
@Override
protected void setUpViews() {
	mContentLayout = (LinearLayout) findViewById(R.id.content_list);
	tv_company = (TextView) findViewById(R.id.tv_express_company);
	tv_mail_no = (TextView) findViewById(R.id.tv_mail_no);
	tv_status = (TextView) findViewById(R.id.tv_status);
	tv_round_center = (TextView) findViewById(R.id.center_text);
	iv_round = (CircleImageView) findViewById(R.id.iv_round);
	mButtonNumberVisible = (ImageButton) findViewById(R.id.btn_number_visible);

	try {
		ViewCompat.setElevation(findViewById(R.id.headerView), getResources().getDimension(R.dimen.toolbar_elevation));
	} catch (NullPointerException e) {
		// Just ignore it.
	}

	mEditTextName = new EditText(mActionBar.getThemedContext());
	ActionBar.LayoutParams lp = new ActionBar.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT, Gravity.CENTER_VERTICAL);
	mActionBar.setCustomView(mEditTextName, lp);
	mActionBar.setDisplayShowCustomEnabled(false);
	mActionBar.setDisplayShowTitleEnabled(true);
	mButtonNumberVisible.setOnClickListener(new View.OnClickListener() {
		@Override
		public void onClick(View v) {
			toggleNumberShowing();
		}
	});
}
 
源代码10 项目: android   文件: MapzenSearchViewActivity.java
@Override protected void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);
  setContentView(R.layout.activity_search);

  listView = (AutoCompleteListView) findViewById(R.id.list_view);
  autocompleteAdapter = new AutoCompleteAdapter(this, android.R.layout.simple_list_item_1);
  listView.setAdapter(autocompleteAdapter);

  peliasLocationProvider = new MapzenMapPeliasLocationProvider(this);

  MapView mapView = (MapView) findViewById(R.id.map_view);
  mapView.getMapAsync(new OnMapReadyCallback() {
    @Override public void onMapReady(MapzenMap mapzenMap) {
      MapzenSearchViewActivity.this.mapzenMap = mapzenMap;
      mapzenMap.setPersistMapData(true);
      configMap();
    }
  });

  mapzenSearch = new MapzenSearch(this);
  mapzenSearch.setLocationProvider(peliasLocationProvider);

  PeliasSearchView peliasSearchView = new PeliasSearchView(this);
  ActionBar.LayoutParams lp = new ActionBar.LayoutParams(ActionBar.LayoutParams.MATCH_PARENT,
      ActionBar.LayoutParams.MATCH_PARENT);
  getSupportActionBar().setCustomView(peliasSearchView, lp);
  getSupportActionBar().setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM);
  setupPeliasSearchView(peliasSearchView);
}
 
private void setupCustomActionBar() {
    View actionBarCustomView = LayoutInflater.from(this).inflate(R.layout.homescreen_actionbar, null);
    ActionBar.LayoutParams params = new ActionBar.LayoutParams(ActionBar.LayoutParams.MATCH_PARENT,
            ActionBar.LayoutParams.MATCH_PARENT, Gravity.CENTER);

    getSupportActionBar().setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM);
    getSupportActionBar().setCustomView(actionBarCustomView, params);
    TextView heading = (TextView) actionBarCustomView.findViewById(R.id.homescreen_action_bar_title);
    ImageView gazettiLogo = (ImageView) actionBarCustomView.findViewById(R.id.gazetti_logo);

    heading.setAnimation(getEntryAnimation(ENTRY_ANIMATION_TITLE));
    gazettiLogo.setAnimation(getEntryAnimation(ENTRY_ANIMATION_LOGO));
}
 
源代码12 项目: SimpleAdapterDemo   文件: EmptyFragmentActivity.java
@Override
    public void initActionBar(ActionBar actionBar) {
        if (actionBar == null)
            return;

        //You can initialize custom action bar here.
        int padding = CompatResourceUtils.getDimensionPixelSize(this, R.dimen.space_12);
        FrameLayout customView = new FrameLayout(this);
//        customView.setPadding(padding, 0, padding, 0);
        ActionBar.LayoutParams barParams = new ActionBar.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, WindowUtils.getActionBarSize(this));
        actionBar.setDisplayShowCustomEnabled(true);
        actionBar.setCustomView(customView, barParams);
        //添加标题
        TextView tvTitle = new TextView(this);
        tvTitle.setTextColor(Color.WHITE);
        tvTitle.setTextSize(TypedValue.COMPLEX_UNIT_SP, 18);
        tvTitle.setGravity(Gravity.CENTER);
        tvTitle.setText(getClass().getSimpleName().replace("Activity", ""));
        customView.addView(tvTitle, new FrameLayout.LayoutParams(FrameLayout.LayoutParams.MATCH_PARENT, FrameLayout.LayoutParams.MATCH_PARENT));
        //添加返回按钮
        ImageView ivBack = new ImageView(this);
        ivBack.setPadding(padding / 2, 0, padding / 2, 0);
        ivBack.setScaleType(ImageView.ScaleType.CENTER_INSIDE);
        ivBack.setImageResource(R.drawable.ic_chevron_left_white_24dp);
        ivBack.setBackground(WindowUtils.getSelectableItemBackgroundBorderless(this));
        customView.addView(ivBack, new FrameLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.MATCH_PARENT));
        ivBack.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                onBackPressed();
            }
        });
        //添加menu菜单
        ActionMenuView actionMenuView = new ActionMenuView(this);
        FrameLayout.LayoutParams menuParams = new FrameLayout.LayoutParams(FrameLayout.LayoutParams.WRAP_CONTENT, FrameLayout.LayoutParams.WRAP_CONTENT);
        menuParams.gravity = Gravity.END | Gravity.CENTER_VERTICAL;
        customView.addView(actionMenuView, menuParams);

        String title = getIntent().getStringExtra(EXTRA_TITLE);
        tvTitle.setText(TextUtils.isEmpty(title) ? getClass().getSimpleName().replace("Activity", "") : title);
    }
 
源代码13 项目: CameraMaskDemo   文件: EmptyFragmentActivity.java
@Override
    public void initActionBar(ActionBar actionBar) {
        if (actionBar == null)
            return;

        //You can initialize custom action bar here.
        int padding = CompatResourceUtils.getDimensionPixelSize(this, R.dimen.space_12);
        FrameLayout customView = new FrameLayout(this);
//        customView.setPadding(padding, 0, padding, 0);
        ActionBar.LayoutParams barParams = new ActionBar.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, WindowUtils.getActionBarSize(this));
        actionBar.setDisplayShowCustomEnabled(true);
        actionBar.setCustomView(customView, barParams);
        //添加标题
        TextView tvTitle = new TextView(this);
        tvTitle.setTextColor(Color.WHITE);
        tvTitle.setTextSize(TypedValue.COMPLEX_UNIT_SP, 18);
        tvTitle.setGravity(Gravity.CENTER);
        tvTitle.setText(getClass().getSimpleName().replace("Activity", ""));
        customView.addView(tvTitle, new FrameLayout.LayoutParams(FrameLayout.LayoutParams.MATCH_PARENT, FrameLayout.LayoutParams.MATCH_PARENT));
        //添加返回按钮
        ImageView ivBack = new ImageView(this);
        ivBack.setPadding(padding / 2, 0, padding / 2, 0);
        ivBack.setScaleType(ImageView.ScaleType.CENTER_INSIDE);
        ivBack.setImageResource(R.drawable.ic_chevron_left_white_24dp);
        ivBack.setBackground(WindowUtils.getSelectableItemBackgroundBorderless(this));
        customView.addView(ivBack, new FrameLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.MATCH_PARENT));
        ivBack.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                onBackPressed();
            }
        });
        //添加menu菜单
        ActionMenuView actionMenuView = new ActionMenuView(this);
        FrameLayout.LayoutParams menuParams = new FrameLayout.LayoutParams(FrameLayout.LayoutParams.WRAP_CONTENT, FrameLayout.LayoutParams.WRAP_CONTENT);
        menuParams.gravity = Gravity.END | Gravity.CENTER_VERTICAL;
        customView.addView(actionMenuView, menuParams);

        String title = getIntent().getStringExtra(EXTRA_TITLE);
        tvTitle.setText(TextUtils.isEmpty(title) ? getClass().getSimpleName().replace("Activity", "") : title);
    }
 
源代码14 项目: WheelViewDemo   文件: EmptyFragmentActivity.java
@Override
    public void initActionBar(ActionBar actionBar) {
        if (actionBar == null)
            return;

        //You can initialize custom action bar here.
        int padding = CompatResourceUtils.getDimensionPixelSize(this, R.dimen.space_12);
        FrameLayout customView = new FrameLayout(this);
//        customView.setPadding(padding, 0, padding, 0);
        ActionBar.LayoutParams barParams = new ActionBar.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, WindowUtils.getActionBarSize(this));
        actionBar.setDisplayShowCustomEnabled(true);
        actionBar.setCustomView(customView, barParams);
        //添加标题
        TextView tvTitle = new TextView(this);
        tvTitle.setTextColor(Color.WHITE);
        tvTitle.setTextSize(TypedValue.COMPLEX_UNIT_SP, 18);
        tvTitle.setGravity(Gravity.CENTER);
        tvTitle.setText(getClass().getSimpleName().replace("Activity", ""));
        customView.addView(tvTitle, new FrameLayout.LayoutParams(FrameLayout.LayoutParams.MATCH_PARENT, FrameLayout.LayoutParams.MATCH_PARENT));
        //添加返回按钮
        ImageView ivBack = new ImageView(this);
        ivBack.setPadding(padding / 2, 0, padding / 2, 0);
        ivBack.setScaleType(ImageView.ScaleType.CENTER_INSIDE);
        ivBack.setImageResource(R.drawable.ic_chevron_left_white_24dp);
        ivBack.setBackground(WindowUtils.getSelectableItemBackgroundBorderless(this));
        customView.addView(ivBack, new FrameLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.MATCH_PARENT));
        ivBack.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                onBackPressed();
            }
        });
        //添加menu菜单
        ActionMenuView actionMenuView = new ActionMenuView(this);
        FrameLayout.LayoutParams menuParams = new FrameLayout.LayoutParams(FrameLayout.LayoutParams.WRAP_CONTENT, FrameLayout.LayoutParams.WRAP_CONTENT);
        menuParams.gravity = Gravity.END | Gravity.CENTER_VERTICAL;
        customView.addView(actionMenuView, menuParams);

        String title = getIntent().getStringExtra(EXTRA_TITLE);
        tvTitle.setText(TextUtils.isEmpty(title) ? getClass().getSimpleName().replace("Activity", "") : title);
    }
 
源代码15 项目: actor-platform   文件: BaseActivity.java
protected void setToolbar(View view, ActionBar.LayoutParams params) {
    setToolbar(view, params, true);
}
 
源代码16 项目: V.FlyoutTest   文件: ActionBarDisplayOptions.java
@Override
public void onClick(View v) {
    final ActionBar bar = getSupportActionBar();
    int flags = 0;
    switch (v.getId()) {
        case R.id.toggle_home_as_up:
            flags = ActionBar.DISPLAY_HOME_AS_UP;
            break;
        case R.id.toggle_show_home:
            flags = ActionBar.DISPLAY_SHOW_HOME;
            break;
        case R.id.toggle_use_logo:
            flags = ActionBar.DISPLAY_USE_LOGO;
            break;
        case R.id.toggle_show_title:
            flags = ActionBar.DISPLAY_SHOW_TITLE;
            break;
        case R.id.toggle_show_custom:
            flags = ActionBar.DISPLAY_SHOW_CUSTOM;
            break;
        case R.id.toggle_navigation:
            bar.setNavigationMode(
                    bar.getNavigationMode() == ActionBar.NAVIGATION_MODE_STANDARD
                            ? ActionBar.NAVIGATION_MODE_TABS
                            : ActionBar.NAVIGATION_MODE_STANDARD);
            return;
        case R.id.cycle_custom_gravity: {
            ActionBar.LayoutParams lp = mCustomViewLayoutParams;
            int newGravity = 0;
            switch (lp.gravity & Gravity.HORIZONTAL_GRAVITY_MASK) {
                case Gravity.LEFT:
                    newGravity = Gravity.CENTER_HORIZONTAL;
                    break;
                case Gravity.CENTER_HORIZONTAL:
                    newGravity = Gravity.RIGHT;
                    break;
                case Gravity.RIGHT:
                    newGravity = Gravity.LEFT;
                    break;
            }
            lp.gravity = lp.gravity & ~Gravity.HORIZONTAL_GRAVITY_MASK | newGravity;
            bar.setCustomView(mCustomView, lp);
            return;
        }
        case R.id.toggle_visibility:
            if (bar.isShowing()) {
                bar.hide();
            } else {
                bar.show();
            }
            return;
    }

    int change = bar.getDisplayOptions() ^ flags;
    bar.setDisplayOptions(change, flags);
}
 
源代码17 项目: Kernel-Tuner   文件: CPUActivity.java
@Override
public void onCreate(Bundle savedInstanceState)
{
    uiHandler = new Handler();
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_cpu);

    showAllCores = PrefsManager.cpuShowAllCores();
    ActionBar.LayoutParams lp = new ActionBar.LayoutParams(ActionBar.LayoutParams.WRAP_CONTENT, ActionBar.LayoutParams.WRAP_CONTENT, Gravity.RIGHT | Gravity.CENTER_VERTICAL);
    View view = getLayoutInflater().inflate(R.layout.layout_cpu_ab_switch, null);
    mSwitch = (Switch) view.findViewById(R.id.swShowAllCores);
    mSwitch.setChecked(showAllCores);
    mSwitch.setOnCheckedChangeListener(this);
    mSwitch.setOnTouchListener(this);

    getSupportActionBar().setDisplayShowCustomEnabled(true);
    getSupportActionBar().setDisplayShowTitleEnabled(true);
    getSupportActionBar().setCustomView(view, lp);

    pbLoading = (ProgressBar) findViewById(R.id.pbLoading);
    mList = (ListView) findViewById(R.id.list);
    mList.setOnItemClickListener(this);
    mListAdapter = new CPUAdapter(this, new ArrayList<CPU>());
    mList.setAdapter(mListAdapter);
    refreshView();

    if (Constants.MPDECISION.exists()/* || new File(Constants.MPDECISION_BINARY).exists()*/)
    {
        Button mp = (Button) findViewById(R.id.btn_mpdecision);
        mp.setOnClickListener(new SimpleStartActivityListener(Mpdecision.class));
        mp.setOnLongClickListener(new InfoListener(R.drawable.main_mp,
                getResources().getString(R.string.info_mpd_title),
                getResources().getString(R.string.info_mpd_text),
                Constants.G_S_URL_PREFIX + "mp-decision", true));
        mp.setVisibility(View.VISIBLE);
    }
    if (Constants.THERMALD.exists()/* || new File(Constants.THERMALD_BINARY).exists()*/)
    {
        Button thermal = (Button) findViewById(R.id.btn_thermal);
        thermal.setOnClickListener(new SimpleStartActivityListener(Thermald.class));

        thermal.setOnLongClickListener(new InfoListener(R.drawable.main_thermal,
                getResources().getString(R.string.info_thermal_title),
                getResources().getString(R.string.info_thermal_text), "", false));
        thermal.setVisibility(View.VISIBLE);
    }

}
 
源代码18 项目: Kernel-Tuner   文件: TaskManager.java
/**
 * Foreground Application = 10040
 * Secondary Server  	  = 10041
 * Content Providers      = 10043
 * Empty Application      = 10079
 * Visible Application    = 10025
 * Hidden Application     =
 * */
/*
 private static final int BACKGROUND = RunningAppProcessInfo.IMPORTANCE_BACKGROUND;
 private static final int EMPTY = RunningAppProcessInfo.IMPORTANCE_EMPTY;
 private static final int FOREGROUND = RunningAppProcessInfo.IMPORTANCE_FOREGROUND;
 private static final int PERCEPTIBLE = RunningAppProcessInfo.IMPORTANCE_PERCEPTIBLE;
 private static final int SERVICE = RunningAppProcessInfo.IMPORTANCE_SERVICE;
 private static final int VISIBLE = RunningAppProcessInfo.IMPORTANCE_VISIBLE;
 */

@Override
public void onCreate(Bundle savedInstanceState)
{
       handler = new Handler();
	preferences = PreferenceManager.getDefaultSharedPreferences(this);

	super.onCreate(savedInstanceState);

	getSupportActionBar().setDisplayHomeAsUpEnabled(true);
	setContentView(R.layout.activity_tm_list);

	pbLoading = (ProgressBar)findViewById(R.id.pbLoading);
	
	getSupportActionBar().setTitle(getResources().getString(R.string.title_task_manager));
	getSupportActionBar().setSubtitle(null);
	getSupportActionBar().setIcon(R.drawable.tm);

	ActionBar.LayoutParams lp = new ActionBar.LayoutParams(ActionBar.LayoutParams.WRAP_CONTENT, ActionBar.LayoutParams.WRAP_CONTENT, Gravity.RIGHT | Gravity.CENTER_VERTICAL);
	View customNav = LayoutInflater.from(this).inflate(R.layout.ram_layout, null);

	((TextView)customNav.findViewById(R.id.free)).setText(Html.fromHtml("<b>" + getResources().getString(R.string.mem_free) + "</b>" + getFreeRAM() + "MB"));
	((TextView)customNav.findViewById(R.id.total)).setText(Html.fromHtml("<b>" + getResources().getString(R.string.mem_total) + "</b>" + getTotalRAM() + "MB"));

       //Attach to the action bar
       getSupportActionBar().setCustomView(customNav, lp);
       getSupportActionBar().setDisplayShowCustomEnabled(true);

	tmListView =  (ListView)findViewById(R.id.list);
	pm = getPackageManager();
	
	tmAdapter = new TMAdapter(this, R.layout.tm_row);
       tmListView.setAdapter(tmAdapter);
	tmListView.setOnItemClickListener(this);

	loading = (ProgressBar)findViewById(R.id.loading);
	system = (CheckBox)findViewById(R.id.system);
	user = (CheckBox)findViewById(R.id.user);
	other = (CheckBox)findViewById(R.id.other);

	system.setChecked(preferences.getBoolean("tm_system", false));
	user.setChecked(preferences.getBoolean("tm_user", true));
	other.setChecked(preferences.getBoolean("tm_other", false));

	system.setOnCheckedChangeListener(new Listener());
	user.setOnCheckedChangeListener(new Listener());
	other.setOnCheckedChangeListener(new Listener());

       new GetRunningApps(true).execute();
}