项目作者: nahzur-h

项目描述 :
A simple transparent toolbar
高级语言: Kotlin
项目地址: git://github.com/nahzur-h/Transparent-Delegate-Toolbar.git
创建时间: 2016-07-03T10:10:15Z
项目社区:https://github.com/nahzur-h/Transparent-Delegate-Toolbar

开源协议:Apache License 2.0

下载


Transparent-Delegate-Toolbar

A simple transparent toolbar for Android

Screenshots

Transparent-Delegate-Toolbar use Delegate finish scroll change color to alpha

Gradle

Add it in your root build.gradle at the end of repositories:

  1. allprojects {
  2. repositories {
  3. ...
  4. maven { url 'https://jitpack.io' }
  5. }
  6. }

Add the dependency:

  1. dependencies {
  2. compile 'com.github.ruzhan123:Transparent-Delegate-Toolbar:v1.0'
  3. }

Usage

  1. <zhan.transparent.widget.TransparentFrameLayout
  2. android:id="@+id/tool_bar"
  3. android:layout_width="match_parent"
  4. android:layout_height="48dp">
  1. mTransparentFrameLayout.setColorToBackGround(getResources().getColor(R.color.colorPrimary));
  2. mTransparentFrameLayout.setMaxOffset(getResources().getDimension(R.dimen.offset));
  1. mRecyclerView.addOnScrollListener(new RecyclerView.OnScrollListener() {
  2. @Override public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
  3. super.onScrolled(recyclerView, dx, dy);
  4. mDy += dy;
  5. mTransparentFrameLayout.updateTop(mDy);
  6. }
  7. });

Delegate

Implementing View

Custom

  1. public class TransparentToolBar extends Toolbar implements ITransparentDelegate {
  2. private TransparentDelegate mTransparentDelegate;
  3. public TransparentToolBar(Context context) {
  4. super(context);
  5. init();
  6. }
  7. public TransparentToolBar(Context context, AttributeSet attrs) {
  8. super(context, attrs);
  9. init();
  10. }
  11. public TransparentToolBar(Context context, AttributeSet attrs, int defStyleAttr) {
  12. super(context, attrs, defStyleAttr);
  13. init();
  14. }
  15. private void init() {
  16. mTransparentDelegate = new TransparentDelegate(this);
  17. }
  18. @Override public void updateTop(float top) {
  19. mTransparentDelegate.updateTop(top);
  20. }
  21. @Override public void setMaxOffset(float offset) {
  22. mTransparentDelegate.setMaxOffset(offset);
  23. }
  24. @Override public void setColorToBackGround(int backGroundColor) {
  25. mTransparentDelegate.setColorToBackGround(backGroundColor);
  26. }
  27. ...

expand

  1. public interface OnTransparentListener {
  2. void onTransparentStart(float fraction); //scroll to top, offset is 0
  3. void onTransparentEnd(float fraction); //scroll to max offset
  4. void onTransparentUpdateFraction(float fraction); //scrolling...
  5. }

Developed by

ruzhan - dev19921116@gmail.com

License

  1. Copyright 2017 ruzhan
  2. Licensed under the Apache License, Version 2.0 (the "License");
  3. you may not use this file except in compliance with the License.
  4. You may obtain a copy of the License at
  5. http://www.apache.org/licenses/LICENSE-2.0
  6. Unless required by applicable law or agreed to in writing, software
  7. distributed under the License is distributed on an "AS IS" BASIS,
  8. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  9. See the License for the specific language governing permissions and
  10. limitations under the License.