5

我已经轻松地放大了布局,但我也想滚动缩放的布局。我已经能够缩放,但我还想在缩放后滚动,以便我可以编辑Widgets

有没有办法做到这一点?

    import android.app.TabActivity;
    import android.content.Intent;
    import android.os.Bundle;
    import android.view.View;
    import android.view.View.OnClickListener;
    import android.widget.RelativeLayout;
    import android.widget.TabHost;
    import android.widget.TabHost.TabSpec;

    public class MainActivity extends TabActivity {
        View mainview;
        int zoomed = 0;
        TabHost th;
        TabSpec one;
        TabSpec two;
        TabSpec three;
        TabSpec four;

        @Override
        protected void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.activity_main);
            mainview = (RelativeLayout) findViewById(R.id.relLayout1);

            th = getTabHost();
            th.setup();
            one = th.newTabSpec("One");
            two = th.newTabSpec("Two");
            three = th.newTabSpec("Three");
            four = th.newTabSpec("Four");

            one.setIndicator("One");
            two.setIndicator("Two");
            three.setIndicator("Three");
            four.setIndicator("Four");

            Intent a = new Intent(this, first.class);
            Intent b = new Intent(this, second.class);
            Intent c = new Intent(this, third.class);
            Intent d = new Intent(this, fourth.class);

            one.setContent(a);
            two.setContent(b);
            three.setContent(c);
            four.setContent(d);

            th.addTab(one);
            th.addTab(two);
            th.addTab(three);
            th.addTab(four);

            mainview.setOnClickListener(new OnClickListener() {

                @Override
                public void onClick(View arg0) {

                    mainview.setPivotX(100);
                    mainview.setPivotY(100);
                    if (zoomed == 0) {                  
                        mainview.setScaleX(2f);
                        mainview.setScaleY(2f);
                        zoomed=1;
                    }
                    else{
                        mainview.setScaleX(1f);
                        mainview.setScaleY(1f);
                        zoomed=0;
                    }
                }
            });
        }
    }

这是我的布局:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/relLayout1"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".MainActivity" >

    <TabHost
        android:id="@android:id/tabhost"
        android:layout_width="match_parent"
        android:layout_height="220dp"
        android:layout_alignParentBottom="true"
        android:layout_alignParentLeft="true"
        android:layout_alignParentTop="true" >

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:orientation="vertical" >

            <TabWidget
                android:id="@android:id/tabs"
                android:layout_width="match_parent"
                android:layout_height="wrap_content" >
            </TabWidget>

            <FrameLayout
                android:id="@android:id/tabcontent"
                android:layout_width="match_parent"
                android:layout_height="match_parent" >

                <LinearLayout
                    android:id="@+id/tab1"
                    android:layout_width="match_parent"
                    android:layout_height="match_parent" >
                </LinearLayout>

                <LinearLayout
                    android:id="@+id/tab2"
                    android:layout_width="match_parent"
                    android:layout_height="match_parent" >
                </LinearLayout>

                <LinearLayout
                    android:id="@+id/tab3"
                    android:layout_width="match_parent"
                    android:layout_height="match_parent" >
                </LinearLayout>

                <LinearLayout
                    android:id="@+id/tab4"
                    android:layout_width="match_parent"
                    android:layout_height="match_parent" >
                </LinearLayout>
            </FrameLayout>
        </LinearLayout>
    </TabHost>

</RelativeLayout>
4

0 回答 0