Привет Я использую следующий макет для отображения Webview содержание ...центр изображения в WebView
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:id="@+id/ads_screen"
android:background="@drawable/splash_gradient">
<FrameLayout
android:id = "@+id/ads_frame"
android:layout_weight="8"
android:layout_width="fill_parent"
android:layout_height="0dp"
android:layout_gravity="center"
android:scaleType="centerInside"
android:background="@drawable/splash_gradient">
<WebView
android:id="@+id/ads_image"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginLeft = "10dp"
android:layout_marginRight = "10dp"
android:scaleType="center"
/>
</FrameLayout>
<ProgressBar
android:id="@+id/ads_progress_bar"
android:layout_width="18dp"
android:layout_height="18dp"
android:layout_gravity="center"/>
<TextView
android:layout_width="fill_parent"
android:layout_weight="3"
android:layout_height="0dp"
android:gravity="center"
android:id="@+id/ads_text"
android:text="@string/connecting"
android:textColor="@color/white"/>
</LinearLayout>
В коде я использую следующее:
View adsFragment = inflater.inflate(R.layout.ads_fragment, container, false);
i_image = (WebView) adsFragment.findViewById(R.id.ads_image);
View view = adsFragment.findViewById(R.id.ads_screen);
final View f = (FrameLayout)adsFragment.findViewById(R.id.ads_frame);
i_image.getSettings().setJavaScriptEnabled(false);
i_image.getSettings().setPluginState(android.webkit.WebSettings.PluginState.OFF);
i_image.getSettings().setBuiltInZoomControls(false);
i_image.getSettings().setSupportZoom(false);
i_image.setBackgroundColor(0);
i_image.setWebViewClient(new WebViewClient() {
public void onReceivedError(WebView view, int errorCode, String description, String failingUrl) {
if (DebugConstants.ENABLE_LOGS)
{
Log.info("onReceivedError() URL: " + failingUrl + " ERROR: " + description);
}
f.setVisibility(View.GONE);
}
});
i_image.loadUrl("file:///android_res/drawable/splashscreen_default.png");
То, что я хочу, чтобы центр это изображение в веб-просмотре. Может кто-нибудь, пожалуйста, взглянуть и что-нибудь предложить?