I tried  "xWalkView.setBackgroundColor(Color.BLUE);" with latest crosswalk,  it 
works.
BTW, we didn't use android::background in the layout file to set this color. I 
just raise this as a feature: 
https://crosswalk-project.org/jira/browse/XWALK-4628.

Here are some hints about  background color:
1), Some page has its own background.
If  open www.intel.com<http://www.intel.com>, you will see the color set by 
setBackgroundColor a fraction of second.  But soon this will be covered by the 
whole page.
If open http://www.baidu.com/, I can see the BLUE even when page loaded.

2),  white screen flick
If add  "XWalkPreferences.setValue(XWalkPreferences.ANIMATABLE_XWALK_VIEW, 
true);"   there will be a white screen flick when you switch from background to 
front.
If add  "XWalkPreferences.setValue(XWalkPreferences.ANIMATABLE_XWALK_VIEW, 
false);" (this is the default setting for latest crosswalk)  , no white screen 
observed.


Regards,
Xing

From: Alexander Biemann [mailto:[email protected]]
Sent: Thursday, July 16, 2015 11:20 AM
To: Xu, Xing; [email protected]
Cc: George Tonev
Subject: RE: [Crosswalk-help] How to set the background color ?

I am using xwalk_core_library:14.43.343.17
________________________________
From: [email protected]<mailto:[email protected]>
To: [email protected]<mailto:[email protected]>; 
[email protected]<mailto:[email protected]>
CC: [email protected]<mailto:[email protected]>
Subject: RE: [Crosswalk-help] How to set the background color ?
Date: Thu, 16 Jul 2015 00:28:43 +0000
Hi,  which crosswalk are you using?
As I know,  this is a fixed issue. For canary version, it is fixed since 
2015.feb,9.  For crosswalk 12, since 2015.feb,23.
You can check it here:  https://crosswalk-project.org/jira/browse/XWALK-1910.


Regards,
Xing

From: Crosswalk-help 
[mailto:[email protected]] On Behalf Of 
Alexander Biemann
Sent: Thursday, July 16, 2015 7:39 AM
To: 
[email protected]<mailto:[email protected]>
Cc: George Tonev
Subject: [Crosswalk-help] How to set the background color ?

Dear Crosswalk team,

I would like to customize the background color of the XWalkView, however, this 
seems impossible / non-functional via the setBackgroundColor() API or via XML
Please see below for my implementation details...

As you can see, I would like to have the background set to Blue, however, it 
always shows as white. Screenshot is attached.

What do I need to do to be able to set the background color of the XWalkView ?
My Goal is to absolutely avoid the initial white screen, even for a split 
second. Once the HTML loads the background color no longer matters.



Build.gradle

apply plugin: 'com.android.application'

android {
    compileSdkVersion 22
    buildToolsVersion "22.0.1"

    defaultConfig {
        applicationId "com.zumobi.xwalkbackgroundtest"
        minSdkVersion 16
        targetSdkVersion 22
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 
'proguard-rules.pro'
        }
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile 'com.android.support:appcompat-v7:22.2.0'
    compile 'org.xwalk:xwalk_core_library:14.43.343.17'
}

Layout XML

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android";
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:paddingTop="@dimen/activity_vertical_margin"
    android:paddingBottom="@dimen/activity_vertical_margin"
    android:background="#FF0000">

    <org.xwalk.core.XWalkView
        android:id="@+id/xwalkview"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:background="#0000FF"/>

</RelativeLayout>

Java

public class MainActivity extends ActionBarActivity {

    private XWalkView xWalkWebView;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        xWalkWebView=(XWalkView)findViewById(R.id.xwalkview);

        // test
        xWalkWebView.setBackgroundColor(Color.BLUE);

        // test
        xWalkWebView.post(new Runnable() {
            @Override
            public void run() {
                xWalkWebView.setBackgroundColor(Color.BLUE);
            }
        });
    }

    @Override
    protected void onPause() {
        super.onPause();
        if (xWalkWebView != null) {
            xWalkWebView.pauseTimers();
            xWalkWebView.onHide();
        }
    }

    @Override
    protected void onResume() {
        super.onResume();
        if (xWalkWebView != null) {
            xWalkWebView.resumeTimers();
            xWalkWebView.onShow();
        }
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
        if (xWalkWebView != null) {
            xWalkWebView.onDestroy();
        }
    }
}




Alexander Biemann / Sr. Android Software Engineer
[email protected]<mailto:[email protected]>
1525 4th Ave. Ste. 800, Seattle, WA 98101
Zumobi.com

_______________________________________________
Crosswalk-help mailing list
[email protected]
https://lists.crosswalk-project.org/mailman/listinfo/crosswalk-help

Reply via email to