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

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

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

Toolbar.setSubtitle介绍

暂无

代码示例

代码示例来源:origin: chrisjenx/Calligraphy

@Override
      public void run() {
//                toolbar.setTitle("Calligraphy Added");
        toolbar.setSubtitle("Added subtitle");
      }
    }, 1000);

代码示例来源:origin: omadahealth/LolliPin

private void initView() {
    Toolbar toolbar = (Toolbar) findViewById(R.id.id_toolbar);
    setSupportActionBar(toolbar);

    toolbar.setTitle("Title");
    toolbar.setTitleTextColor(getResources().getColor(android.R.color.white));
    toolbar.setSubtitle("SubTitle");
    toolbar.setSubtitleTextColor(getResources().getColor(android.R.color.white));
    toolbar.setLogo(R.drawable.ic_launcher);
    toolbar.setNavigationIcon(R.drawable.ic_menu_white_36dp);
  }
}

代码示例来源:origin: yanzhenjie/NoHttp

@Override
final void setSubTitle(CharSequence title) {
  if (mActionBar != null) mActionBar.setSubtitle(title);
}

代码示例来源:origin: yanzhenjie/NoHttp

@Override
final void setSubTitle(CharSequence title) {
  if (mActionBar != null) mActionBar.setSubtitle(title);
}

代码示例来源:origin: chrisjenx/Calligraphy

@Override public void run() {
    toolbar.setTitle(null);
    toolbar.setSubtitle("Added subtitle");
  }
}, 2000);

代码示例来源:origin: chrisjenx/Calligraphy

@Override public void run() {
    toolbar.setTitle("Calligraphy added back");
    toolbar.setSubtitle("Added subtitle");
  }
}, 3000);

代码示例来源:origin: yanzhenjie/NoHttp

@Override
final void setSubTitle(@StringRes int title) {
  if (mActionBar != null) mActionBar.setSubtitle(title);
}

代码示例来源:origin: yanzhenjie/NoHttp

@Override
final void setSubTitle(@StringRes int title) {
  if (mActionBar != null) mActionBar.setSubtitle(title);
}

代码示例来源:origin: aa112901/remusic

private void setupToolbar() {
  setSupportActionBar(toolbar);
  actionBar = getSupportActionBar();
  actionBar.setHomeAsUpIndicator(R.drawable.actionbar_back);
  actionBar.setDisplayHomeAsUpEnabled(true);
  actionBar.setTitle("歌单");
  toolbar.setPadding(0, mStatusSize, 0, 0);
  toolbar.setNavigationOnClickListener(new View.OnClickListener() {
    @Override
    public void onClick(View v) {
      onBackPressed();
    }
  });
  toolbar.setSubtitle(albumDes);
}

代码示例来源:origin: aa112901/remusic

private void setupToolbar() {
  setSupportActionBar(toolbar);
  actionBar = getSupportActionBar();
  actionBar.setHomeAsUpIndicator(R.drawable.actionbar_back);
  actionBar.setDisplayHomeAsUpEnabled(true);
  actionBar.setTitle("歌单");
  toolbar.setPadding(0, mStatusSize, 0, 0);
  toolbar.setNavigationOnClickListener(new View.OnClickListener() {
    @Override
    public void onClick(View v) {
      onBackPressed();
    }
  });
  toolbar.setSubtitle(albumDes);
}

代码示例来源:origin: aa112901/remusic

private void setupToolbar() {
  setSupportActionBar(toolbar);
  actionBar = getSupportActionBar();
  actionBar.setHomeAsUpIndicator(R.drawable.actionbar_back);
  actionBar.setDisplayHomeAsUpEnabled(true);
  actionBar.setTitle(artistName);
  toolbar.setPadding(0, mStatusSize, 0, 0);
  toolbar.setNavigationOnClickListener(new View.OnClickListener() {
    @Override
    public void onClick(View v) {
      onBackPressed();
    }
  });
  toolbar.setSubtitle(artistDes);
}

