如何在 Android 布局中使用环绕图像的文本创建浮动图像(右对齐)? [英] How can I have a floating image (right aligned) with text that wraps around the image in Android Layout?

查看:20
本文介绍了如何在 Android 布局中使用环绕图像的文本创建浮动图像(右对齐)?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这有点难以解释,但我想要完成的一个例子是这样的:

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 中生成布局并使用 web 视图,但是我需要能够在用户单击图像时执行操作.有人有什么想法吗?

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?

提前致谢,

优雅

推荐答案

首先你必须使用一些 html 代码,为你的 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");        
                }
            });
        }
    }

将界面和您的模板添加到您的网络视图中!

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

这篇关于如何在 Android 布局中使用环绕图像的文本创建浮动图像(右对齐)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