好吧,这就是我的问题。我有一个包含大量图片的应用程序,我希望能够捏缩放这些图片,但由于 ImageViewer 本身不支持此功能,我想我应该使用 Webviewer,但事情就是这样。我所有的图片都保存到我的“图片”int 中,它是我想要加载到网络查看器中的图片函数。不是特定的 \drawable\bla.jpg 到处搜索但没有找到任何有关它的信息。我将附上一些代码以供参考。
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Intent intent=getIntent();
int picture=intent.getIntExtra("picture", 22);
setContentView(R.layout.pictureframe);
ImageView image = (ImageView) findViewById(R.id.pansarvagn);
image.setBackgroundResource(picture);
这是我想要的地方
Webview image = (WebView) findViewById(R.id.pansarvagn);
image.(setdata bla bla)
图片函数。
public void displayPicture(int pictureresource){
Intent intent = new Intent();
intent.putExtra("picture", pictureresource);
intent.setClass(getApplicationContext(), Picture.class);
startActivity(intent);
,这是调用的
Button tank = (Button) findViewById(R.id.tank);
tank.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
displayPicture(R.drawable.tank);
}
为了进一步详细说明,我想将图像放入我可以放大的网络视图中。因此,网络视图中的某种图像视图可以用我的图片填充网络视图。然后我希望能够放大它。
Allright so here's my problem. I have an app which contains alot of pictures and i wanted to be able to pinchzoom these, but since the ImageViewer doesnt support this natively I thought I'd use the Webviewer instead, but heres the thing. all my pictures are saved into my "picture" int and its the picture function i want to load into the webviewer. not a specific \drawable\bla.jpg Searched all around but didnt find anything about it. I'll attach some code for reference.
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Intent intent=getIntent();
int picture=intent.getIntExtra("picture", 22);
setContentView(R.layout.pictureframe);
ImageView image = (ImageView) findViewById(R.id.pansarvagn);
image.setBackgroundResource(picture);
and its here where i want smth like
Webview image = (WebView) findViewById(R.id.pansarvagn);
image.(setdata bla bla)
and this is the picture function
public void displayPicture(int pictureresource){
Intent intent = new Intent();
intent.putExtra("picture", pictureresource);
intent.setClass(getApplicationContext(), Picture.class);
startActivity(intent);
called by
Button tank = (Button) findViewById(R.id.tank);
tank.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
displayPicture(R.drawable.tank);
}
To further elaborate i want to put an image into a webview which i will be able to zoom into. so some sort of imageview inside the webview to fill up the webview with my picture. and then I want to be able to zoom in on it.
发布评论
评论(1)
您需要创建自己的
ContentProvider
并覆盖它的openFile(..)
方法。然后您可以将其提供给 WebView:这是一个示例: http://www.techjini.com/blog/2009/01/10/android-tip-1-contentprovider-accessing-local-file-system-from-webview-showing-image-in- webview-using-content/
注意:使用这种方法,您需要将图像保存在某个地方。你将无法凭记忆为他们服务。
You need to create you own
ContentProvider
and override it'sopeenFile(..)
method. Then you can feed it to WebView:Here is an example: http://www.techjini.com/blog/2009/01/10/android-tip-1-contentprovider-accessing-local-file-system-from-webview-showing-image-in-webview-using-content/
Note: with this approach you will need to save your images somewhere. You will not be able to serve them from memory.