我有这个活动显示图像,我期待它默认显示在中心,但它是什么使图像显示在屏幕的左上角和时间我按下时间如果去中心的图像。图像默认显示没有得到集中
变焦XML
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_gravity="center" >
<ImageView
android:id="@+id/iv_photo"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_gravity="center" />
<TextView
android:id="@+id/tv_current_matrix"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom|center_horizontal"
android:gravity="center"
android:background="#60000000"
android:textColor="@android:color/white" />
</FrameLayout>
活动
public void onCreate(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
Window window = getWindow();
window.setGravity(Gravity.CENTER);
imageLoader = ImageLoader.getInstance();
imageLoader.init(ImageLoaderConfiguration.createDefault(getBaseContext()));
Intent intent = getIntent();
easyPuzzle = intent.getExtras().getString("imagePath");
setContentView(R.layout.zoom_image);
mImageView = (ImageView) findViewById(R.id.iv_photo);
mCurrMatrixTv = (TextView) findViewById(R.id.tv_current_matrix);
//aq.id(R.id.iv_photo).image(easyPuzzle.toString(), memCache, fileCache);
Log.d("#Zoom Picture CLass: Image Path ", ""+ easyPuzzle.toString());
//
//mImageView.setImageResource(R.drawable.beverages);
//new DisplayImage(mImageView)
//.execute(easyPuzzle);
DisplayImageOptions options = new DisplayImageOptions.Builder()
//Because you reuse view for different
//images you can see a previous image in the view while new image is loading. .resetViewBeforeLoading(true
.showImageForEmptyUri(R.drawable.content_picture)
.showImageOnFail(R.drawable.content_picture)
.cacheOnDisc(true)
.bitmapConfig(Bitmap.Config.RGB_565)
.build();
if(imageLoader!=null){
imageLoader.displayImage(easyPuzzle.toString(), mImageView, options);
}
// The MAGIC happens here!
mAttacher = new PhotoViewAttacher(mImageView);
// Lets attach some listeners, not required though!
mAttacher.setOnMatrixChangeListener(new MatrixChangeListener());
mAttacher.update();
}
更新
对不起,我忘了提及,该图像能够放大的。因此,有一个潜在可能 图像将从中心延伸到全屏。
我使用通用-图片下载器来显示图像,并且如果使用一个绘制图像被居中向右走,但如果切换到通用-图像 - 装载机中,首先显示的图像在屏幕的最左边然后如果我触摸它,然后转移到中心。
也删除不必要的'机器人:layout_gravity = “中心” 从'父'FrameLayout'。 –
@RaviBhatt,请看我更新的q。 – rahstame