android打开webview白一下,android – WebView在第二次初始化后显示为纯白框

编辑:tl;博士:WebView显示为白色框,即使我似乎正确设置它,实际上它确实在前两次工作,但随后失败)

编辑:Video showing the problem in action…

我有以下一些代码从xml中扩展了一个视图(包含一个WebView),它定义了它:

private void createCard(ViewGroup cvFrame, Card card) {

//... setup vairables...

cvFrame.clearDisappearingChildren();

cvFrame.clearAnimation();

try {

View cv = LayoutInflater.from(getBaseContext()).inflate(R.layout.card_back_view,

cvFrame, true);

cv.setBackgroundDrawable(Drawable.createFromStream(mngr.open(deckName + "_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.setBackgroundColor(0x00000000);

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);

}

}

当我的Activity中的onCreate方法调用此方法时,WebView包含正确的代码,并且适当透明.

我有一个手势监听器,它用不同的内容替换ViewGroup的内容(它将顶部卡片设置为左侧,用卡片2替换顶部卡片的内容,将顶部卡片放回,然后用卡片3替换卡片2) )

//Gesture listener event

ViewGroup cvFrame = (ViewGroup)findViewById(R.id.firstCard);

cardLoc++

cvFrame.startAnimation(slideLeft);

(onAnimationEnd代码)

public void onAnimationEnd(Animation animation) {

if (animation == slideLeft) {

ViewGroup cvFrameOldFront = (ViewGroup)findViewById(R.id.firstCard);

ViewGroup cvFrameNewFront = (ViewGroup)findViewById(R.id.secondCard);

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

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

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

slideBack.setDuration(1);

slideBack.setFillAfter(true);

cvFrameOldFront.startAnimation(slideBack);

}

}

当动画发生并且我替换了卡片的内容时,TextView套装被替换得很好,代码肯定会通过代码来替换WebView内容,但由于某种原因,我最终得到一个白色矩形的大小和形状WebView,没有内容,没有透明度.

如果我将WebView更改为TextView,它的内容被替换为正常,因此只有WebView控件才会出现问题:S

谁能告诉我为什么/建议修复?

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值