[問題] imageview如何控制縮小?

看板AndroidDev作者 (WHY)時間9年前 (2016/04/28 12:18), 編輯推噓2(203)
留言5則, 3人參與, 最新討論串1/1
放置一張imageview,把它設置背景為全白的圖 請問要如何點擊它並把它等比例縮小呢? 例如:點一下 1 >0.8 >0.6>0.4>> 再回到1 Image11.setOnClickListener(this); public void onClick(View v) { Image11.buildDrawingCache(); Bitmap bmp = Image11.getDrawingCache(); int width = bmp.getWidth(); int height = bmp.getHeight(); Matrix matrix = new Matrix(); matrix.postScale(0.8f,0.8f); // 得到新的圖片 Bitmap newbm = Bitmap.createBitmap(bmp, 0, 0, width, height, matrix, true); //重新載入 imageView Image11.setImageBitmap(newbm); } 可以執行但是點擊image的時候不會變小Q.Q -- ※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 140.123.115.137 ※ 文章網址: https://www.ptt.cc/bbs/AndroidDev/M.1461817091.A.BC7.html

04/28 16:42, , 1F
我把你的code直接貼上去可以變阿
04/28 16:42, 1F

04/28 17:04, , 2F
! 真假 不過我的imageview是ㄧ張全白的,不是外部資源
04/28 17:04, 2F

04/28 17:36, , 3F
圖片我是直接在layout裡面定好
04/28 17:36, 3F

04/28 17:36, , 4F
點下去就變小拉
04/28 17:36, 4F

05/03 11:59, , 5F
你imageview的 長寬是用wrap content嗎?
05/03 11:59, 5F
文章代碼(AID): #1N8Oy3l7 (AndroidDev)