Reputation: 10392
I am trying load the GIF image in the web view. It's loaded perfectly but i want to fit it within screen. I mean, i don't want the scrollbars(Horizontal/vertical). Horizontal sideit is fitted but in vertical side it is not fitted. Please can anyone help me.
Activity
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);
}
}
Layout
< 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>
Upvotes: 0
Views: 584
Reputation:
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);
Upvotes: 0