如何将android Image URI用作HTML作为背景

时间:2016-05-21 20:19:35

标签: android html

How may I assign image to Background in HTML using android URI ?

代码示例:

// Getting images From Camera or Gallery
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
        if (requestCode == CropImage.PICK_IMAGE_CHOOSER_REQUEST_CODE && resultCode == Activity.RESULT_OK) {
            Uri imageUri = CropImage.getPickImageResultUri(this, data);
UserAppSettings.setSplashScreen(imageUri); //Model
}
}

在Web背景中设置CSS和图像

//Create String to Change Image Dynamically
public static String htmlDocument = "<html><head><style>.splash {
    background: url('"+UserAppSettings.getSplashScreen()+"');       
}</style><body><div class="splash"></div></body></head></html>";

将修改过的字符串放入JAVA代码:

webView.loadDataWithBaseURL("file:///android_asset/", UserWebPage.htmlDocument,
     "text/html", "UTF-8", ""); 

but this is not working on my side and I am getting Uri very fine
content://com.android.providers.media.documents/document/image%3A52530

0 个答案:

没有答案