마스터Q&A 안드로이드는 안드로이드 개발자들의 질문과 답변을 위한 지식 커뮤니티 사이트입니다. 안드로이드펍에서 운영하고 있습니다. [사용법, 운영진]

이미지뷰 확대.축소.드래그에 관해 질문드립니다,

0 추천

어플만들기를 하고있는데

https://www.youtube.com/watch?v=N3d3FxEkT6k 여기 동영상을 보고 만들기 시작했습니다.

근데 아무리 해도 이미지뷰가 드래그,축소,확대가 안되요 ㅜㅜ

제가 하고싶은건 item1버튼을 통해  이미지를 드래그 확대 축소를 하고싶어요

제발알려주세요

<pre>public class MainActivity extends AppCompatActivity {

    PhotoViewAttacher mattacher;

    final String TAG = getClass().getSimpleName();
    final String LOG = "_test";

    String mCurrentPhotoPath;
    private Uri photoUri;

    BottomNavigationView mNavigation;

    private SectionsPagerAdapter mSectionsPagerAdapter;

    private ViewPager mViewPager;

    private static final int REQ_CAMERA_CAPTURE = 1;
    private static final int REQ_PICK_FROM_ALBUM = 2;
    private static final int REQ_CAMERA_CROP = 3;

    public static ImageView imageView;
    private ImageView mImg;

    FloatingActionButton fab;
    FloatingActionButton fab1;
    FloatingActionButton fab2;
    CoordinatorLayout rootLayout;

    //레이아웃연결선언
    Button friendbtn, officebtn, dailybtn, couplebtn;
    ImageButton buybtn, item1, item2, item3, beforebtn, afterbtn;
    LinearLayout codi;
    ViewFlipper viewFlipper;
     private boolean FAB_Status = false;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
                WindowManager.LayoutParams.FLAG_FULLSCREEN);

                setContentView(R.layout.activity_main);
 
        mSectionsPagerAdapter = new SectionsPagerAdapter(getSupportFragmentManager());

        mViewPager = (ViewPager) findViewById(R.id.container);
        mViewPager.setAdapter(mSectionsPagerAdapter);
               mNavigation = (BottomNavigationView) findViewById(R.id.navigation);
        mNavigation.setOnNavigationItemSelectedListener(mOnNavigationItemSelectedListener);
        fab_set();
    }
    //여남친룩 버튼 연결하기
    public void onFriend(View v){
        friendbtn = (Button)findViewById(R.id.friendbtn);
        codi = (LinearLayout)findViewById(R.id.codi);
        friendbtn.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                codi.setVisibility(View.VISIBLE);
                viewFlipper = (ViewFlipper)findViewById(R.id.viewflipper);
                beforebtn = (ImageButton) findViewById(R.id.beforebtn);
                afterbtn = (ImageButton)findViewById(R.id.afterbtn);
                item1 = (ImageButton)findViewById(R.id.item1);
                item2 = (ImageButton)findViewById(R.id.item2);
                item3 = (ImageButton)findViewById(R.id.item3);
                item1.setBackgroundResource(R.drawable.item1);
                item2.setBackgroundResource(R.drawable.item2);
                item3.setBackgroundResource(R.drawable.item3);
                beforebtn.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        item1.setBackgroundResource(R.drawable.item1);
                        item2.setBackgroundResource(R.drawable.item2);
                        item3.setBackgroundResource(R.drawable.item3);
                    }
                });
                afterbtn.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        item1.setBackgroundResource(R.drawable.mitem1);
                        item2.setBackgroundResource(R.drawable.mitem2);
                        item3.setBackgroundResource(R.drawable.mitem3);
                    }
                });
            }
        });
    }
    //item1 버튼연결
    public void onItem1(View v){
        new Thread(){
            public void run(){
                runOnUiThread(new Runnable() {
                    @Override
                    public void run() {
                        item1 = (ImageButton)findViewById(R.id.item1);
                        mImg = (ImageView) findViewById(R.id.mImg);
                        mImg.setVisibility(View.VISIBLE);
                    }
                });
            }
        }.start();
        new Thread(){
            public void run(){
                runOnUiThread(new Runnable() {
                    @Override
                    public void run() {
                        mImg = (ImageView) findViewById(R.id.mImg);
                        mattacher = new PhotoViewAttacher(mImg);
                    }
                });
            }
        }.start();
        }
hyuiiop (160 포인트) 님이 2017년 10월 9일 질문

1개의 답변

0 추천
혹시몰라서 레이아웃소스도 올립니다
<LinearLayout      android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="#ffffff"
    android:orientation="vertical">

    <LinearLayout
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:orientation="horizontal">
        <Button
            android:id="@+id/friendbtn"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:onClick="onFriend"
            android:text="/남친룩"
            android:textColor="#000000" />

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="horizontal"
        android:visibility="gone">

        <LinearLayout
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:orientation="horizontal">

            <ImageButton
                android:id="@+id/beforebtn"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_weight="1"
                android:background="@drawable/beforeicon" />
        </LinearLayout>
        <ViewFlipper
            android:id="@+id/viewflipper"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content">
            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:orientation="horizontal">
                <ImageButton
                    android:id="@+id/item1"
                    android:onClick="onItem1"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:background="@drawable/item1" />
            </LinearLayout>
        </ViewFlipper>
        <LinearLayout
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:orientation="horizontal">
            <ImageButton
                android:id="@+id/afterbtn"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:background="@drawable/aftericon" />
        </LinearLayout>
    </LinearLayout>
    <FrameLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content">
        <ImageView
            android:id="@+id/imageView1"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
android:background="@drawable/fittingimg"/>

        <LinearLayout
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:id="@+id/toplinear">
        <ImageView
            android:id="@+id/mImg"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_below="@+id/linearLayout"
            android:background="@drawable/item1"
            android:visibility="gone" />
        </LinearLayout>
    </FrameLayout>
</LinearLayout>
hyuiiop (160 포인트) 님이 2017년 10월 9일 답변
...