Opacity Levels in Android Studio - button

I’ve searched and I haven’t found a way to get a certain level of transparency in a colored button while the text of the button is 100% visible.
There has been options to get certain levels of transparency in a button, but the text also becomes transparent and that’s not what I want.
Any pointers?

Do do it in code, you can use:
yourButtonName.getBackground().setAlpha(int alpha)
where alpha is an int between 0 and 255.
Do do it in XML, you would add something like this to your button attributes:
android:background="#8000FF00"
This would yield a 50% opaque green color.
To better understand how we arrive at the code "#8000FF00" , look here.
:)

Related

How to "wash out" colors with CSS filters?

I am trying to use CSS filters to create a "disabled" look for components I am working on. I am trying to make it so that everything is "washed out" a bit. I can create this effect by using opacity(0.75) for components which are on white background: then black becomes gray and all strong colors become a bit more white. But the issue is if the component is not on white background, then opacity does not work as I would like. So how could I use CSS filters to create this "wash out" look? Like to multiply with white color a bit all colors.
I tried contrast but it looks like everything goes to gray, not white (so black stays black much longer than with opacity, while other colors are already washed out).
Using a combination of Contrast and Brightness filters might give you what you need:
filter: contrast(30%) brightness(150%);

Transparency on only one side

I was trying to add some transparency to a text and oddly enough I noticed it was only transparent on one side while being opaque on the other.
The expected behavior was transparent on both sides. Any idea why this happens?
Thank you.
https://aframe.io/docs/0.8.0/components/material.html#transparency-issues
With opacity, A-Frame sets three.js renderer to sortObjects: false. Transparency ordering is based on when objects are added / defined in the scene. Shuffle the order of the text in like the HTML or when they are injected and it should work.

JavaFX: Textarea background color error

Here's the problem:
I tired to make the textarea from javafx have a black color, so i tried to add the parameter:
"-fx-background-color" with the value "black"
It did change something: Around the text area a black border appeared. I tried to change the background size with:
"-fx-background-insets" with the value "100" (for testing purposes, i know there are up to 4 values)
But nothing visual happend.
However, if i set the value to "-100", the screen 100 pixels outwards of the textarea is painted black. So, in theory, reversed parameter delivers the reversed result of what i want.
Therefore i ask: Why is it not working? I looked up other solutions, and they do it with the "-fx-background-color" parameter, so what a i missing here?
Use the following in an external css file:
.text-area .content {
-fx-background-color: black;
}
don't forget to include this css file, either through FXML or through code. You can use this tutorial.
I just found the solution to change the color of the background of TextArea in JavaFX. Write this in your controller class:
textarea.setStyle("-fx-control-inner-background: black;");
I was deep searching on the stackoverflow and eventually found it. The link is given below: Textarea javaFx Color
Happy coding!

How do I enable a transparent QGraphicsPixmapItem to receive mouse click events?

I have a QGraphicPixmapItem as a game piece in my program. It has three main states: red, blue, and blank. The problem is, when blank, the piece is not clickable.
When red, I change the pixmap of the piece to a red, vaguely checker-like png. When blue, I do the same. When blank, I use a completely transparent png.
This blank, completely transparent pixmap is why (as far as I can tell) events are passing right through it. When I redid it by changing the pixmap to the red checker, then manually resetting the opacity to zero, the same thing happened. When I left even 0.01 opacity in the newly-red piece, however, the event triggered.
Clearly, being transparent means events pass through you for a QGraphicPixmapItem. How do I change that and make it receive events? Or is my conclusion wrong?
What you're seeing is the correct behaviour as described by the shapeMode.
You can change it to use QGraphicsPixmapItem::BoundingRectShape which, as the documentation states:-
...does not take into account any transparent areas on the pixmap.
If you still need to obey transparency, then you could inherit from QGraphicsPixmap item and reimplement the shape function to set the opacity to 0.1, call the base class shape function and set it back afterwards.

Turning white background transparent, but keeping dropshadow?

In an image like this, I want to remove the white background but keep the grayness of the dropshadow. Reomving mapping the actual image is not a problem!
This is what I enden up doing instead after lots and lots of trial and error.
Duplicate the layer with the paper in it.
Invert the new layer.
Painting the "paper-part" clear white
Using the inverted layer as a mask on the first layer.
Worked like a charm, perfect masking!
Two options that I can think of:
a) Edit the image in photoshop and make the background transparent.
b) Overlay the "white" background w/ a div overlay that has a white background.
a is the preferred option. Post a comment on this reply if you need me to do this for you.
did you make that image? Why not make the image on a transparent background?
But if you didn't make the image, I don't know if you really can unless you plan on putting it on another whitish background because the dropshadow itself is going to be a little transparent and whatever is underneath it will show through.

Resources