Benjamin Basmaci
Benjamin Basmaci

Reputation: 2557

Setting Android Studio preview background color

I'm creating a custom view that is supposed to go on top of my other views inside a normal layout/view. I want it to be a half-transparent white color, so that what's behind it is still visible and I want it to contain fully solid white borders and white font color. On a black/dark background, this is easily readable. However, in the preview, which has a white background, I'm not able to see anything.

Is there a way to change the background color of the preview, so that I can't test the look of my custom view?

If possible, I'd like to achieve that without adding unnecessary components that imitate a black background.

Upvotes: 4

Views: 2694

Answers (1)

Benjamin Basmaci
Benjamin Basmaci

Reputation: 2557

Ok, I just stumbled over it by accident:

Put xmlns:tools="http://schemas.android.com/tools in the root xml bracket of your layout.

After that, you can use tools:background=to set your background as you like it. This also works with other attributes.

Upvotes: 5

Related Questions