Can i center external content in a WebView? - android

I am loading an image from external url directly in a WebView. So now i want to center that image. I can't edit the file to add css or js. Is it possible and when it is, how?

Related

Use drawable inside HTML Page

I am developing an application in which I am loading an HTML page inside Webview. I am to use an image in that HTML which is inside my drawable. How would I give path to that image inside HTML.

Open image inside WebView in new Activity on clicking

Is there a simple way to open an image in new Activity on clicking it inside the webview?
Or It would be great if I can get the full url of the image on clicking it inside the webview.
Not possible, because how should you get the image url ?
it is difficult to get return values from webview events outside the context of webview.
if you have the direct URL of image then you can easily rendered it on UI but without direct URL you can't render an image.
Create an HTML file
<html>
<img src="abc.jpeg" width="100px" >
</html>
put it in an assests folder of your android application and load the html in your webview
webview.loadUrl("file:///android_asset/abc.html");
You can store the image in the assets folder along with the html
page, and specify the image name as the value of src in img tag
in html code,
or you can give the public URL of the image and the image will be
renderd on its own

Displaying a image captured using Camera inside an html image tag placed within a WebView - Xamarin.Android

I'm looking for a way on to display the image captured using Camera2 API in Xamarin.Android inside an HTML tag which is placed within a WebView.
Though it was possible to obtain the File URi where the image is located, setting it into the image tag which I have tried, isn't working. I also want to know whether this kind of thing can be done in Native Android.
You can encode the content of the image in base64, and than set it in the src of your img tag like this:
<img src="data:image/jpg;base64,VeryLongBase64EncodedImageData"/>

How to drag an image in html file displayed using webview in android?

I have an Android WebView loaded with a html file(actually stored in some folder under sdcard) that is having one/two/three image(s). Is it possible to drag-drop any one of those images?
If its possible, below are my doubts
When i drag an image from (x1,y1) place and drop it in another (x2,y2)place, How can i change the original source file code as the image place is changed ?
When i open the same html file in next time (using default html viewer or my app), i should see the image in (x2, y2) place. Isn't it possible ?
I tried this drag ImageView inside a WebView. But it is just adding an imageview to webview. (So, when i run the same app next time, i don't see the image in the place where i dropped it in first run.) But i need to drag an image presented in source html file. So After every drag-drop, Do i need to render the webview content and create a new html file to see the image in dropped location?
Is it possible to read the android-webview content? (like we read the web page content in java).
Can anyone clear my doubts and suggest me a better way if iam going/thinking wrong?
I don't think it possible (without using some not trivial tricks) to implement the drag and drop as you wish. for the other point's you raised - if the file is on your sd - why not just parse the html file and get the pictures positions and source link and use it to implement the drag and drop on your own? after all- the html file is an xml file which contains attributes which defines positions/links/images/text

Radio button styles not showing in webview

I designed some radio buttons with images using css, because I want to make the radio button look bigger.
Now, when I load it in browsers it works fine, same in mobile browsers. But when I try to load it in webview the radio button is not visible. Is there anyway to enable css?
You don't need to enable css. You just link to it from you html file like you normally would
Put the html, css and image resource files in the assets folder of your project and load the html using "file:///android_asset/yourwebpage.html" as a Url.
if your css file is separate then you need to provide complete relative path in html page you include the html page like file:/// something like that.
mobile brower can take relative path by itself like say your accessing from wampserver but if you are putting all in webview and loading then it dont take relative path by itself. By the way where you are putting all this files in assests or sdcard ?

Categories

Resources