Ripple effect over colored ImageButton? - java

I have a dynamically created ImageButton. Here is my code -
ImageButton bar = new ImageButton(this);
... //some code
parentView.addView(bar);
Ripple effect appears when I click the ImageButton. But when I add the following line -
bar.setBackgroundColor(Color.RED);
The ripple effect doesn't appear anymore. Is there any way to make the ripple effect appear on a colored ImageButton?
By ripple effect, I mean this effect - click here (I'm sorry but I cannot add the image here as gifs are not supported)

Maybe try something like this:
bar.getBackground().setColorFilter(Color.RED, Mode.MULTIPLY);
You need to check what MODE would be apopriate, because i don't have big experience with this.

Related

How to fit the clickable area on a button

I need to make a GUI in javafx where the buttons shape is custom made with a stylesheet
I use -fx-shape: "SVG Path"; to make the shape of my button
And sceneBuilder to make the GUI and if you need to know i use netbeans as my ide
Now when I make the custom form i want to only be able to click on that and not around it where the button is invisible
I have tried to use padding but i dont think that is the way
So if you look at this picture which is in scenebuilder
https://imgur.com/a/11dRR2G
you can see the white form which is what i want to be clickable
not the whole rectangle that you can see is lighted up
Ok this is not the direct answer to your question but a workaround on your Problem.
In you case i would just take the image which looks like that button and add a setOnMouseClickedEventListener
like this-
ImageView img = new ImageView("https://imgur.com/a/11dRR2G");
img.setPickOnBounds(false); // disables click on transparent areas
img.setOnMouseClicked((MouseEvent e) -> {
//do something
});

How to change image during a scroll on Android

I'm a beginner on Android development and am trying to build my first app. I have an activity with a round target image and I'd like to make this image vanish at scroll down and display an another image instead that would snap to the toolBar (see the example images below).
I've researched this, but have only found information about using effects in apps where the image just vanishes. Perhaps, the Coordinator Layout could be useful here?
Initial state of my layout
After scrolling up, I want to change to a state like this.
To summarize, I have to :
- make my round Image go behind de ToolBar
- make the rectangular ImageView2 appear below the ToolBar
- Align my buttons (I guess it's about speed ? The one in the middle should go faster or something like that).
- Display new infos coming from below
You should surely use CoordinatorLayout. The point is that you should add custom behavior to your ImageView.
You can see an example here:
https://www.bignerdranch.com/blog/customizing-coordinatorlayouts-behavior/

Android "Frozen" Button appearance

I have a certain problem: I have created a quick clicker game, where two players try to click quicker than the other one. A special button freezes the opponent's main button. The frozen button currently only becomes unclickable and its text color becomes gray.
To add some "style", I would like to literally freeze it. I don't really know how it would look like, but I thought about a light blue background, and some light blue spikes around it or something like that. I haven't found any style that would do that, and any image to replace the button with, because "Frozen" finds other images ;)...
I'm not a designer so telling me that tools that can design buttons exist won't help me.
Also, just an image won't probably be enough, because the button can be frozen at any moment, with any text and any text color.
Thanks for your help.
You can create button look (drawable) and set it programmatically.
Example
myButton = (Button) findViewById(R.id.myButton);
myButton.setBackgroundResource(R.drawable.frozenDrawable);
To do some simple looks for buttons i recommend you
Android Button Maker
.
Example 2
For more advanced look you can create some png
ImageButton myButton = (ImageButton)findViewById(R.id.myButton);
myButton.setImageResource(R.drawable.frozenResource);
I don't have code, but here is what I would experiment with, if I had to create create the appearance of a frozen button while keeping its text and general appearance:
To ice the button:
Using Google Image search, find the image of a slab of ice
Create an imageView with that "slab of ice" image as the src, and make it about the same size as your button (or slightly larger if you want the ice to leak out)
Place that icy imageView directly over your button.
Make that imageView slightly transparent by setting the "alpha" property to 0.5 (or whatever looks good, keeping in mind that 0 = invisible and 1=fully visible).
To unfreeze the button:
Make the imageView invisible.
Re-enable the button

How to make the Navigation Drawer Shadow lighter

Im pertaining to the one when the drawer is open, the shadow is showing on the right side, this seems dark and the requirement wants to have it a bit lighter.
I've tried changing setDrawerShadow but doesn't seem to change at all.
im using the Gravity.START
Use DrawerLayout.setScrimColor.

ActionBarSherlock custom NavigationDrawer icon

I'm implementing NavigationDrawer with ActionBarSherlock and now I'm trying to implement custom icon for opening and closing the drawer. I already set my own icon (white) but I'm not able to get rid of that grey default icon.
in onCreateOptionsMenu I'm doing this:
getSupportActionBar().setDisplayShowTitleEnabled(false); // does not display activity title
getSupportActionBar().setBackgroundDrawable(
getResources().getDrawable(R.drawable.actionbar_background)); // blue background
getSupportActionBar().setIcon(R.drawable.side_menu_button); // white icon
The picture shows difference when navigation drawer is closed (first) and open (second picture).
Is there any way to do it programmatically? Or is there even some way to do it? I hope it is.
Thank you.
EDIT: This is what I'm trying to achieve:
What you are currently doing is setting the icon on the ActionBar, which is different from setting the icon of the ActionBarDrawerToggle, which is what you want to be dealing with. If you look at the documentation (http://developer.android.com/reference/android/support/v4/app/ActionBarDrawerToggle.html) and find the constructor, you'll see there's a place to specify a custom Drawable to be used by the toggle.

Categories

Resources