当前位置: 首页>>代码示例>>Java>>正文


Java CollapsingToolbarLayout类代码示例

本文整理汇总了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" +
            "防疫方法  由于病菌可系统地侵染桧柏的茎和常绿的叶,因此没有一种化学处理方法能取得令人满意的效果。有人提出应用放线菌酮来抑制雪松-苹果锈病菌的冬孢子产生,这项措施可作为对受侵染植物的短期检疫处理方法以防植物死亡。冬孢子极可能由受侵染植物制成的包装材料携带。");
}
 
开发者ID:lupwei,项目名称:Croprotector,代码行数:25,代码来源:SuggestionActivity.java

示例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);
//                }
//            }
//        });
    }
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:47,代码来源:StatusBarCompatKitKat.java

示例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);
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:19,代码来源:MainActivity.java

示例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);
}
 
开发者ID:Qinlong275,项目名称:AndroidBookTest,代码行数:22,代码来源:FruitActivity.java

示例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);
        }
    }
}
 
开发者ID:yrom,项目名称:shrinker,代码行数:18,代码来源:ItemDetailFragment.java

示例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();
}
 
开发者ID:Luodian,项目名称:Shared-Route,代码行数:20,代码来源:MyRank.java

示例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) {

            }
        });
    }
}
 
开发者ID:iskandergaba,项目名称:Botanist,代码行数:29,代码来源:PlantController.java

示例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());
}
 
开发者ID:graviton57,项目名称:TheNounProject,代码行数:26,代码来源:CollectionDetailActivity.java

示例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);

}
 
开发者ID:rishabh115,项目名称:Odyssey2017,代码行数:27,代码来源:EventItemActivity.java

示例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());
        }

    };
}
 
开发者ID:ecarrara-araujo,项目名称:yabaking,代码行数:18,代码来源:ToolbarMatchers.java

示例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);
}
 
开发者ID:android-app-development-course,项目名称:fruit,代码行数:29,代码来源:FruitActivity.java

示例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();
        }
    });
}
 
开发者ID:vipulyaara,项目名称:betterHotels,代码行数:18,代码来源:HotelVocabActivity.java

示例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);
}
 
开发者ID:ukevgen,项目名称:BizareChat,代码行数:19,代码来源:MainActivity.java

示例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);

}
 
开发者ID:penghongru,项目名称:Coder,代码行数:26,代码来源:MainActivity.java

示例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);
    }
 
开发者ID:LinweiJ,项目名称:MaterialDesignWidget,代码行数:18,代码来源:CollapsingToolbarLayoutActivity.java


注:本文中的android.support.design.widget.CollapsingToolbarLayout类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。