Alan Harper
Alan Harper

Reputation: 803

Activity background in Android

I have an activity with background colour black.

It has edittext and right after soft keyboard goes away, for a moment I see white area under keyboard; and then view gets resized.

This looks like blinking.

Question is, is it possible to set some kind of default background color for entire app? (Assuming that my activity already has background attribute)

windowSoftInputMode is also not an option

Upvotes: 0

Views: 1722

Answers (1)

Oam
Oam

Reputation: 922

If you want to specify the background to your whole application, you may edit the app theme or add custom theme to your application manifest. But this will be overridden when background is specified in the xml layout.

Add custom theme in style.xml

<style name="MyTheme" parent="android:Theme">            
        <item name="android:background">@android:color/black</item>
    </style>

Specify the theme in manifest as

<application           
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/MyTheme" >

Adding theme for each activity in manifest

<activity
            android:name=".Login"
            android:configChanges="orientation"
            android:theme="@style/MyTheme>
        </activity>

You can also modify the existing theme in style.xml which is already defined in manifest by changing the background as desired

<item name="android:background">@android:color/black</item>

Upvotes: 1

Related Questions