(droid分享)新浪微博开发系列【十二】之图片浏览
2012-09-26 20:50
337 查看
该篇是是图片浏览界面,好了,贴代码,在此说明一下,可能代码里调用一些方法在本篇中没有,但是全部在我的代码里,也不要索取图片,要看全部代码的请移步/article/8913211.html
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical">
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="41dp"
android:baselineAligned="false"
android:background="@drawable/bg_activitycontent">
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="2"
android:background="#BB768e95">
<Button
android:id="@+id/returnBtn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:text="@string/imageViewActivity_close"
android:textColor="#ffffff"
android:background="@drawable/bg_btn">
</Button>
</RelativeLayout>
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1"
android:background="#BB768e95" >
<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:text="@string/imageViewActivity_view"
android:textColor="#ffffff" >
</TextView>
<ProgressBar
android:id="@+id/loadImageprogressBar"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:visibility="invisible"
android:layout_toLeftOf="@+id/textView1" />
</RelativeLayout>
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="2"
android:background="#BB768e95">
<Button
android:id="@+id/saveBtn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:text="@string/imageViewActivity_save"
android:textColor="#ffffff"
android:background="@drawable/bg_btn">
</Button>
</RelativeLayout>
</LinearLayout>
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<com.czu.zoom.ImageZoomView
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/pic"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
</com.czu.zoom.ImageZoomView>
<ZoomControls
android:id="@+id/zoomCtrl"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_alignParentBottom="true">
</ZoomControls>
</RelativeLayout>
</LinearLayout>
![](http://img.my.csdn.net/uploads/201209/26/1348664060_9313.png)
package com.czu.sinaweibo;
import com.czu.downloadiconimage.AsyncImageLoader;
import com.czu.sinaweibo.R;
import com.czu.utils.Utils;
import com.czu.zoom.ImageZoomView;
import com.czu.zoom.SimpleZoomListener;
import com.czu.zoom.ZoomState;
import android.app.Activity;
import android.content.Intent;
import android.graphics.Bitmap;
import android.os.Bundle;
import android.view.View;
import android.view.Window;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.ZoomControls;
public class ImageViewActivity extends Activity {
private ImageZoomView imageZoomView = null;
private ZoomState zoomState = null;
private SimpleZoomListener simpleZoomListener = null;
/** 返回按钮 */
private Button returnButton = null;
/** 保存按钮 */
private Button saveButton = null;
/* 对话框 */
// private ProgressDialog progressDialog;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
/* 设置没有标题栏 */
this.requestWindowFeature(Window.FEATURE_NO_TITLE);
setContentView(R.layout.imageview_activity);
imageZoomView = (ImageZoomView) this.findViewById(R.id.pic);
Intent intent = this.getIntent();
Bundle bundle = intent.getExtras();
final String imageUrl = bundle.getString("ImageUrl");
AsyncImageLoader asyncImageLoader = new AsyncImageLoader(imageUrl,
imageZoomView, false);
asyncImageLoader.setImage();
zoomState = new ZoomState();
imageZoomView.setZoomState(zoomState);
simpleZoomListener = new SimpleZoomListener();
simpleZoomListener.setZoomState(zoomState);
imageZoomView.setOnTouchListener(simpleZoomListener);
resetZoomState();
ZoomControls zoomCtrl = (ZoomControls) findViewById(R.id.zoomCtrl);
zoomCtrl.setOnZoomInClickListener(new OnClickListener() {
@Override
public void onClick(View view) {
float z = zoomState.getZoom() + 0.25f;
zoomState.setZoom(z);
zoomState.notifyObservers();
}
});
zoomCtrl.setOnZoomOutClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
float z = zoomState.getZoom() - 0.25f;
zoomState.setZoom(z);
zoomState.notifyObservers();
}
});
/* 退出按钮 */
returnButton = (Button) this.findViewById(R.id.returnBtn);
returnButton.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
finish();
}
});
/** 保存按钮 */
saveButton = (Button) this.findViewById(R.id.saveBtn);
saveButton.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
Bitmap bitmap = imageZoomView.getBitmap();
Utils.SaveBitmap(ImageViewActivity.this,bitmap, imageUrl);
}
});
}
private void resetZoomState() {
zoomState.setPanX(0.5f);
zoomState.setPanY(0.5f);
zoomState.setZoom(1f);
zoomState.notifyObservers();
}
}
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical">
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="41dp"
android:baselineAligned="false"
android:background="@drawable/bg_activitycontent">
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="2"
android:background="#BB768e95">
<Button
android:id="@+id/returnBtn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:text="@string/imageViewActivity_close"
android:textColor="#ffffff"
android:background="@drawable/bg_btn">
</Button>
</RelativeLayout>
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1"
android:background="#BB768e95" >
<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:text="@string/imageViewActivity_view"
android:textColor="#ffffff" >
</TextView>
<ProgressBar
android:id="@+id/loadImageprogressBar"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:visibility="invisible"
android:layout_toLeftOf="@+id/textView1" />
</RelativeLayout>
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="2"
android:background="#BB768e95">
<Button
android:id="@+id/saveBtn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:text="@string/imageViewActivity_save"
android:textColor="#ffffff"
android:background="@drawable/bg_btn">
</Button>
</RelativeLayout>
</LinearLayout>
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<com.czu.zoom.ImageZoomView
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/pic"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
</com.czu.zoom.ImageZoomView>
<ZoomControls
android:id="@+id/zoomCtrl"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_alignParentBottom="true">
</ZoomControls>
</RelativeLayout>
</LinearLayout>
![](http://img.my.csdn.net/uploads/201209/26/1348664060_9313.png)
package com.czu.sinaweibo;
import com.czu.downloadiconimage.AsyncImageLoader;
import com.czu.sinaweibo.R;
import com.czu.utils.Utils;
import com.czu.zoom.ImageZoomView;
import com.czu.zoom.SimpleZoomListener;
import com.czu.zoom.ZoomState;
import android.app.Activity;
import android.content.Intent;
import android.graphics.Bitmap;
import android.os.Bundle;
import android.view.View;
import android.view.Window;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.ZoomControls;
public class ImageViewActivity extends Activity {
private ImageZoomView imageZoomView = null;
private ZoomState zoomState = null;
private SimpleZoomListener simpleZoomListener = null;
/** 返回按钮 */
private Button returnButton = null;
/** 保存按钮 */
private Button saveButton = null;
/* 对话框 */
// private ProgressDialog progressDialog;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
/* 设置没有标题栏 */
this.requestWindowFeature(Window.FEATURE_NO_TITLE);
setContentView(R.layout.imageview_activity);
imageZoomView = (ImageZoomView) this.findViewById(R.id.pic);
Intent intent = this.getIntent();
Bundle bundle = intent.getExtras();
final String imageUrl = bundle.getString("ImageUrl");
AsyncImageLoader asyncImageLoader = new AsyncImageLoader(imageUrl,
imageZoomView, false);
asyncImageLoader.setImage();
zoomState = new ZoomState();
imageZoomView.setZoomState(zoomState);
simpleZoomListener = new SimpleZoomListener();
simpleZoomListener.setZoomState(zoomState);
imageZoomView.setOnTouchListener(simpleZoomListener);
resetZoomState();
ZoomControls zoomCtrl = (ZoomControls) findViewById(R.id.zoomCtrl);
zoomCtrl.setOnZoomInClickListener(new OnClickListener() {
@Override
public void onClick(View view) {
float z = zoomState.getZoom() + 0.25f;
zoomState.setZoom(z);
zoomState.notifyObservers();
}
});
zoomCtrl.setOnZoomOutClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
float z = zoomState.getZoom() - 0.25f;
zoomState.setZoom(z);
zoomState.notifyObservers();
}
});
/* 退出按钮 */
returnButton = (Button) this.findViewById(R.id.returnBtn);
returnButton.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
finish();
}
});
/** 保存按钮 */
saveButton = (Button) this.findViewById(R.id.saveBtn);
saveButton.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
Bitmap bitmap = imageZoomView.getBitmap();
Utils.SaveBitmap(ImageViewActivity.this,bitmap, imageUrl);
}
});
}
private void resetZoomState() {
zoomState.setPanX(0.5f);
zoomState.setPanY(0.5f);
zoomState.setZoom(1f);
zoomState.notifyObservers();
}
}
相关文章推荐
- (droid分享)新浪微博开发系列【四】之登录界面
- (droid分享)新浪微博开发系列【三】之好友微博信息
- (droid分享)新浪微博开发系列【五】之显示主页
- (droid分享)新浪微博开发系列【六】之查看@我的微博和评论
- (droid分享)新浪微博开发系列【七】之查看我的好友和粉丝
- (droid分享)新浪微博开发系列【八】之热门微博
- (droid分享)新浪微博开发系列【九】之开发者信息显示和程序退出
- (droid分享)新浪微博开发系列【十】 之发送微博
- (droid分享)新浪微博开发系列【十一】之查看微博正文
- (droid分享)新浪微博开发系列【序论】
- (droid分享)新浪微博开发系列【十三】之微博的评论转发
- (droid分享)新浪微博开发系列【一】之欢迎首页
- (droid分享)新浪微博开发系列【二】之授权
- 转 【微信公众平台开发】调用微信内置图片浏览功能
- ios开发学习--列表(Table)效果源码分享--系列教程4
- iOS开发实现文字/图片的社交网络分享功能
- ios开发学习--图表(Chart)效果源码分享--系列教程
- Android官方开发文档Training系列课程中文版:分享简单数据之发送简单数据给其它APP
- android 使用Intent.ACTION_SEND分享图片和文字内容(新浪微博,短信等)
- J2EE Web服务开发系列之十二: 实现安全的AXIS Web服务,第1部分