This repository has been archived by the owner on Jan 14, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 23
Old Readme
Dani Mahardhika edited this page Oct 29, 2017
·
1 revision
An upgraded Snackbar for Android that provides more options and easy to use. Download sample apk from here.
The minimum API level supported by this library is API 13
Add JitPack repository to root build.gradle
allprojects {
repositories {
maven { url "https://jitpack.io" }
}
}
Add the dependency
dependencies {
compile 'com.github.danimahardhika:cafebar:1.2.0'
}
CafeBar.make(context, R.string.text, CafeBarDuration.SHORT).show();
CafeBar.builder(context)
.theme(CafeBarTheme.LIGHT)
.content(R.string.text)
.neutralText("Action")
//You can parse string color
.neutralColor(Color.parseColor("#EEFF41"))
//Or use color resource
.neutralColor(R.color.neutralText)
.show();
CafeBar.Builder builder = new CafeBar.Builder(context);
...
CafeBar cafeBar = builder.build();
View v = cafeBar.getCafeBarView();
//Do something
cafeBar.show();
CafeBar.builder(context)
.content("some text")
.floating(true)
.show();
CafeBar.builder(context)
.content(R.string.text)
//automatically determine if device has soft navigation bar and translucent navigation bar
.fitSystemWindow()
.show();
CafeBar.builder(context)
//With release 1.0.7 you can use custom theme
//In release 1.1.7 and up CafeBarTheme.Custom has private access
//Text color (content and buttons) automatically set
.theme(CafeBarTheme.Custom(Color.parseColor("#F44336")));
.content(R.string.text)
.show();
CafeBar.builder(context)
.content(R.string.text)
//You must place your font inside assets/fonts/ folder
.contentTypeface("RobotoMono-Regular.ttf")
//Or
.contentTypeface(Typeface.createFromAsset(context.getAssets(), "fonts/RobotoMono-Regular.ttf");
.show();
Builder
-
customView()
→ Use custom view -
to()
→ Set target view, it should beCoordinatorLayout
-
content()
→ Content text -
contentTypeface()
→ Custom typeface for content -
maxLines()
→ Max content lines, must be between 1 to 6. -
duration()
→ Show duration -
theme()
→ CafeBar theme, there are 3 choices availableDARK
(default),LIGHT
, andCLEAR_BLACK
. With release 1.0.7 you can use custom themenew CafeBarTheme.Custom(int)
. In release 1.1.6Custom()
has private access, useCafeBarTheme.Custom(int)
instead. -
icon()
→ Icon shown on left side of content -
showShadow()
→ Enable or disable shadow -
autoDismiss()
→ Enable or disable auto dismiss, default is true -
swipeToDismiss()
→ Enable or disable swipe to dismiss, only works with target viewCoordinatorLayout
. -
floating()
→ Set CafeBar style to floating -
gravity()
→ Set CafeBar view gravity, only works for tablet and floating -
fitSystemWindow()
→ Show CafeBar above translucent navigation bar -
neutralText()
→ Neutral action text -
neutralColor()
→ Neutral action text color -
neutralTypeface()
→ Custom typeface for neutral text -
onNeutral()
→ Neutral action callback -
positiveText()
→ Positive action text -
positiveColor()
→ Positive action text color -
positiveTypeface()
→ Custom typeface for positive text -
onPositive()
→ Positive action callback -
negativeText()
→ Negative action text -
negativeColor()
→ Negative action text color -
negativeTypeface()
→ Custom typeface for negative text -
onNegative()
→ Negative action callback -
buttonColor()
→ Set all buttons color -
buttonTypeface()
→ Set all buttons typeface -
typeface()
→ Set content and button typeface -
show()
→ Show CafeBar directly from builder -
build()
→ Create CafeBar
CafeBar
-
make()
→ Create CafeBar -
setAction()
→ It's the same with neutral action from builder, ifneutralText()
already set from buildersetAction()
will be ignored. -
getCafeBarView()
→ Get root view of CafeBar -
show()
→ Show CafeBar -
dismiss()
→ Dismiss CafeBar
Copyright (c) 2017 Dani Mahardhika
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.