0

我正在尝试在网络视图中加载 GIF 图像。它已完美加载,但我想将其放入屏幕中。我的意思是,我不想要滚动条(水平/垂直)。水平侧已安装,但垂直侧未安装。请任何人都可以帮助我。

活动

public class MainActivity extends Activity {

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    // Using Web view
    setContentView(R.layout.activity_main);

    WebView view = (WebView) findViewById(R.id.animationview);

    // Only hide the scrollbar, not disables the scrolling:
    view.setVerticalScrollBarEnabled(false);
    view.setHorizontalScrollBarEnabled(false);

    // Settings
    WebSettings settings = view.getSettings();
    settings.setLoadWithOverviewMode(true);
    settings.setUseWideViewPort(true);
    settings.setSupportMultipleWindows(true);

    // Load the GIF
    String strUrl = "file:///android_asset/lk_animation.gif";
    view.loadUrl(strUrl);
}

}

布局

< LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >


< WebView
    android:id="@+id/animationview"
    android:layout_width="match_parent"
    android:layout_height="match_parent" />

< / LinearLayout>

在此处输入图像描述

4

1 回答 1

1

set zoom false

webview.getSettings().setSupportZoom(false);
webview.getSettings().setBuiltInZoomControls(false);

use these method so that you can control the zoom so that image will fit into the screen.

webview.getSettings(). setDefaultZoom(WebSettings.ZoomDensity.CLOSE);

webview.getSettings().setDefaultZoom(WebSettings.ZoomDensity.FAR);

webview.getSettings().setDefaultZoom(WebSettings.ZoomDensity.MEDIUM);

于 2013-06-26T11:40:54.983 回答