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

리사이즈한 이미지뷰 오버레이가 안보입니다..

0 추천

이미지뷰 오버레이를 띄어서 오버레이가 터치를 익식하면 액티비티를 여는 서비스 클레스를 삽질을 떴습니다.

여기까지는 잘 되었고. 여기에다가 설정값에 따라 이미지뷰 오버레이를 리사이징 하는것을 넣엇는대..

이상하게 오버레이가 안보이고. 오버레이가 터치 인식은 하는대.. 잘 하지를 않내요..
이걸 어캐해야하는지 잘 몰라서;; 질문 올립니다. 이미지뷰 오버레이 다시 보이게 하고 터치인식도 제대로
되도록 하게하려면 어캐해야하는지 코드좀 봐주시고 답변 달아주셨음 합니다.
 
 
이게 설정값에 따라 이미지뷰 오버레이가 리사이징 되도록 삽질해서 작성한건대,
터치이벤트도 잘 안되고. 이미지뷰 오버레이가 아예 안보이내요 ㅜ
 

public class TouchDetectService extends Service {
	private ImageView mTouchDetector;							
	private WindowManager.LayoutParams mParams;		
	private WindowManager mWindowManager;	
	private static final int MY_NOTIFICATION_ID=1;
	private NotificationManager notificationManager;
	private Notification myNotification;
	final static String ACTION = "NotifyServiceAction";
	final static String STOP_SERVICE = "";
	final static int RQS_STOP_SERVICE = 1;
	

	private OnTouchListener mViewTouchListener = new OnTouchListener() {
	    @Override public boolean onTouch(View v, MotionEvent event) {
	        switch(event.getAction()) {
	            case MotionEvent.ACTION_MOVE:
	            	boolean vibeon = getSharedPreferences(getPackageName() + "_preferences", Context.MODE_PRIVATE).getBoolean("vibe_toggle", true);
	            	if(vibeon){ 
	            	Vibrator vibe = (Vibrator) getSystemService(Context.VIBRATOR_SERVICE);
	            	vibe.vibrate(10);} 
	            	else{}
	            	Intent lsp = new Intent(getBaseContext(), SidePanel.class);
	            	lsp.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
	            	getApplication().startActivity(lsp);
	                break;
	        }
	        return true;
	    }
	};
	
    @Override
    public IBinder onBind(Intent arg0) { return null; }
    @Override
    public void onCreate() {
        super.onCreate();
        boolean rightpanel = getSharedPreferences(getPackageName() + "_preferences", Context.MODE_PRIVATE).getBoolean("panelpos_right", true);
        boolean notificationison = getSharedPreferences(getPackageName() + "_preferences", Context.MODE_PRIVATE).getBoolean("noti_toggle", true);
        Log.i("BOOTSVC", "Service started at the BOOT_COMPLETED.");
        	SharedPreferences myPreference = PreferenceManager.getDefaultSharedPreferences(this);
      	  String dw = myPreference.getString("detector_width", "");
      	  String dh = myPreference.getString("detector_height", "");
        mTouchDetector = new ImageView(this);                                        
        mTouchDetector.setImageResource(R.drawable.detector);
        mTouchDetector.setOnTouchListener(mViewTouchListener);         
        WindowManager.LayoutParams params = new WindowManager.LayoutParams();
        
        if(dw.equals("025")){
            params.height = (int) (mTouchDetector.getDrawable().getIntrinsicWidth()*0.25);
        }
        else if(dw.equals("050")){
            params.height = (int) (mTouchDetector.getDrawable().getIntrinsicWidth()*0.5);
        }
        else if(dw.equals("075")){
            params.height = (int) (mTouchDetector.getDrawable().getIntrinsicWidth()*0.75);
        }
        else if(dw.equals("100")){
            params.height = mTouchDetector.getDrawable().getIntrinsicWidth();
        }
        else if(dw.equals("200")){
            params.height = mTouchDetector.getDrawable().getIntrinsicWidth()*2;
        }
        else if(dw.equals("300")){
        	params.height = mTouchDetector.getDrawable().getIntrinsicWidth()*3;
        }
        else if(dw.equals("400")){
        	params.height = mTouchDetector.getDrawable().getIntrinsicWidth()*4;
        }
        
        if (dh.equals("025")){
            params.width = (int) (mTouchDetector.getDrawable().getIntrinsicHeight()*0.25);
            }
        else if (dh.equals("050")){
            params.width = (int) (mTouchDetector.getDrawable().getIntrinsicHeight()*0.5);
            }
        else if (dh.equals("075")){
            params.width = (int) (mTouchDetector.getDrawable().getIntrinsicHeight()*0.75);
            }
        else if (dh.equals("100")){
            params.width = mTouchDetector.getDrawable().getIntrinsicHeight();
            }
        else if (dh.equals("200")){
            params.width = mTouchDetector.getDrawable().getIntrinsicHeight()*2;
            }
        else if (dh.equals("300")){
            params.width = mTouchDetector.getDrawable().getIntrinsicHeight()*3;
            }
        else if (dh.equals("400")){
            params.width = mTouchDetector.getDrawable().getIntrinsicHeight()*4;
            }
        params.flags = WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE;
        params.format = PixelFormat.TRANSLUCENT;
        params.type = WindowManager.LayoutParams.TYPE_PHONE;

        if(rightpanel)
        {
        params.gravity = Gravity.RIGHT & Gravity.CENTER;   
        }
        else
        {
        	params.gravity = Gravity.LEFT & Gravity.CENTER;   
        }
        mWindowManager = (WindowManager) getSystemService(WINDOW_SERVICE);
        mWindowManager.addView(mTouchDetector, params);
        if(notificationison){

        notificationManager =
         (NotificationManager)getSystemService(Context.NOTIFICATION_SERVICE);
        myNotification = new Notification(R.drawable.ic_stat_sidepanel,
        		getText(R.string.service_notification),
          System.currentTimeMillis());
        Context context = getApplicationContext();
        CharSequence notificationTitle = getText(R.string.service_running);
        CharSequence notificationText = getText(R.string.service_running_desc);
        Intent myIntent = new Intent(getBaseContext(), Settings.class);;
        PendingIntent pendingIntent
          = PendingIntent.getActivity(getBaseContext(),
            0, myIntent,
            Intent.FLAG_ACTIVITY_NEW_TASK);
        myNotification.defaults |= Notification.DEFAULT_SOUND;
        myNotification.flags |= Notification.FLAG_AUTO_CANCEL;
        myNotification.flags = Notification.FLAG_ONGOING_EVENT;
        myNotification.setLatestEventInfo(context,
           notificationTitle,
           notificationText,
           pendingIntent);
        notificationManager.notify(MY_NOTIFICATION_ID, myNotification);
        }
        else
        {
        }
        }
	@Override
    public void onDestroy() {
        if(mWindowManager != null) {      
            if(mTouchDetector != null) mWindowManager.removeView(mTouchDetector);
        }
        super.onDestroy();
        notificationManager.cancel(MY_NOTIFICATION_ID);
    }
}

 

sukso (120 포인트) 님이 2013년 3월 9일 질문

답변 달기

· 글에 소스 코드 보기 좋게 넣는 법
· 질문에 대해 추가적인 질문이나 의견이 있으면 답변이 아니라 댓글로 달아주시기 바랍니다.
표시할 이름 (옵션):
개인정보: 당신의 이메일은 이 알림을 보내는데만 사용됩니다.
스팸 차단 검사:
스팸 검사를 다시 받지 않으려면 로그인하거나 혹은 가입 하세요.
...