Organizational Research By

Surprising Reserch Topic

Question:WebView appears as plain white box after the second time it's been initialised

EDIT: tl;dr: WebView appears as white box, even though I appear to be setting it up correctly, and indeed it does work the first two times, but fails subsequently)

EDIT: Video showing the problem in action...

I have the following bit of code which inflates a view (Which contains a WebView) from the xml which defines it:

private void createCard(ViewGroup cvFrame, Card card) {

    //... setup vairables...


    try {
        View cv = LayoutInflater.from(getBaseContext()).inflate(R.layout.card_back_view,
                cvFrame, true);
        cv.setBackgroundDrawable(Drawable.createFromStream( + "_Card_back.png"), deckName));

        TextView suit = (TextView)cv.findViewWithTag("card_back_suit");
        //...setup text view for suit, this code works fine every time...

        WebView title = (WebView)cv.findViewWithTag("card_back_title");
        //This WebView doesn't appear to be the one which actually appears on screen (I can change settings till I'm blue in the face, with no effect)
        if (title != null) {
            title.loadData(titleText, "text/html", "UTF-8");
        } else {
            Log.e("CardView", "Error can't find title WebView");
    } catch (IOException e) {
        Log.e("CardView", "Error making cards: ", e);

When this method is called as part of the onCreate method in my Activity, the WebView contains the correct code, and is suitably transparent.

I have a gesture listener which replaces the contents of the ViewGroup with different content (It animates the top card off to the left, replaces the contents of the top card with card 2, puts the top card back, then replaces card 2 with card 3)

//Gesture listener event
ViewGroup cvFrame = (ViewGroup)findViewById(;

(onAnimationEnd code)

public void onAnimationEnd(Animation animation) {
    if (animation == slideLeft) {
        ViewGroup cvFrameOldFront = (ViewGroup)findViewById(;
        ViewGroup cvFrameNewFront = (ViewGroup)findViewById(;

        createCard(cvFrameOldFront, cards.get((cardLoc)%cards.size()));
        createCard(cvFrameNewFront, cards.get((cardLoc+1)%cards.size()));

        TranslateAnimation slideBack = new TranslateAnimation(0,0,0,0);


When the animation has happened and I replace the contents of the cards, the TextView suit is replaced fine and the code definitely passes through the code to replace the WebView contents, but for some reason I end up with a white rectangle the size and shape of the WebView, no content, no transparency.

If I change the WebView to a TextView, it's contents is replaced fine, so it's an issue that occurs only with the WebView control :S

Can anyone tell me why / suggest a fix?
asked Sep 13, 2013 in ANDROID by rajesh
edited Sep 12, 2013
0 votes

Related Hot Questions

Government Jobs Opening