Sebastian Engel
Sebastian Engel

Reputation: 3695

Meaning / usage of "android:colorBackground"

Can anyone please explain, what the meaning and usage of Android's "android:colorBackground" attribute is? And how is it used by Android itself? I read the doc but that doesn't make it clearer:

Color that matches (as closely as possible) the window background.

Upvotes: 4

Views: 2953

Answers (3)

marmor
marmor

Reputation: 28179

This is used in Android N and above as the background color for the copy/paste popup when long pressing an EditText

Upvotes: 0

Ped7g
Ped7g

Reputation: 16596

I think android will use this color as "fake" background in case the proper background resource is not yet ready for rendering (like loading the image in asynchronous process), or in cases where fake solid color background can be enough (maybe some thumb preview, etc).

Unfortunately I have no exact idea where/how/when it is used.

Upvotes: 0

JBS
JBS

Reputation: 686

I'm just getting started with Android Studio myself, but this is what I've figured out about using colorBackground. In your res/values/styles.xml you'll use it in this way

<resources>

    <color name="colour_name">#bada55</color>
    <color name="white">#ffffff</color>

    <style name="AppThemeA" parent="android:Theme.AppCompat.Light">
    <!-- Customize your theme here. -->
        <item name="android:colorBackground">@color/colour_name</item>
        <item name="android:textColor">@color/white</item>

    </style>
</resources>

Hope this answers your question.

Upvotes: 1

Related Questions