android - set WebView in center horizontal -
i placed gif image in webview , want put webview in horizontal center. tried code android:layout_centerhorizontal="true" relative layout does'nt work
<relativelayout android:layout_width="match_parent" android:layout_height="match_parent" android:gravity="center_horizontal" > <webview android:id="@+id/imgchargement" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_centerhorizontal="true" /> </relativelayout>
but not work
can 1 me please !
you said loading image know, start simple. here way load text , center horizontally. in code after inflate layout.
// variable webview, imgchargement.loaddata("<html><body align='center'>you scored <b>192</b> points.</body></html>", "text/html", null);
in otherwords, using align='center'
center contents of webview
, not webview
. now, center thewebview
in layout, if contents aren't centered within webview
, won't appearance of centering looking for..
furthermore, can't stick image in webview
, have have webview
"wrap_content" (like when laying out android views). "wrap_content' ignored , webview
width ends defaulting parent's width. (you can use "wrap_content", doesn't size view html content, think expecting do).
so, case, replace text inside of body tags of example html image, , see if helps solve problem.
i using following xml , not using centering attributes in parent.
<webview android:id="@+id/imgchargement" android:layout_width="match_parent" android:layout_height="wrap_content"/>
Comments
Post a Comment