GithubHelp home page GithubHelp logo

savvyapps / togglebuttonlayout Goto Github PK

View Code? Open in Web Editor NEW
229.0 16.0 30.0 371 KB

Easy creation and management of toggle buttons on Android from the Material Design spec.

Home Page: https://savvyapps.com/blog/toggle-button-solution-android-app

License: Apache License 2.0

Kotlin 100.00%
android material-design kotlin togglebutton segmented-controls

togglebuttonlayout's People

Contributors

bmc08gt avatar jawnnypoo avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

togglebuttonlayout's Issues

Change textColor of selected menuItem

I have been trying all kind of approaches, no success. I just want to change the text color of selected toggle, can you guide me on how to achieve that? Thanks alot.

Cannot resolve artifact

I'm trying to use the Java version of the library. The docs say to use

implementation 'com.github.savvyapps:ToggleButtonLayout:latest.version.here'

Examining the source to find the version number, it looks like that should actually be

implementation 'com.savvyapps:togglebuttonlayout:1.0'

But gradle cannot resolve version 1.0 of either of those artifacts. What is the latest artifact, version, and repository information?

AAR library assembling

Hi! I'm appologise for of-topic question, but how do you managed assembling of your project to .aar, which contains all sources and documentation? I'm trying to do same thing with my project, but still have no result. Sources are avalible after adding .jar in addition to .aar.
Then i cloned your project and tryed to build .aar from it's sources and got same result. As a conclusion -- i`m doing something wrong...

task sourceJar(type: Jar) {
    classifier = 'sources'
    from android.sourceSets.main.java.srcDirs
}

task javadoc(type: Javadoc) {
    failOnError  false
    source = android.sourceSets.main.java.sourceFiles
    classpath += project.files(android.getBootClasspath().join(File.pathSeparator))
    classpath += configurations.compile
}
task addMySourcesToAar(type: Jar) {
    archiveName "ttsmanager.aar"
    destinationDir file("build")
    from zipTree("build/outputs/aar/ttsmanager-release.aar")
    from fileTree("build").include("libs/ttsmanager-sources.jar")
}
afterEvaluate { project ->
    project.tasks.preBuild.dependsOn sourceJar
    project.addMySourcesToAar.dependsOn build
}
artifacts {
    javadoc
    archives addMySourcesToAar.archivePath
}

Can you help me?

The ability to block selection of items

Hello,

I really like your library, it is useful and easy to use, but I miss one option.
Could you add the option to enable / disable the ability to select items by user? In some case I need blocking for while selected item, but in this version i can't do this.

id not showed up

the id not showed up, instead i've got some random numbers
any helps?

How to check, which button has been pressed?

I want to perform some action when one particular button is pressed. I'm using below code, but don't know what to do next.

    ToggleButtonLayout toggleButtonLayout = (ToggleButtonLayout) findViewById(R.id.toggleText);
    List<Toggle> selectedToggles = toggleButtonLayout.getSelectedToggles();

Graddle Sync failed

I know this is strange but when i include the library with ...
implementation 'com.github.savvyapps:ToggleButtonLayout:1.1.0'

my graddle sync fails.

Change selected color

How can I change programatically the selected color of the button? Thanks. Nice library.

Ability to get ToggleButtonLayout from Toggle

In Android from all listeners you can get a view which called this listener.
e.g. View.OnClickListener::onClick(View v) or CompoundButton.OnCheckedChangeListener::onCheckedChanged(CompoundButton buttonView, boolean isChecked).
It is convenient to use setTag()/getTag(Object) with view.

At the same time it is not possible to get ToggleButtonLayout object from listener to use setTag()/getTag(Object) with the current implementation.

There are two solutions:

  1. Change listener callback, e.g.
    onToggledListener: ((layout: ToggleButtonLayout, toggle: Toggle, selected: Boolean) -> Unit)?

  2. Allow to get ToggleButtonLayout from Toggle class.

setSelected() does not set the background color

Hi,

When invoking toggle.setSelected(true) the button gets selected but the button background doesn't show the selection.
2019-06-28_11:33:19-maindesk_001
I've already found a workaround for this issue: use toggle.setToggled(toggle.getId(), true);:
2019-06-28_11:33:27-maindesk_001

As a developer I'm expecting that setSelected(true) selects the toggle and marks the toggle background as selected. Could you fix this small bug?

With kind regards, Eimert

Making the layout take up the entire length of the screen

I have a Tabbed layout, and on the second tab the design people put another set of tabs, there's only 2 tabs, and I thought it was a bad idea to put tabs inside tabs. So I decided to make the second "tab" section 2 toggle buttons, since it just changes the values in a chart on the screen. The problem is, when using this layout the toggle buttons are very small and don't stretch to fill the screen. The way I am picturing it is, if you had a LinearLayout with layout_width set to match_parent, then weightSum set to 2, then each of the toggles would have layout_weight = 1 and they would stretch to fill in the width of the screen. The way I have it set right now in my layout is a LinearLayout with layout_width to "match_parent" and height to "wrap_content", then in my ToggleButtonLayout I have layout_width to "match_parent", but they are still just 2 small buttons on the left side of the screen, not stretching to fill the entire width. Is there a way to do this?

ToggleListener

I tried setting a listener so as to get Toggle events using

> toggleButtonLayout.setOnToggleSelectedListener(new ToggleButtonLayout.OnToggledListener() {
>             @Override
>             public void onToggled(Toggle toggle, boolean selected) {
> 
>             }
>         });

but this method doesn't resolve. Am using Java

Can you please show me this in Java ?

` toggleButtonLayout.onToggledListener = { _, toggle, selected ->
Snackbar.make(root, "Toggle ${toggle.id} selected state $selected", Snackbar.LENGTH_LONG)
.show()
}

    buttonSetSelectedColor.setOnClickListener {
        val primary = ContextCompat.getColor(this, R.color.colorPrimary)
        val accent = ContextCompat.getColor(this, R.color.colorAccent)
        if (toggleButtonLayoutText.selectedColor == accent) {
            toggleButtonLayoutText.selectedColor = primary
        } else {
            toggleButtonLayoutText.selectedColor = accent
        }
    }

    buttonSetDividerColor.setOnClickListener {
        val gray = Color.GRAY
        val red = Color.RED
        if (toggleButtonLayoutText.dividerColor == gray) {
            toggleButtonLayoutText.dividerColor = red
        } else {
            toggleButtonLayoutText.dividerColor = gray
        }
    }
}

}`

How to set one selected by default?

<com.savvyapps.togglebuttonlayout.ToggleButtonLayout
                android:id="@+id/toggle_button_layout"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_gravity="center_horizontal"
                app:allowDeselection="false"
                app:menu="@menu/toggles"
                app:selectedColor="@color/colorPrimary" />

And also want to set different color for two different selected toggle buttons.

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.