bitvale / switcher Goto Github PK
View Code? Open in Web Editor NEWAndroid implementation of switch animation from Oleg Frolov
Home Page: https://android.jlelse.eu/android-dynamic-custom-view-is-easy-433258cbb80f
Android implementation of switch animation from Oleg Frolov
Home Page: https://android.jlelse.eu/android-dynamic-custom-view-is-easy-433258cbb80f
Can you add one more wait state? Because in some cases it takes a while to open
Please, how to use it in Java
if (shadow == null) {
shadow = Bitmap.createBitmap(width, height, Bitmap.Config.ALPHA_8)
}
Default set isChecked = false value, exception: IllegalArgumentException - width and height must be > 0
if (shadow == null) {
val w = if (width > 0) width else defWidth
val h = if (height > 0) height else defHeight
shadow = Bitmap.createBitmap(w, h, Bitmap.Config.ALPHA_8)
}
Hello, is there any way to change the icon of switcher? for example can i change icon to play and pause ty
Release on MavenCentral?
I followed the steps mentioned in your readme. But when I try to inflate a layout (which contains the switcher) inside a fragment class, the app crashes and throws the following error: "Error inflating class com.bitvale.switcher.Switcherx".
android sdk: 6.0
android {
compileSdkVersion 29
defaultConfig {
applicationId "*******"
minSdkVersion 23
targetSdkVersion 29
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
implementation 'com.google.android.material:material:1.1.0'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
implementation 'androidx.cardview:cardview:1.0.0'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test.ext:junit:1.1.1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
implementation 'com.bitvale:switcher:1.0.9'
}
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent">
<com.bitvale.switcher.SwitcherX
android:id="@+id/switcher"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:switcher_on_color="@color/primary"
app:switcher_off_color="@color/secondary"
app:switcher_icon_color="#ffffff"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
public class TrackFragment extends Fragment {
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
return inflater.inflate(R.layout.track_view, container, false);
}
}
android.view.InflateException: Binary XML file line #17: Binary XML file line #17: Error inflating class com.bitvale.switcher.SwitcherX
Caused by: java.lang.NoClassDefFoundError: Failed resolution of: Lkotlin/jvm/internal/Intrinsics;
at com.bitvale.switcher.SwitcherX.<init>(SwitcherX.kt)
at com.bitvale.switcher.SwitcherX.<init>(SwitcherX.kt:52)
at com.bitvale.switcher.SwitcherX.<init>(SwitcherX.kt)
at java.lang.reflect.Constructor.newInstance(Native Method)
at android.view.LayoutInflater.createView(LayoutInflater.java:619)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:764)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:704)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:835)
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:798)
at android.view.LayoutInflater.inflate(LayoutInflater.java:515)
at android.view.LayoutInflater.inflate(LayoutInflater.java:423)
at com.adify.driver.fragments.nav_fragments.TrackFragment.onCreateView(TrackFragment.java:18)
at androidx.fragment.app.Fragment.performCreateView(Fragment.java:2600)
at androidx.fragment.app.FragmentManagerImpl.moveToState(FragmentManagerImpl.java:881)
at androidx.fragment.app.FragmentManagerImpl.moveFragmentToExpectedState(FragmentManagerImpl.java:1238)
at androidx.fragment.app.FragmentManagerImpl.moveToState(FragmentManagerImpl.java:1303)
at androidx.fragment.app.BackStackRecord.executeOps(BackStackRecord.java:439)
at androidx.fragment.app.FragmentManagerImpl.executeOps(FragmentManagerImpl.java:2079)
at androidx.fragment.app.FragmentManagerImpl.executeOpsTogether(FragmentManagerImpl.java:1869)
at androidx.fragment.app.FragmentManagerImpl.removeRedundantOperationsAndExecute(FragmentManagerImpl.java:1824)
at androidx.fragment.app.FragmentManagerImpl.execPendingActions(FragmentManagerImpl.java:1727)
at androidx.fragment.app.FragmentManagerImpl$2.run(FragmentManagerImpl.java:150)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:5417)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
Caused by: java.lang.ClassNotFoundException: Didn't find class "kotlin.jvm.internal.Intrinsics" on path: DexPathList[[zip file "/data/app/com.adify.driver-1/base.apk"],nativeLibraryDirectories=[/data/app/com.adify.driver-1/lib/x86, /vendor/lib, /system/lib]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
at java.lang.ClassLoader.loadClass(ClassLoader.java:511)
at java.lang.ClassLoader.loadClass(ClassLoader.java:469)
at com.bitvale.switcher.SwitcherX.<init>(SwitcherX.kt)
at com.bitvale.switcher.SwitcherX.<init>(SwitcherX.kt:52)
at com.bitvale.switcher.SwitcherX.<init>(SwitcherX.kt)
at java.lang.reflect.Constructor.newInstance(Native Method)
at android.view.LayoutInflater.createView(LayoutInflater.java:619)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:764)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:704)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:835)
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:798)
at android.view.LayoutInflater.inflate(LayoutInflater.java:515)
at android.view.LayoutInflater.inflate(LayoutInflater.java:423)
at com.adify.driver.fragments.nav_fragments.TrackFragment.onCreateView(TrackFragment.java:18)
at androidx.fragment.app.Fragment.performCreateView(Fragment.java:2600)
at androidx.fragment.app.FragmentManagerImpl.moveToState(FragmentManagerImpl.java:881)
at androidx.fragment.app.FragmentManagerImpl.moveFragmentToExpectedState(FragmentManagerImpl.java:1238)
at androidx.fragment.app.FragmentManagerImpl.moveToState(FragmentManagerImpl.java:1303)
at androidx.fragment.app.BackStackRecord.executeOps(BackStackRecord.java:439)
at androidx.fragment.app.FragmentManagerImpl.executeOps(FragmentManagerImpl.java:2079)
at androidx.fragment.app.FragmentManagerImpl.executeOpsTogether(FragmentManagerImpl.java:1869)
at androidx.fragment.app.FragmentManagerImpl.removeRedundantOperationsAndExecute(FragmentManagerImpl.java:1824)
at androidx.fragment.app.FragmentManagerImpl.execPendingActions(FragmentManagerImpl.java:1727)
at androidx.fragment.app.FragmentManagerImpl$2.run(FragmentManagerImpl.java:150)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:5417)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
Suppressed: java.lang.ClassNotFoundException: kotlin.jvm.internal.Intrinsics
at java.lang.Class.classForName(Native Method)
at java.lang.BootClassLoader.findClass(ClassLoader.java:781)
at java.lang.BootClassLoader.loadClass(ClassLoader.java:841)
at java.lang.ClassLoader.loadClass(ClassLoader.java:504)
Caused by: java.lang.NoClassDefFoundError: Class not found using the boot class loader; no stack trace available
Cannot change the On color by using the setOnColor method and for Off too.
when i specify the needed color in the method it only shows the almost grey color every time.
hint: i am using java
Can you help me? I won't kotlin
thank you.
I have implemented your library in the my project ,which have Java as preferred language and not kotlin.
@bitvale hi i got this error :
Could not find class 'com.bitvale.switcher.SwitcherX$SwitchOutline', referenced from method com.bitvale.switcher.SwitcherX.onSizeChanged
android sdk: 4.1.1
1.App is crashing because there is an exception being thrown by Renderscript library. This usually happens often in devices with low processing power. This exception is not a Java exception, cannot be caught.
log:E/RenderScript: rsAssert failed: ret == bytes || mShutdown, in frameworks/rs/rsFifoSocket.cpp at 83
I use the version 1.0.7
@bitvale thanks for this awesome Switcher but is there any possibility to make 3 Stage Switcher, it will be really helpful.
Thanks
I use the default code but can't see the shadows
When I load my view with some switches that are set to the 'off' position, they show the correct graphic, but in the color specified for the 'on' state.
Hello,
I find a problem.
click Checkable Parent View can not effective switch
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.