Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make labels clickable #95

Closed
lynfogeek opened this issue Jan 6, 2015 · 13 comments · Fixed by #152
Closed

Make labels clickable #95

lynfogeek opened this issue Jan 6, 2015 · 13 comments · Fixed by #152

Comments

@lynfogeek
Copy link
Contributor

After showing my app to an handful of tester, I realized that most of them wanted to click on the label itself instead of the FloatingActionButton attached to it.

It would be nice to handle it with the FloatingActionButton click/touch listener.

@chalup
Copy link
Contributor

chalup commented Jan 6, 2015

Great idea, but it's not there simple to implement it in a correct way. You
also need to extend the click able area vertically to match the FAB height,
make sure the margin between FAB and label is clickable too, show feedback
on FAB when label is touched, etc.

Having said that, this improvement is quite high on my TODO list for this
project.
On Jan 6, 2015 11:17 AM, "Arnaud Camus" notifications@github.com wrote:

After showing my app to an handful of tester, I realized that most of them
wanted to click on the label itself instead of the FloatingActionButton
attached to it.

It would be nice to handle it with the FloatingActionButton click/touch
listener.


Reply to this email directly or view it on GitHub
#95
.

@LewisRhine
Copy link

Have the fab and the label view inside a layout set to wrap content. Then have on click calls go to the layout inside of the label?

@tamiof
Copy link

tamiof commented Jan 16, 2015

The workaround I used was go to setTitle method inside FloatingActionButton and add:

label.setOnClickListener(new OnClickListener()
{
@OverRide
public void onClick(View v)
{
FloatingActionButton.this.performClick();
}
});

Hopes this helps someone.

@AlexPari
Copy link

@tamiof your solution not worked for me, the performClick() returns to onClickListener of the FloatingActionMenu and not my FloatingActionButton...

wjwarren added a commit to wjwarren/android-floating-action-button that referenced this issue Jan 26, 2015
@wjwarren
Copy link

@tamiof I found that making the label clickable involved slightly more than your suggestion above. See my commit wjwarren@10cdcb6

@AndroidDeveloperLB
Copy link

I think it's better to use "setOnClickListener" on the label TextView and call "performClick" inside of it, on the "FloatingActionButton" itself. All of this, just when you create the labels TextViews.
It's much shorter this way.

Here's the relevant part (in "FloatingActionsMenu") :

private void createLabels() {
        ...
        label.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(final View v) {
                button.performClick();
            }
        });
        ...
    }
}

@lynfogeek
Copy link
Contributor Author

Maybe extend the touchable area of the FAB with a TouchDelegate would be more reliable than the performClick() solution.

If @chalup agrees with this solution I can make a PR next weekend

@AndroidDeveloperLB
Copy link

@lynfogeek Well, I offered to make it fully customizable, so that you could put whatever views you wish, and choose what to do on each clicking of which. This way, there won't be any weird workarounds for this case.

@lynfogeek
Copy link
Contributor Author

@AndroidDeveloperLB but you should not have a use case where clicking on the label does something else than clicking on the FAB.

Helping such behavior via the library is bad design IMO.

@AndroidDeveloperLB
Copy link

@lynfogeek I didn't say it should or should not. I want to give the control to whoever uses it. This way, the developer that puts the views can also decide how to put them, with which animations, angle, and so on... if he does something weird with the functionality, it's his fault. They don't even have to put labels. Any View can be put instead.

@danielesegato
Copy link

Which is the state of this issue?
Is someone working on it?

@AndroidDeveloperLB
Copy link

@danielesegato I don't know, but I've offered a very tiny change that you can do to make it work:
#95 (comment)

@devishankar
Copy link

By making the

private TextView getLabelView() {
        return (TextView) getTag(R.id.fab_label);
    } 

to public in

FloatingActionButton.java 

and using this with floating action button will solve this problem

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

9 participants