/FloatOptionButton

🎈 Float Option Button is a Float Action Button (fab) with two option button drawer that can expand and collapse with many custom attrs

Primary LanguageKotlinApache License 2.0Apache-2.0

FloatOptionButton

Developer Lisense Download

🎈 Float Option Button is a Float Action Button (fab) with two option button drawer that can expand and collapse with many custom attrs

screenshot

Gradle & Maven

 implementation 'ir.sinadalvand.libs:floatoptionbutton:1.0.2'
<dependency>
	<groupId>ir.sinadalvand.libs</groupId>
	<artifactId>floatoptionbutton</artifactId>
	<version>1.0.2</version>
	<type>pom</type>
</dependency>

How use this Fob :

<ir.sinadalvand.floatoptionbutton.FloatOptionButton
	android:id="@+id/floatOptionButton"
	app:fob_animDuration="300"                  ==> animation duration to open or close
	app:fob_autoCollapseInClick="false"         ==> auto collapse after click on any button of this view
	app:fob_backgroundColor="#f66767"           ==> color background of expanded rabon
	app:fob_buttonColor="@android:color/white"  ==> main button color (center float action button)
	app:fob_scale="3.5"                         ==> scale size of option width against collapse size
	app:fob_open="false"                        ==> if true view will be expanded as default 
	app:fob_leftIcon="@drawable/ic_image"       ==> left button icon as Drawable
	app:fob_rightIcon="@drawable/ic_airplay"    ==> right button icon as Drawable
	app:fob_mainIcon="@drawable/ic_lock"        ==> main button (center button) icon as Drawable
	app:fob_scaleWidth="100dp"                  ==> width fix size for expanded (it will overrite to fob_scale)
	/>

Buttons click Listener: :

   floatOptionButton.setFloatOptionListener(object :FloatOptionButtonListener{
		override fun mainButtonClicked(view: View) {
			// main button clicked! (center button)
		}

		override fun leftButtonClicked(view: View) {
			// left button clicked! (center button)
		}

		override fun rightButtonClicked(view: View) {
		   // right button clicked! (center button)
		}

	})

For toggle between Collapse and Expanded :

   floatOptionButton.toggle()

For Collapse:

   floatOptionButton.collapse()

For Expand:

   floatOptionButton.expand()

and also can set all thr xml attrs by code:

floatOptionButton.setMainButtonColor(color: Int) 
floatOptionButton.setSidesButtonColor(color: Int)
floatOptionButton.setFobBackgroundColor(color: Int)
floatOptionButton.setMainButtonIcon(res: Int)
floatOptionButton.setLeftButtonIcon(res: Int)
floatOptionButton.setRightButtonIcon(res: Int)
floatOptionButton.isOpen(boolean: Boolean)
floatOptionButton.setScale(scale: Float)
floatOptionButton.setAnimationDuration(duration: Int)
floatOptionButton.setMaxWidth(width: Int)

and if you want to apply more customization , you can get buttons by :

floatOptionButton.getMainButton()   ==> FloatingActionButton
floatOptionButton.getRightButton()  ==> ImageView
floatOptionButton.getLeftButton()   ==> ImageView

License

Copyright 2019 Sina Dalvand

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.