代码示例来源:origin: aa112901/remusic

private void setupToolbar() {
  setSupportActionBar(toolbar);
  actionBar = getSupportActionBar();
  actionBar.setHomeAsUpIndicator(R.drawable.actionbar_back);
  actionBar.setDisplayHomeAsUpEnabled(true);
  actionBar.setTitle("歌单");
  toolbar.setPadding(0, mStatusSize, 0, 0);
  toolbar.setNavigationOnClickListener(new View.OnClickListener() {
    @Override
    public void onClick(View v) {
      onBackPressed();
    }
  });
  if (!isLocalPlaylist) {
    toolbar.setSubtitle(playlistDetail);
  }
}

代码示例来源:origin: aa112901/remusic

private void setupToolbar() {
  setSupportActionBar(toolbar);
  actionBar = getSupportActionBar();
  actionBar.setHomeAsUpIndicator(R.drawable.actionbar_back);
  actionBar.setDisplayHomeAsUpEnabled(true);
  actionBar.setTitle("歌单");
  toolbar.setPadding(0, mStatusSize, 0, 0);
  toolbar.setNavigationOnClickListener(new View.OnClickListener() {
    @Override
    public void onClick(View v) {
      onBackPressed();
    }
  });
  if (!isLocalPlaylist) {
    toolbar.setSubtitle(playlistDetail);
  }
}

代码示例来源:origin: chrisjenx/Calligraphy

/**
   * Will forcibly set text on the views then remove ones that didn't have copy.
   *
   * @param view toolbar view.
   */
  private void applyFontToToolbar(final Toolbar view) {
    final CharSequence previousTitle = view.getTitle();
    final CharSequence previousSubtitle = view.getSubtitle();
    // The toolbar inflates both the title and the subtitle views lazily but luckily they do it
    // synchronously when you set a title and a subtitle programmatically.
    // So we set a title and a subtitle to something, then get the views, then revert.
    view.setTitle("uk.co.chrisjenx.calligraphy:toolbar_title");
    view.setSubtitle("uk.co.chrisjenx.calligraphy:toolbar_subtitle");

    // Iterate through the children to run post inflation on them
    final int childCount = view.getChildCount();
    for (int i = 0; i < childCount; i++) {
      onViewCreated(view.getChildAt(i), view.getContext(), null);
    }
    // Remove views from view if they didn't have copy set.
    view.setTitle(previousTitle);
    view.setSubtitle(previousSubtitle);
  }
}

代码示例来源:origin: jgilfelt/chuck

@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);
  setContentView(R.layout.chuck_activity_main);
  Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
  setSupportActionBar(toolbar);
  toolbar.setSubtitle(getApplicationName());
  if (savedInstanceState == null) {
    getSupportFragmentManager().beginTransaction()
        .add(R.id.container, TransactionListFragment.newInstance())
        .commit();
  }
}

代码示例来源:origin: aa112901/remusic

@Override
  public void onScrollChanged(int scrollY, boolean firstScroll, boolean dragging) {

    updateViews(scrollY, false);

    if (scrollY > 0 && scrollY < mFlexibleSpaceImageHeight - mActionBarSize - mStatusSize) {
      toolbar.setTitle(albumName);
      toolbar.setSubtitle(albumDes);
      actionBar.setBackgroundDrawable(getResources().getDrawable(R.drawable.toolbar_background));
    }
    if (scrollY == 0) {
      toolbar.setTitle("歌单");
      actionBar.setBackgroundDrawable(null);
    }
    if (scrollY > mFlexibleSpaceImageHeight - mActionBarSize - mStatusSize) {

//            if(mBlurDrawable != null){
//                mBlurDrawable.setColorFilter(Color.parseColor("#79000000"), PorterDuff.Mode.SRC_OVER);
//                actionBar.setBackgroundDrawable(mBlurDrawable);
//            }
    }

    float a = (float) scrollY / (mFlexibleSpaceImageHeight - mActionBarSize - mStatusSize);
    headerDetail.setAlpha(1f - a);
    Log.e("alpha", " " + a);
  }

