开发者

Android WebView setEmbeddedTitleBar problem

开发者 https://www.devze.com 2023-03-27 02:46 出处:网络
I\'m trying to add a titlebar on WebView so the titlebar to be scrolled with WebView. I used this code.

I'm trying to add a titlebar on WebView so the titlebar to be scrolled with WebView.

I used this code.

private void setEmbeddedTitleBar(WebView web, View titlebar) {
    try {
        Method m = WebView.class.getMethod("setEmbeddedTitleBar", new Class[] { View.class });
        m.invoke(web, titlebar);
    }
    catch(Exception e) {
        Log.d("TEST", "Err: "+e.toString());
    }
}

I called the method above and the titlebar seemed to be added to the corresponding webview but the titlebar doesn't show up and just white space( height of titlebar ) is upside the webview content.

My classes are 'CTitleBar' , 'CTab' and 'CWebView'. CTab includes CWebView as a member( fo开发者_如何学编程r one WebView per a Tab ). And CTitleBar includes CTabs array as a member.

Prorgam operates like below.

By clicking 'add tab' button, user add a tab. Then CTab is created with CWebView in it. The tab is added to CTab array in CTitleBar. ( ** IMPORTANT ** ) And the CTitleBar view is added as tab.webView's titlebar. This means.. the titlebar is referenced by it's member's member( titlebar.tab.webview ).

It seems to be a cross reference I think.

I don't know if this causes the 'white space' problem. Or am I just using the method invocation with worng way?

How can I solve it? Somebody help me.

0

精彩评论

暂无评论...
验证码 换一张
取 消