Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/218.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android Webview display.gif位于中间_Android_Webview_Gif - Fatal编程技术网

Android Webview display.gif位于中间

Android Webview display.gif位于中间,android,webview,gif,Android,Webview,Gif,我正在webview中显示.gif。它起作用了!。但它显示在左侧。我需要在中心展示 View footerView = ((LayoutInflater)context.getSystemService(Context.LAYOUT_INFLATER_SERVICE)).inflate(R.layout.listviewfooter, null, false); webviewLoadmore = (WebView) footerView.findViewById(R.id.web

我正在webview中显示.gif。它起作用了!。但它显示在左侧。我需要在中心展示

  View footerView =  ((LayoutInflater)context.getSystemService(Context.LAYOUT_INFLATER_SERVICE)).inflate(R.layout.listviewfooter, null, false);
    webviewLoadmore = (WebView) footerView.findViewById(R.id.webviewLoadmore);
    webviewLoadmore.loadUrl("file:///android_asset/load_icon.gif");
之后,我将它添加到Listview页脚中

clubListView.addFooterView(webviewLoadmore);
我的xml布局

<WebView xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/webviewLoadmore"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_gravity="center"
    android:scrollbars="none" 
     android:scaleType="centerInside"
    >
</WebView>

试试这个:

WebView web = (WebView) findViewById(R.id.gif_image);
web.getSettings().setDefaultZoom(ZoomDensity.FAR);
或:

public void loadImage(){
位图BitmapOfMyImage=BitmapFactory.decodeResource(Environment.getExternalStorageDirectory())
.getAbsolutePath()+“yourFolder/myImageName.jpg”);
mWebView.loadDataWithBaseURL(“文件://“+Environment.getExternalStorgeDirectory()
.getAbsolutePath()
+“您的文件夹/,”
“,”文本/html“,”utf-8“,”);
//这将在屏幕中央加载图像
}

将Gif文件放在HTML文件中,对其进行编码,就像图像将显示在网页中心一样(显然使用css)。然后在WebView中加载html页面


有关更多详细信息,请检查

尝试android:gravity=“center”这不是webviewohh的属性抱歉,我的意思是在布局中将html放置在资产中,并使用loadUrl()加载它,就像您对gif所做的那样。它显示的是“hello word”。但不是gif图像。伙计,你只是复制粘贴的代码。更改html正文以显示图像。它一定是这样的,它没有显示图像。只显示一个图标而不是gif图像
public void loadImage(){
   Bitmap BitmapOfMyImage=BitmapFactory.decodeResource(Environment.getExternalStorageDirectory()
                                       .getAbsolutePath()+"yourFolder/myImageName.jpg");  

   mWebView.loadDataWithBaseURL("file:///"+Environment.getExternalStorgeDirectory()  
                               .getAbsolutePath()
                                +"yourFolder/","<html><center>
                                <img src=\"myImageName.jpg\" vspace="
                                +(currentHeight/2-(BitmapOfMyImage.getHeight()/2))+">
                                 </html>","text/html","utf-8","");
 //This loads the image at the center of thee screen                    
}