为GridView添加缩放缩放

时间:2014-11-07 06:50:35

标签: android gridview pinchzoom

我需要为gridview添加一个缩放缩放。我没有找到任何关于在gridview中添加缩放缩放的示例。到目前为止,我的布局看起来像这样。我需要为该gridview添加一个缩放缩放。

activity_main.xml:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/relativeLayout"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical" >

    <LinearLayout
        android:id="@+id/linearlayoutControll"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:layout_centerHorizontal="true"
        android:background="@color/light_grey"
        android:gravity="center"
        android:orientation="horizontal" >

        <ImageButton
            android:id="@+id/imagebuttonLast"
            android:layout_width="50dp"
            android:layout_height="50dp"
            android:background="@drawable/ic_action_previous"
            android:scaleType="fitXY" />

        <ImageButton
            android:id="@+id/imagebuttonPause"
            android:layout_width="50dp"
            android:layout_height="50dp"
            android:background="@drawable/ic_action_pause"
            android:scaleType="fitXY" />
 </LinearLayout>

    <GridView
        android:id="@+id/gridViewTable"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_above="@+id/linearlayoutControll"
        android:layout_alignParentTop="true"
        android:layout_margin="15dp"
        android:listSelector="#00000000"
        android:numColumns="2"
        android:rotationY="180" >
    </GridView>

FragmentPage.java:

import android.widget.LinearLayout; import android.widget.LinearLayout.LayoutParams;

@Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
            Bundle savedInstanceState) {

         rootView = inflater.inflate(R.layout.activity_main, container, false);
      rootView.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT));
       zoomView = new ZoomView(getActivity());
       zoomView.addView(rootView);

        return rootView;

    }

如果我得到任何示例代码或教程或任何建议,它将对我有所帮助。谢谢。

1 个答案:

答案 0 :(得分:2)

添加

ZoomView zoomView;
rootView.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT));
zoomView = new ZoomView(getActivity());
zoomView.addView(rootView);

和更改

 return rootView; 

 return zoomView;

并将zoomview jar放入您的项目