本文整理匯總了Java中android.support.design.widget.CollapsingToolbarLayout類的典型用法代碼示例。如果您正苦於以下問題:Java CollapsingToolbarLayout類的具體用法?Java CollapsingToolbarLayout怎麽用?Java CollapsingToolbarLayout使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
CollapsingToolbarLayout類屬於android.support.design.widget包,在下文中一共展示了CollapsingToolbarLayout類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: onCreate
import android.support.design.widget.CollapsingToolbarLayout; //導入依賴的package包/類
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_suggestion);
Intent intent=getIntent();
Toolbar toolbar=(Toolbar)findViewById(R.id.toolbar);
CollapsingToolbarLayout collapsingToolbarLayout=(CollapsingToolbarLayout)findViewById(R.id.collapsing_toolbar);
ImageView fruitImageView=(ImageView)findViewById(R.id.fruit_image_view);
TextView fruitContentText=(TextView)findViewById(R.id.fruit_content_text);
setSupportActionBar(toolbar);
ActionBar actionBar=getSupportActionBar();
if (actionBar!=null){
actionBar.setDisplayHomeAsUpEnabled(true);
}
collapsingToolbarLayout.setTitle("蘋果雪鬆生鏽-雪鬆蘋果鏽病菌");
Glide.with(this).load(R.drawable.disease_pic1).into(fruitImageView);
fruitContentText.setText("危害性狀 危害蘋果屬、刺柏屬。在刺柏的細枝、分枝和葉上產生菌瘓,或在莖部引起紡錘形腫脹,在潮濕條件下可產生冬孢子角。在鏽子器寄主上,鏽子器引起的葉片症狀和性孢子器引起的症狀是一致的。能在感病品種上造成非常嚴重的落葉。偶爾能在蘋果表麵引起褐色壞死斑。\n" +
"\n" +
"生物特性 冬孢子堆在枝條邊上的球形或腎形,直徑1-3cm的菌癭上形成,長圓柱形,逐漸變細,長10-20mm,寬1-2mm,鏽褐色。冬孢子:雙細胞,圓柱形至擬紡錘形。15-21μm× 35-65μm,壁厚0.5-1μm。在薔薇科寄主上,鏽子器:毛型鏽子器為葉背生,具包被,高3-5mm。在頂端開裂。鏽孢子團為紅褐色。鏽孢子:直徑15-28μm。 轉主寄生,需要刺柏屬和薔薇科寄主來完成它的生活史。春季,冬孢子堆產生在刺柏屬的莖、嫩枝和葉上。在潮濕條件下,冬孢子萌發並產生擔孢子,擔孢子飛散再侵染鄰近的薔薇科寄主。擔孢子侵染薔薇科寄主的葉的上表麵,產生性孢子器;在春末到初夏季節用肉眼即可看到,隨後,在葉背部的管狀保護鞘(包被)內產生夏孢子。夏孢子堆以獨特的形式出現在果實上。據推側,侵染果實的病菌可能是其他的種。當包被破裂時,夏孢子即被釋放,並隨風作長距離傳播至刺柏屬寄主上。在刺柏屬上萌發後,產生越冬的潛伏菌絲。受侵染的葉或果實脫落後,對薔薇科寄主的侵染便不能繼續。春天,冬孢子階段出現在刺柏屬上,開始下一輪生活史。\n" +
"\n" +
"傳染途徑 在自然條件下通過薔薇科寄主上的擔孢子傳播,也可通過刺柏屬寄主上的鏽孢子風傳。遠距離傳播主要借助染病的植株體(特別是用其做包裝材料時)等。\n" +
"\n" +
"防疫方法 由於病菌可係統地侵染檜柏的莖和常綠的葉,因此沒有一種化學處理方法能取得令人滿意的效果。有人提出應用放線菌酮來抑製雪鬆-蘋果鏽病菌的冬孢子產生,這項措施可作為對受侵染植物的短期檢疫處理方法以防植物死亡。冬孢子極可能由受侵染植物製成的包裝材料攜帶。");
}
示例2: setStatusBarColorForCollapsingToolbar
import android.support.design.widget.CollapsingToolbarLayout; //導入依賴的package包/類
/**
* compat for CollapsingToolbarLayout
* 1. set Window Flag : WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS
* 2. set FitsSystemWindows for views.
* 3. removeFakeStatusBarViewIfExist
* 4. removeMarginTopOfContentChild
* 5. add OnOffsetChangedListener to change statusBarView's alpha
*/
public static void setStatusBarColorForCollapsingToolbar(Activity activity, final AppBarLayout appBarLayout, final CollapsingToolbarLayout collapsingToolbarLayout,
Toolbar toolbar, int statusColor) {
Window window = activity.getWindow();
window.addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
ViewGroup mContentView = (ViewGroup) window.findViewById(Window.ID_ANDROID_CONTENT);
View mContentChild = mContentView.getChildAt(0);
mContentChild.setFitsSystemWindows(false);
((View) appBarLayout.getParent()).setFitsSystemWindows(false);
appBarLayout.setFitsSystemWindows(false);
collapsingToolbarLayout.setFitsSystemWindows(false);
collapsingToolbarLayout.getChildAt(0).setFitsSystemWindows(false);
toolbar.setFitsSystemWindows(true);
if (toolbar.getTag() == null) {
CollapsingToolbarLayout.LayoutParams lp = (CollapsingToolbarLayout.LayoutParams) toolbar.getLayoutParams();
lp.height += getStatusBarHeight(activity);
toolbar.setLayoutParams(lp);
toolbar.setTag(true);
}
int statusBarHeight = getStatusBarHeight(activity);
removeFakeStatusBarViewIfExist(activity);
removeMarginTopOfContentChild(mContentChild, statusBarHeight);
// final View statusView = addFakeStatusBarView(activity, statusColor, statusBarHeight);
// appBarLayout.addOnOffsetChangedListener(new AppBarLayout.OnOffsetChangedListener() {
// @Override
// public void onOffsetChanged(AppBarLayout appBarLayout, int verticalOffset) {
// if (Math.abs(verticalOffset) > appBarLayout.getHeight() - collapsingToolbarLayout.getStatusBarScrim().getIntrinsicHeight()) {
// if (statusView.getAlpha() == 0) {
// statusView.animate().alpha(1f).setDuration(collapsingToolbarLayout.getScrollBarFadeDuration()).start();
// }
// } else {
// statusView.setAlpha(0);
// }
// }
// });
}
示例3: initView
import android.support.design.widget.CollapsingToolbarLayout; //導入依賴的package包/類
@Override
public void initView(Bundle savedInstanceState, View view) {
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
View fakeStatusBar = findViewById(R.id.fake_status_bar);
CollapsingToolbarLayout ctl = (CollapsingToolbarLayout) findViewById(R.id.ctl);
ctl.setExpandedTitleColor(Color.parseColor("#00FFFFFF"));
setSupportActionBar(toolbar);
ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(this,
rootLayout,
toolbar,
R.string.navigation_drawer_open,
R.string.navigation_drawer_close);
rootLayout.addDrawerListener(toggle);
toggle.syncState();
BarUtils.setStatusBarAlpha4Drawer(this, rootLayout, fakeStatusBar, 0, false);
BarUtils.addMarginTopEqualStatusBarHeight(toolbar);
}
示例4: onCreate
import android.support.design.widget.CollapsingToolbarLayout; //導入依賴的package包/類
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_fruit);
Intent intent=getIntent();
String fruitName=intent.getStringExtra(FRUIT_NAME);
int fruitImageId=intent.getIntExtra(FRUIT_IMAGE_ID,0);
Toolbar toolbar=(Toolbar)findViewById(R.id.toolbar);
CollapsingToolbarLayout collapsingToolbar=(CollapsingToolbarLayout)findViewById(R.id.collapsing_toolbar);
ImageView fruitImageView=(ImageView)findViewById(R.id.fruit_image_view);
TextView fruitContentText=(TextView)findViewById(R.id.fruit_content_text);
setSupportActionBar(toolbar);
ActionBar actionBar=getSupportActionBar();
if (actionBar!=null){
actionBar.setDisplayHomeAsUpEnabled(true);
}
collapsingToolbar.setTitle(fruitName);
Glide.with(this).load(fruitImageId).into(fruitImageView);
String fruitContent=generateFruitContent(fruitName);
fruitContentText.setText(fruitContent);
}
示例5: onCreate
import android.support.design.widget.CollapsingToolbarLayout; //導入依賴的package包/類
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
if (getArguments().containsKey(ARG_ITEM_ID)) {
// Load the dummy content specified by the fragment
// arguments. In a real-world scenario, use a Loader
// to load content from a content provider.
mItem = DummyContent.ITEM_MAP.get(getArguments().getString(ARG_ITEM_ID));
Activity activity = this.getActivity();
CollapsingToolbarLayout appBarLayout = (CollapsingToolbarLayout) activity.findViewById(R.id.toolbar_layout);
if (appBarLayout != null) {
appBarLayout.setTitle(mItem.content);
}
}
}
示例6: onCreate
import android.support.design.widget.CollapsingToolbarLayout; //導入依賴的package包/類
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_my_rank);
UltimateBar ultimateBar = new UltimateBar(this);
ultimateBar.setImmersionBar();
CollapsingToolbarLayout collapsingToolbar = findViewById(R.id.collapsing_toolbar);
if (PorA.equals("submit"))
collapsingToolbar.setTitle("發單排行");
else collapsingToolbar.setTitle("接單排行");
Toolbar toolbar = findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
ActionBar actionBar = getSupportActionBar();
if(actionBar != null){
actionBar.setDisplayHomeAsUpEnabled(true);
}
new RandAsysc().execute();
}
示例7: loadProfileInfo
import android.support.design.widget.CollapsingToolbarLayout; //導入依賴的package包/類
/**
* Load info of the plant
*/
private void loadProfileInfo() {
if (mPlantReference != null) {
mPlantReference.addValueEventListener(new ValueEventListener() {
@Override
public void onDataChange(@NotNull DataSnapshot dataSnapshot) {
mPlant = dataSnapshot.getValue(Plant.class);
if (mPlant != null) {
String species = mPlant.getSpecies();
TextView speciesTextView = getActivity().findViewById(R.id.plant_species);
speciesTextView.setText(getActivity().getString(R.string.species_fmt, species));
CollapsingToolbarLayout collapsingToolbarLayout = getActivity().findViewById(R.id.toolbar_layout);
collapsingToolbarLayout.setTitle(mPlant.getName());
TextView HeightTextView = getActivity().findViewById(R.id.plant_height);
HeightTextView.setText(getActivity().getString(R.string.height_fmt, mPlant.getHeight()));
loadCareTips(species);
}
}
@Override
public void onCancelled(@NotNull DatabaseError databaseError) {
}
});
}
}
示例8: init
import android.support.design.widget.CollapsingToolbarLayout; //導入依賴的package包/類
@Override
protected void init() {
setSupportActionBar(toolbar);
if (getSupportActionBar() != null) {
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
}
CollapsingToolbarLayout appBarLayout =
(CollapsingToolbarLayout) findViewById(R.id.toolbar_layout);
if (appBarLayout != null) {
appBarLayout.setTitle(collection.getName());
} else if (getSupportActionBar() != null) {
getSupportActionBar().setTitle(collection.getName());
}
// setting values
txtAuthorName.setText(collection.getAuthor().getName());
txtAuthorLoc.setText(collection.getAuthor().getLocation());
txtDateCreate.setText(collection.getDate_created());
txtDesc.setText(collection.getDescription());
LinearLayoutManager linearLayoutManager = new LinearLayoutManager(this);
recyclerView.setLayoutManager(linearLayoutManager);
recyclerView.setAdapter(iconAdapter);
RecyclerItemUtils.addTo(recyclerView).setOnItemClickListener(this);
// load selected noun collections icons
presenter.getCollectionIconsById(collection.getId());
}
示例9: onCreate
import android.support.design.widget.CollapsingToolbarLayout; //導入依賴的package包/類
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
typeface=Typeface.createFromAsset(getAssets(),"canaro_extra_bold.otf");
setContentView(R.layout.activity_event_item);
LogSaver.appendLog(TAG);
collapsingToolbarLayout= (CollapsingToolbarLayout) findViewById(R.id.collapsing_toolbar);
collapsingToolbarLayout.setExpandedTitleTypeface(typeface);
collapsingToolbarLayout.setExpandedTitleColor(Color.parseColor("#FFFFFF"));
iv_bg=(ImageView) findViewById(R.id.event_bg);
Picasso.with(this).load(Config.EVENT_BG).placeholder(R.drawable.backsplash).into(iv_bg);
toolbar=(Toolbar) findViewById(R.id.toolbar_event);
setSupportActionBar(toolbar);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
toolbar.setNavigationOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
finish();
}
});
tabLayout= (TabLayout) findViewById(R.id.tabs);
viewPager= (ViewPager) findViewById(R.id.viewpager_event);
setupViewPager(viewPager);
tabLayout.setupWithViewPager(viewPager);
}
示例10: withCollapsingToolbarTitle
import android.support.design.widget.CollapsingToolbarLayout; //導入依賴的package包/類
private static Matcher<Object> withCollapsingToolbarTitle(
final Matcher<CharSequence> textMatcher) {
return new BoundedMatcher<Object, CollapsingToolbarLayout>(CollapsingToolbarLayout.class) {
@Override
public void describeTo(Description description) {
description.appendText("with collapsing toolbar title: ");
textMatcher.describeTo(description);
}
@Override
protected boolean matchesSafely(CollapsingToolbarLayout collapsingToolbarLayout) {
return textMatcher.matches(collapsingToolbarLayout.getTitle());
}
};
}
示例11: onCreate
import android.support.design.widget.CollapsingToolbarLayout; //導入依賴的package包/類
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_fruit);
Intent intent = getIntent();
String fruitName = intent.getStringExtra(FRUIT_NAME);
int fruitImageId = intent.getIntExtra(FRUIT_IMAGE_ID, 0);
String fruitinfo = intent.getStringExtra(FRUIT_INFO);
byte[] in = intent.getByteArrayExtra(FRUIT_IMAGE);
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
CollapsingToolbarLayout collapsingToolbar = (CollapsingToolbarLayout) findViewById(R.id.collapsing_toolbar);
ImageView fruitImageView = (ImageView) findViewById(R.id.fruit_image_view);
TextView fruitContentText = (TextView) findViewById(R.id.fruit_content_text);
setSupportActionBar(toolbar);
ActionBar actionBar = getSupportActionBar();
if (actionBar != null) {
actionBar.setDisplayHomeAsUpEnabled(true);
}
collapsingToolbar.setTitle(fruitName);
if(fruitImageId==0)
{
Bitmap fruitimage = BitmapFactory.decodeByteArray(in, 0, in.length);
fruitImageView.setImageBitmap(fruitimage);
}
else Glide.with(this).load(fruitImageId).into(fruitImageView);
String fruitContent = generateFruitContent(fruitinfo);
fruitContentText.setText(fruitContent);
}
示例12: initializeToolbar
import android.support.design.widget.CollapsingToolbarLayout; //導入依賴的package包/類
private void initializeToolbar() {
final CollapsingToolbarLayout collapsingToolbar =
(CollapsingToolbarLayout) findViewById(R.id.collapsing_toolbar);
collapsingToolbar.setTitle("");
Toolbar mToolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(mToolbar);
getSupportActionBar().setHomeButtonEnabled(true);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
getSupportActionBar().setTitle("");
mToolbar.setNavigationOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
onBackPressed();
}
});
}
示例13: findViews
import android.support.design.widget.CollapsingToolbarLayout; //導入依賴的package包/類
private void findViews() {
fab = (FloatingActionButton) findViewById(R.id.fab);
fab.setOnClickListener(this);
mLayout = (RelativeLayout) findViewById(R.id.layout_chat_empty);
mTabLayout = (TabLayout) findViewById(R.id.tabLayout);
mTabLayout.addTab(mTabLayout.newTab().setText("Public"));
mTabLayout.addTab(mTabLayout.newTab().setText("Private"));
mDrawer = (DrawerLayout) findViewById(R.id.drawer_layout);
mToolbar = (Toolbar) findViewById(R.id.toolbar);
toolbarLayout = (CollapsingToolbarLayout) findViewById(R.id.collapsing_toolbar_layout);
toolbarParams = (AppBarLayout.LayoutParams) toolbarLayout.getLayoutParams();
setSupportActionBar(mToolbar);
mTextOnToolbar = (TextView) findViewById(R.id.chat_toolbar_title);
mNavigationView = (NavigationView) findViewById(R.id.nav_view);
progressBar = (ProgressBar) findViewById(R.id.main_progress_bar);
progressBar.getIndeterminateDrawable()
.setColorFilter(getResources().getColor(R.color.colorPrimary), android.graphics.PorterDuff.Mode.MULTIPLY);
}
示例14: initActivity
import android.support.design.widget.CollapsingToolbarLayout; //導入依賴的package包/類
@Override
protected void initActivity(@Nullable Bundle savedInstanceState) {
presenter = new MainPresenter(this);
homeBanner = (ImageView) findViewById(iv_home_banner);
tabLayout = (TabLayout) findViewById(R.id.tab_home_category);
appBarLayout = (AppBarLayout) findViewById(R.id.appbar);
viewPager = (ViewPager) findViewById(R.id.vp_home_category);
floatingActionButton = (FloatingActionButton) findViewById(R.id.fab_home_random);
coordinatorLayout = (CollapsingToolbarLayout) findViewById(R.id.collapsing_toolbar);
setting = (AppCompatImageView) findViewById(R.id.iv_home_setting);
setFabDynamicState();
homeBanner.setOnClickListener(this);
floatingActionButton.setOnClickListener(this);
setting.setOnClickListener(this);
presenter.getServerData();
viewPager.setAdapter(new MainPagerAdapter(getSupportFragmentManager()));
tabLayout.setupWithViewPager(viewPager);
}
示例15: onCreate
import android.support.design.widget.CollapsingToolbarLayout; //導入依賴的package包/類
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
//app:statusBarScrim 狀態欄紗布 需要侵入statusbar,使用透明化布局
// getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
setContentView(R.layout.activity_collapsing_toolbar_layout);
Toolbar mToolbar = findViewById(R.id.toolbar);
CollapsingToolbarLayout mCollapsingToolbarLayout = findViewById(R.id.CollapsingToolbarLayout);
mCollapsingToolbarLayout.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Log.e("CollapsingToolbarLayout","CollapsingToolbarLayout");
}
});
mToolbar.setTitle("CollapsingToolbarLayout");
setSupportActionBar(mToolbar);
}