代码示例来源:origin: aa112901/remusic

@Override
  public void onScrollChanged(int scrollY, boolean firstScroll, boolean dragging) {

    updateViews(scrollY, false);

    if (scrollY > 0 && scrollY < mFlexibleSpaceImageHeight - mActionBarSize - mStatusSize) {
      toolbar.setTitle(albumName);
      toolbar.setSubtitle(albumDes);
      actionBar.setBackgroundDrawable(getResources().getDrawable(R.drawable.toolbar_background));
    }
    if (scrollY == 0) {
      toolbar.setTitle("歌单");
      actionBar.setBackgroundDrawable(null);
    }
    if (scrollY > mFlexibleSpaceImageHeight - mActionBarSize - mStatusSize) {

//            if(mBlurDrawable != null){
//                mBlurDrawable.setColorFilter(Color.parseColor("#79000000"), PorterDuff.Mode.SRC_OVER);
//                actionBar.setBackgroundDrawable(mBlurDrawable);
//            }
    }

    float a = (float) scrollY / (mFlexibleSpaceImageHeight - mActionBarSize - mStatusSize);
    headerDetail.setAlpha(1f - a);
    Log.e("alpha", " " + a);
  }

代码示例来源:origin: aa112901/remusic

@Override
  public void onScrollChanged(int scrollY, boolean firstScroll, boolean dragging) {

    updateViews(scrollY, false);

    if (scrollY > 0 && scrollY < mFlexibleSpaceImageHeight - mActionBarSize - mStatusSize) {
      toolbar.setTitle(playlistName);
      toolbar.setSubtitle(playlistDetail);
      actionBar.setBackgroundDrawable(getResources().getDrawable(R.drawable.toolbar_background));
    }
    if (scrollY == 0) {
      toolbar.setTitle("歌单");
      actionBar.setBackgroundDrawable(null);
    }
    if (scrollY > mFlexibleSpaceImageHeight - mActionBarSize - mStatusSize) {

//            if(mBlurDrawable != null){
//                mBlurDrawable.setColorFilter(Color.parseColor("#79000000"), PorterDuff.Mode.SRC_OVER);
//                actionBar.setBackgroundDrawable(mBlurDrawable);
//            }
    }

    float a = (float) scrollY / (mFlexibleSpaceImageHeight - mActionBarSize - mStatusSize);
    headerDetail.setAlpha(1f - a);
  }

代码示例来源:origin: aa112901/remusic

@Override
  public void onScrollChanged(int scrollY, boolean firstScroll, boolean dragging) {

    updateViews(scrollY, false);

    if (scrollY > 0 && scrollY < mFlexibleSpaceImageHeight - mActionBarSize - mStatusSize) {
      toolbar.setTitle(playlistName);
      toolbar.setSubtitle(playlistDetail);
      actionBar.setBackgroundDrawable(getResources().getDrawable(R.drawable.toolbar_background));
    }
    if (scrollY == 0) {
      toolbar.setTitle("歌单");
      actionBar.setBackgroundDrawable(null);
    }
    if (scrollY > mFlexibleSpaceImageHeight - mActionBarSize - mStatusSize) {

//            if(mBlurDrawable != null){
//                mBlurDrawable.setColorFilter(Color.parseColor("#79000000"), PorterDuff.Mode.SRC_OVER);
//                actionBar.setBackgroundDrawable(mBlurDrawable);
//            }
    }

    float a = (float) scrollY / (mFlexibleSpaceImageHeight - mActionBarSize - mStatusSize);
    headerDetail.setAlpha(1f - a);
  }

代码示例来源:origin: Leaking/WeGit

@Override
  public void setTotalCount(int count) {
    toolbar.setSubtitle("" + count);
  }
}

相关文章

Toolbar类方法