android.support.v7.widget.Toolbar.addView()方法的使用及代码示例

x33g5p2x  于2022-01-29 转载在 其他  
字(5.9k)|赞(0)|评价(0)|浏览(122)

本文整理了Java中android.support.v7.widget.Toolbar.addView()方法的一些代码示例,展示了Toolbar.addView()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Toolbar.addView()方法的具体详情如下:
包路径:android.support.v7.widget.Toolbar
类名称:Toolbar
方法名:addView

Toolbar.addView介绍

暂无

代码示例

代码示例来源:origin: eneim/toro

private void setupDemoButton() {
 View buttonContainer = toolbar.findViewById(R.id.home_toolbar_button);
 if (buttonContainer == null) {
  buttonContainer = LayoutInflater.from(toolbar.getContext())
    .inflate(R.layout.widget_toolbar_button, toolbar, false);
  buttonContainer.setId(R.id.home_toolbar_button);
  ActionBar.LayoutParams params = (ActionBar.LayoutParams) buttonContainer.getLayoutParams();
  params.gravity = GravityCompat.END;
  toolbar.addView(buttonContainer, params);
 }
 buttonContainer.findViewById(R.id.button_open_demos)
   .setOnClickListener(__ -> startActivity(new Intent(this, MainActivity.class)));
}

代码示例来源:origin: SharryChoo/SToolbar

@Override
public void addView(View child, int index, ViewGroup.LayoutParams params) {
  if (LOCKED_CHILDREN_COUNT == getChildCount()) {
    return;
  }
  super.addView(child, index, params);
}

代码示例来源:origin: opacapp/multiline-collapsingtoolbar

private void updateDummyView() {
  if (!mCollapsingTitleEnabled && mDummyView != null) {
    // If we have a dummy view and we have our title disabled, remove it from its parent
    final ViewParent parent = mDummyView.getParent();
    if (parent instanceof ViewGroup) {
      ((ViewGroup) parent).removeView(mDummyView);
    }
  }
  if (mCollapsingTitleEnabled && mToolbar != null) {
    if (mDummyView == null) {
      mDummyView = new View(getContext());
    }
    if (mDummyView.getParent() == null) {
      mToolbar.addView(mDummyView, LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
    }
  }
}

代码示例来源:origin: VyacheslavShmakin/GpCollapsingToolbar

private void updateDummyView() {
  if (!mCollapsingTitleEnabled && mDummyView != null) {
    // If we have a dummy view and we have our title disabled, remove it from its parent
    final ViewParent parent = mDummyView.getParent();
    if (parent instanceof ViewGroup) {
      ((ViewGroup) parent).removeView(mDummyView);
    }
  }
  if (mCollapsingTitleEnabled && mToolbar != null) {
    if (mDummyView == null) {
      mDummyView = new View(getContext());
    }
    if (mDummyView.getParent() == null) {
      mToolbar.addView(mDummyView, LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
    }
  }
}

代码示例来源:origin: CarlLu/MVPframe

protected void setToolbar(boolean isNeedBackImg, String titleContent) {
  if (mToolbar != null) {
    if (isNeedBackImg) {
      mToolbar.setNavigationIcon(R.mipmap.ico_back);
      mToolbar.setNavigationOnClickListener(v -> onBackClick());
    }
    if (!TextUtils.isEmpty(titleContent)) {
      mTitleView = new TextView(mContext);
      mTitleView.setTextSize(18);
      mTitleView.setTextColor(Color.WHITE);
      mTitleView.setText(titleContent);
      Toolbar.LayoutParams params = new Toolbar.LayoutParams(
          ViewGroup.LayoutParams.WRAP_CONTENT,
          ViewGroup.LayoutParams.WRAP_CONTENT, Gravity.CENTER);
      mToolbar.addView(mTitleView, params);
    }
  }
}

代码示例来源:origin: nglauber/dominando_android2

@Override
protected void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);
  setContentView(R.layout.activity_tela_spinner);
  ArrayAdapter<String> adapter = new ArrayAdapter<String>(
      this,
      android.R.layout.simple_list_item_1,
      android.R.id.text1,
      getResources().getStringArray(R.array.secoes)
  );
  mSpinner = new Spinner(this);
  mSpinner.setAdapter(adapter);
  mSpinner.setOnItemSelectedListener(this);
  mToolbar = (Toolbar)findViewById(R.id.toolbar);
  mToolbar.addView(mSpinner);
  setSupportActionBar(mToolbar);
  getSupportActionBar().setDisplayHomeAsUpEnabled(true);
  getSupportActionBar().setDisplayShowTitleEnabled(false);
}
@Override

