在全屏查看图像时,如何获得类似于您在 Facebook 应用程序中看到的结果?(见附图)
我利用 Chris Banes 的PhotoView Library实现多点触控缩放功能。
然而,我面临着让它发挥作用的困难。
我的 XML:
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/llMainContainer"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#000000"
android:orientation="vertical" >
<FrameLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_gravity="center" >
<ImageView
android:id="@+id/imgvwImage"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_gravity="center"
android:scaleType="fitXY" >
</ImageView>
<LinearLayout
android:id="@+id/linlaCaption"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_gravity="top|center"
android:layout_margin="4.0dip"
android:gravity="center"
android:orientation="horizontal" >
<TextView
android:id="@+id/txtPhotoCaption"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:text="CAPTION"
android:textColor="#fff1f1f1"
android:textSize="16.0sp"
android:textStyle="bold" >
</TextView>
</LinearLayout>
<LinearLayout
android:id="@+id/linlaLikesAndComments"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom|center"
android:gravity="center"
android:orientation="horizontal" >
<LinearLayout
android:id="@+id/linlaLikes"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1.0"
android:orientation="horizontal" >
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="2.0dip"
android:orientation="horizontal" >
<ImageButton
android:id="@+id/imgbtnLike"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@null"
android:gravity="center"
android:orientation="vertical"
android:src="@drawable/photo_viewer_like" >
</ImageButton>
</LinearLayout>
<LinearLayout
android:id="@+id/linlaShowLikes"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_gravity="right|center"
android:layout_margin="2.0dip"
android:layout_weight="1.0"
android:orientation="horizontal"
android:padding="5.0dip" >
<TextView
android:id="@+id/txtLikesTotal"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:gravity="left|center"
android:text="20 LIKES"
android:textColor="#fff1f1f1"
android:textSize="12.0sp"
android:textStyle="bold" >
</TextView>
</LinearLayout>
</LinearLayout>
<LinearLayout
android:id="@+id/linlaComments"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1.0"
android:orientation="horizontal" >
<LinearLayout
android:id="@+id/linlaShowComments"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_gravity="right|center"
android:layout_margin="2.0dip"
android:layout_weight="1.0"
android:orientation="horizontal"
android:padding="5.0dip" >
<TextView
android:id="@+id/txtCommentsTotal"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:gravity="right|center"
android:text="20 COMMENTS"
android:textColor="#fff1f1f1"
android:textSize="12.0sp"
android:textStyle="bold" >
</TextView>
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="2.0dip"
android:orientation="horizontal" >
<ImageButton
android:id="@+id/imgbtnComment"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@null"
android:gravity="center"
android:orientation="vertical"
android:src="@drawable/photo_viewer_comment" >
</ImageButton>
</LinearLayout>
</LinearLayout>
</LinearLayout>
</FrameLayout>
</FrameLayout>
还有我在点击时切换可见性的 JAVA 代码:
FrameLayout llMainContainer = (FrameLayout) findViewById(R.id.llMainContainer);
llMainContainer.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
if (linlaLikesAndComments.getVisibility() == View.GONE) {
linlaLikesAndComments.setVisibility(View.VISIBLE);
} else if (linlaLikesAndComments.getVisibility() == View.VISIBLE) {
linlaLikesAndComments.setVisibility(View.GONE);
}
}
});
我需要改变什么才能让它工作?