Java Code Examples for android.support.v7.widget.Toolbar#setAlpha()

The following examples show how to use android.support.v7.widget.Toolbar#setAlpha() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ScrollToolBarBehavior.java    From RxZhihuDaily with MIT License 5 votes vote down vote up
private void setToolBarStatus(Toolbar toolbar, float scrollY){
    int toolbarHeight = toolbar.getHeight();

    float contentHeight = getStoryHeaderViewHeight() - toolbarHeight;
    float ratio = Math.min(scrollY / contentHeight, 1.0f);
    toolbar.setAlpha((int) (ratio * 0xFF));
}
 
Example 2
Source File: GalleryActivity.java    From HeartBeat with Apache License 2.0 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_gallery);

    long eventId = getIntent().getLongExtra(EVENT_ID, -1);
    String path = "";
    if (eventId == -1) {
        path = getIntent().getStringExtra(PATH);
    }

    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    toolbar.setBackgroundColor(Color.BLACK);
    toolbar.setTitle("");
    toolbar.setAlpha(0.6f);
    setSupportActionBar(toolbar);
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);

    mImage = (PhotoView) findViewById(R.id.imageview);

    mImage.setOnPhotoTapListener(new PhotoViewAttacher.OnPhotoTapListener() {
        @Override
        public void onPhotoTap(View view, float x, float y) {
            finish();
        }
    });

    if (eventId != -1) {
        String imagePath = ImageUtils.getImageByEventId(this, eventId).getPath();
        Glide.with(this).load(GalleryUtils.getImagePath(imagePath)).into(mImage);
    } else {
        Glide.with(this).load(GalleryUtils.getImagePath(path)).into(mImage);
    }
}