怎样才可以有浮动图像(右对齐)文本,它包装在Android的布局图像周围?图像、才可以、装在、布局

2023-09-13 01:22:09 作者:帅有什么用,能当饭吃么

这是一种很难解释,但什么,我想完成的一个例子是这样的:

It's kind of hard to explain, but an example of what I'm wanting to accomplish is like this:

Here is some text | image |
that is printed   |       |
out in a view and ---------
it is wrapped around an
image that is floating and
right aligned.

我想过生成HTML中的布局和使用网络的看法,但我需要能够当用户点击了图片上执行的操作。有没有人有什么想法?

I thought about generating the layout in html and using a web view, but I need to be able to perform an action when the user clicks on the image. Does anyone have any ideas?

在此先感谢,

groomsy

推荐答案

首先,你必须有一些HTML code的工作,从而为您的WebView模板...

first you must work with some html code, creating a template for your webview...

     String TemplateHTML =

"<div id=\"content\">[Replace with your CONTENT]</div><div id=\"myimage\"><a id=\"mylink\" onClick=\"window.demo.clickOnAndroid()\"><img id=\"myImage\" src=\"[Replace your image URL path]\" /></a></div>"

创建JSInterface与您的模板交互

Create JSInterface to interact with your template

    final class myJavaScriptInterface {
        myJavaScriptInterface () {
        }
        public void clickOnAndroid() {
            mHandler.post(new Runnable() {
                public void run() {
Log.i("myJavaScriptInterface " ,"Jorge is Clickin the image!!! =D");        
                }
            });
        }
    }

添加接口和你的模板到您的WebView!

add the interface and your Template to your webview!

MyWebView.addJavascriptInterface(new myJavaScriptInterface (), "demo");     
    MyWebView.loadDataWithBaseURL(null, TemplateHTML, "text/html", "utf-8", null);
    WebSettings webSettings = WebContent.getSettings();
    webSettings.setSavePassword(false);
    webSettings.setSaveFormData(false);
    webSettings.setJavaScriptEnabled(true);
    webSettings.setSupportZoom(true);