1
코드를 작동하지 않습니다 :onTouchListener는
public class ImageActivity extends FragmentActivity {
ImageView mClickedImage;
PhotoViewAttacher mPhotoViewAttacher;
TextView mRotate_imageActivity;
private int BASEINT_ImageActivity;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_image);
Intent intent = getIntent();
final String string = (String) intent.getSerializableExtra("Clicked Image");
mClickedImage = (ImageView) findViewById(R.id.iv_clicked_image);
mRotate_imageActivity = (TextView) findViewById(R.id.tv_rotate_imageActivity);
mPhotoViewAttacher = new PhotoViewAttacher(mClickedImage);
Glide.with(getApplicationContext())
.load(string)
.fitCenter()
.into(mClickedImage);
mRotate_imageActivity.setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View view, MotionEvent motionEvent) {
Glide.with(getApplicationContext())
.load(string)
.diskCacheStrategy(DiskCacheStrategy.ALL)
.transform(new RotateHelper(getApplicationContext(), 90f))
.into(mClickedImage);
return true;
}
});
}
}
XML 코드 : 위에서 볼 수 있듯이
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/activity_image"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.keepair.www.pinair.ImageActivity">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/rl_rotate_text">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/tv_rotate_imageActivity"
android:text="@string/rotate"/>
</RelativeLayout>
<ImageView
android:layout_centerInParent="true"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:id="@+id/iv_clicked_image"/>
</RelativeLayout>
, 내 XML 코드는 텍스트 뷰는 이미지 뷰에 있다고 말한다. 그들은 겹쳐진다.
하지만 photoviewattacher 때문에 onTouchListener가 TextView 용으로 작성된 것, mRotate_imageActivity가 작동하지 않는다고 생각합니다.
질문 : 어떻게하면 onTouchListener를 사용할 수 있습니까?
어디로 추가 할 수 있습니까? 제발 알려주시겠습니까? – touchingtwist
@ touchingtwist 내가 대답을 업데이트했습니다 –
Ahmed Hegazy – touchingtwist