GithubHelp home page GithubHelp logo

vishal-sehgal / google-message-app-fab-clone Goto Github PK

View Code? Open in Web Editor NEW
10.0 1.0 2.0 2.72 MB

In this app you'll get the FloatingActionButton like Google's Message App.

License: MIT License

Kotlin 100.00%
android recyclerview nestedrecyclerview appbarlayout coordinatorlayout floatingactionbutton floating-action-button

google-message-app-fab-clone's People

Contributors

vishal-sehgal avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

google-message-app-fab-clone's Issues

when we have Fab extended and CollapsingToolbarLayout , we cant minimze or something like this in both!

Hello
I hope you are fine
I have a project in which I wanted a picture to be displayed at the top of the page and a title and text below it, and when the user pulls the page down, the picture slowly fades from the page, and when the user pulls the page down, the picture disappears. The picture slowly appears
I implemented this
But when I wanted to have both this issue and the floatingactionbutton in this way, it didn't work!
It means that this FAB will return from the extended mode to the normal reduced mode

<androidx.coordinatorlayout.widget.CoordinatorLayout
android:id="@+id/cordinatorasli"
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".MainActivity2">


    <com.google.android.material.appbar.AppBarLayout
        android:id="@+id/appbar_2"
        android:layout_width="match_parent"
        android:layout_height="wrap_content">

        <com.google.android.material.appbar.CollapsingToolbarLayout
            android:id="@+id/collapsing_toolbar_mainactivity2_test"
            android:theme="@style/Theme.MaterialComponents"
            app:contentScrim="@color/abie_firozei"
            app:layout_scrollFlags="scroll"
            android:layout_width="match_parent"
            android:layout_height="wrap_content">

            <ImageView

                app:layout_collapseMode="parallax"
                android:id="@+id/img_profili_aks"
                android:adjustViewBounds="true"
                android:src="@drawable/mohsenchavoshi"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"/>


            <androidx.appcompat.widget.Toolbar
                app:layout_collapseMode="pin"

                android:id="@+id/toolbar_asli2"
                android:layout_width="match_parent"
                android:layout_height="56dp"/>

        </com.google.android.material.appbar.CollapsingToolbarLayout>



    </com.google.android.material.appbar.AppBarLayout>

   <androidx.core.widget.NestedScrollView
       android:id="@+id/nested_changes2"
       app:layout_behavior="com.google.android.material.appbar.AppBarLayout$ScrollingViewBehavior"
       android:layout_width="match_parent"
       android:layout_height="match_parent">

       <LinearLayout
           android:padding="16dp"
          android:orientation="vertical"
           android:layout_width="match_parent"
           android:layout_height="wrap_content">

           <TextView
               android:textStyle="bold|italic"
               android:textSize="22sp"
               android:textColor="@color/blacklight"
               android:text="Lorem"
               android:layout_width="wrap_content"
               android:layout_height="wrap_content"/>

           <TextView
               android:textColor="@color/blacklight"
               android:layout_marginTop="6dp"
               android:lineSpacingExtra="8dp"
               android:text="Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer nec odio. Praesent libero. Sed cursus ante dapibus diam. Sed nisi. Nulla quis sem at nibh elementum imperdiet. Duis sagittis ipsum. Praesent mauris. Fusce nec tellus sed augue semper porta. Mauris massa. Vestibulum lacinia arcu eget nulla. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Curabitur sodales ligula in libero. Sed dignissim lacinia nunc. Curabitur tortor. Pellentesque nibh. Aenean quam. In scelerisque sem at dolor. Maecenas mattis. Sed convallis tristique sem. Proin ut ligula vel nunc egestas porttitor. Morbi lectus risus, iaculis vel, suscipit quis, luctus non, massa. Fusce ac turpis quis ligula lacinia aliquet. Mauris ipsum. Nulla metus metus, ullamcorper vel, tincidunt sed, euismod in, nibh. Quisque volutpat condimentum velit. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Nam nec ante. Sed lacinia, urna non tincidunt mattis, tortor neque adipiscing diam, a cursus ipsum ante quis turpis. Nulla facilisi. Ut fringilla. Suspendisse potenti. Nunc feugiat mi a tellus consequat imperdiet. Vestibulum sapien. Proin quam. Etiam ultrices. Suspendisse in justo eu magna luctus suscipit. Sed lectus. Integer euismod lacus luctus magna. Quisque cursus, metus vitae pharetra auctor, sem massa mattis sem, at interdum magna augue eget diam. "
               android:layout_width="wrap_content"
               android:layout_height="wrap_content"/>


       </LinearLayout>




   </androidx.core.widget.NestedScrollView>
    <com.google.android.material.floatingactionbutton.ExtendedFloatingActionButton
        android:id="@+id/extFloatingActionButton"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="end|bottom"
        android:layout_marginEnd="16dp"
        android:layout_marginBottom="16dp"
        android:text="ACTIONS"
        android:textColor="@android:color/white"
        app:icon="@drawable/ic_web"
        app:iconTint="@android:color/white" />






</androidx.coordinatorlayout.widget.CoordinatorLayout>

and also my coding:

    class MainActivity2 : AppCompatActivity() {
    lateinit var binding:ActivityMain2Binding
    private var fabTitle: TextView? = null
    private var appbar: AppBarLayout? = null


    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        binding= ActivityMain2Binding.inflate(layoutInflater)
        setContentView(binding.root)

        setSupportActionBar(binding.toolbarAsli2)


        val extendedFloatingActionButton =findViewById<ExtendedFloatingActionButton>(R.id.extFloatingActionButton)
        val nestedScrollView = findViewById<NestedScrollView>(R.id.nested_changes2)

        nestedScrollView.setOnScrollChangeListener(NestedScrollView.OnScrollChangeListener { v, scrollX, scrollY, oldScrollX, oldScrollY -> // the delay of the extension of the FAB is set for 12 items
            if (scrollY > oldScrollY + 12 && extendedFloatingActionButton.isExtended) {
                extendedFloatingActionButton.shrink()
            }

            // the delay of the extension of the FAB is set for 12 items
            if (scrollY < oldScrollY - 12 && !extendedFloatingActionButton.isExtended) {
                extendedFloatingActionButton.extend()
            }

            // if the nestedScrollView is at the first item of the list then the
            // extended floating action should be in extended state
            if (scrollY == 0) {
                extendedFloatingActionButton.extend()
            }
        })




        binding.collapsingToolbarMainactivity2Test.setExpandedTitleColor(
            ContextCompat.getColor(this,android.R.color.transparent)


        )


        supportActionBar!!.setHomeButtonEnabled(true)
        supportActionBar!!.setDisplayHomeAsUpEnabled(true)

        binding.collapsingToolbarMainactivity2Test.title="تست"







    }

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.