Coder Social home page Coder Social logo

ranyalbegwein / appbartranslatescalebehavior Goto Github PK

View Code? Open in Web Editor NEW
92.0 8.0 13.0 7.56 MB

A CoordinatorLayout.Behavior<View> which interacts with an AppBarLayout as a dependency for translating and scaling a specific View of your choice.

Java 100.00%

appbartranslatescalebehavior's Introduction

AppBarTranslateScaleBehavior


A CoordinatorLayout.Behavior<View> which interacts with an AppBarLayout as a dependency for translating and scaling a specific View of your choice.

Watch how the CircularImageView translates and scales to be finally located in the ToolBar:

alt text

Usage


The following explanation uses the terms source-view and destination-view.

  • source-view : The View on which the Behavior is attached representing the initial state - before translation and scaling.
  • destination-view : The View to which the source-view will translate and scale - representing the final state of the source-view.

Download Android Arsenal

Buy Me a Coffee at ko-fi.com

  1. Edit your build.gradle to include the library and sync.
dependencies {
    compile 'com.rany.albeg.wein:appbar-translate-scale-behavior:1.0.0'
}

Or with Maven:

<dependency>
  <groupId>com.rany.albeg.wein</groupId>
  <artifactId>appbar-translate-scale-behavior</artifactId>
  <version>1.0.0</version>
  <type>pom</type>
</dependency>
  1. Create a destination-view anywhere inside your CoordinatorLayout and give it an id. For example, in the preview above you can see that the final state of the profile image is a small icon (32dp X 32dp) located to the left of the ToolBar's title, therefore the destination-view:
            <android.support.v7.widget.Toolbar
            	... >
				<!-- Destination View start -->
                <View
                    android:id="@+id/v_destination_profile_image"
                    android:layout_width="32dp"
                    android:layout_height="32dp"
                    android:visibility="invisible"/>
                <!-- Destination View end -->

            </android.support.v7.widget.Toolbar>
  1. Attach the Behavior to a source-view of your choice and connect it with the destination-view, by adding the app:layout_behavior and app:behavior_destination_id attributes. For example, in the preview above I attached the Behavior to a CircularImageView representing the source-view which is connected to a destination-view with an @id/v_destination_profile_image like so:
    <com.mikhaellopez.circularimageview.CircularImageView
        android:layout_width="120dp"
        android:layout_height="100dp"
        ...
        app:behavior_destination_id="@id/v_destination_profile_image"
        app:layout_behavior="@string/appbar_translate_scale_behavior"/>

That's it, you're ready to go!

Issues

  • destination-view disappears:

    • 1 Set an elevation of 4dp + on source-view.

    OR

    • 2 Set elevation of 0dp on AppBarLayout.

AUTHOR

Rany Albeg Wein

LICENSE

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

appbartranslatescalebehavior's People

Stargazers

Benzhang09 avatar ruixiang_cao avatar  avatar  avatar Botirali Kozimov avatar yii avatar Benoit Billington avatar Hán Trung Kiên avatar BEAN avatar Gilyong Park avatar  avatar RahimpourDeveloper avatar beeftime avatar Rupesh Urmaliya avatar  avatar Masoud Mohammadi avatar klwb avatar Kenny Goers avatar Nadeem Iqbal avatar TaTa avatar Patryk Cyrzan avatar  avatar Beka Kukhalashvili avatar Neil avatar 周嘉 avatar  avatar  avatar Rofie Sagara avatar Sudipta K Paik avatar wangyl avatar MoRostami avatar  avatar Edgar Ceballos avatar zf avatar Seth Lopez avatar Tim avatar PengPeng avatar Yura F avatar NiceCoder avatar Vinh Bui avatar Job Getabu avatar  avatar Makamu L. Evans avatar Burhan Khanzada avatar Jeff Andeko avatar hyl87 avatar macszh2013 avatar Steephan Selvaraj avatar Yumcoder avatar A.samad Mahmoodi avatar Su avatar 沈阳熊宝宝科技有限公司-张振虎 avatar Jaydip_Meghapara(JD) avatar  avatar Maksym Mamuta avatar Natig Babayev avatar Ankit Maurya avatar Darshan Mistry avatar Pranav Lathigara avatar Trung Nguyen avatar Nisarg avatar MAY3AM avatar Alexander Štimac avatar Juan Esteban Londoño Tabares avatar Adriano Nascimento avatar  avatar Alexander Girke avatar  avatar Daniel avatar Jungle avatar  avatar  avatar Suraj Singh Pawar avatar Mas Kipli avatar xiawei avatar Abdul-Mujeeb Aliu avatar Anton Lookin avatar Rainer-Lang avatar David Ruiz avatar Huang Ying avatar Mayur Solanki avatar alphaDroid89 avatar Adeyinka Adediji avatar ARKINA avatar Wellington Ribeiro avatar Andy Barber avatar Phùng Văn Hoà avatar Pavel avatar Huy Nguyen avatar Raúl Pera Pairó avatar Mohamed Nabil avatar Rany Albeg Wein avatar

Watchers

James Cloos avatar  avatar Rany Albeg Wein avatar  avatar Steephan Selvaraj avatar Jeff Andeko avatar bill avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.