代码示例来源:origin: nglauber/dominando_android2

@Override
protected void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);
  setContentView(R.layout.activity_tela_spinner);
  ArrayAdapter<String> adapter = new ArrayAdapter<String>(
      this,
      android.R.layout.simple_list_item_1,
      android.R.id.text1,
      getResources().getStringArray(R.array.secoes)
  );
  mSpinner = new Spinner(this);
  mSpinner.setAdapter(adapter);
  mSpinner.setOnItemSelectedListener(this);
  mToolbar = (Toolbar)findViewById(R.id.toolbar);
  mToolbar.addView(mSpinner);
  setSupportActionBar(mToolbar);
  getSupportActionBar().setDisplayHomeAsUpEnabled(true);
  getSupportActionBar().setDisplayShowTitleEnabled(false);
}
@Override

代码示例来源:origin: GadgetCheck/TinderView

private void setToolBar() {
  toolbar = (Toolbar) findViewById(R.id.toolbar);
  setSupportActionBar(toolbar);
  LayoutInflater mLayoutInflater = (LayoutInflater) this.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
  //setting TabBarView
  View customTabView = mLayoutInflater.inflate(R.layout.custom_tab_view, null);
  mTabBarView = (TabBarView) customTabView.findViewById(R.id.customTabBar);
  mTabBarView.setStripHeight(7);
  mTabBarView.setStripColor(getResources().getColor(R.color.white));
  //setting the properties of ActionBar
  getSupportActionBar().setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM);
  getSupportActionBar().setDisplayHomeAsUpEnabled(false);
  getSupportActionBar().setHomeButtonEnabled(false);
  //Setting the Customized Toolbar into toolbar object
  toolbar.addView(customTabView);
}

代码示例来源:origin: Suleiman19/Android-Material-Design-for-pre-Lollipop

ActionBar.LayoutParams lp = new ActionBar.LayoutParams(
    ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
toolbar.addView(spinnerContainer, lp);

代码示例来源:origin: pocmo/Yaaic

toolbar.addView(LayoutInflater.from(this).inflate(R.layout.item_done_discard, toolbar, false));

代码示例来源:origin: andyiac/githot

toolbar.addView(spinnerContainer, lp);

代码示例来源:origin: lionoggo/FastApp

Toolbar.LayoutParams params = new Toolbar.LayoutParams(ActionBar.LayoutParams.MATCH_PARENT,
    ActionBar.LayoutParams.MATCH_PARENT);
actionBar.addView(view, params);
mActionTitle = (TextView) view.findViewById(R.id.action_bar_title);
int titleRes = getActionBarTitle();

代码示例来源:origin: lionoggo/Akit-Reader

Toolbar.LayoutParams params = new Toolbar.LayoutParams(ActionBar.LayoutParams.MATCH_PARENT,
    ActionBar.LayoutParams.MATCH_PARENT);
actionBar.addView(view, params);
mActionTitle = (TextView) view.findViewById(R.id.action_bar_title);
int titleRes = getActionBarTitle();

代码示例来源:origin: pocmo/Yaaic

params.gravity = Gravity.BOTTOM;
activity.getToolbar().addView(tabLayout, params);

相关文章

Toolbar类方法