IngressAchievementsã£ã¦ããViewä½ã£ã
IngressAchievements
amyu/IngressAchievements · GitHub
ã³ã¬ä½ã£ãã¯ãããã§ããã©ãã©ã¤ãã©ãªåããã®ã¨ãä½ã£ã¦ãæä¸ã«ããã©ããããªã£ã¦ãã¦ã
ãã®ãã¡æã«ãªã£ããã¾ãé²åããã¾ãã
å è§å½¢ã®é¨åã®TouchEvent
Regionã«å
è§å½¢ã®Pathãã»ãããã¦ï½¤Viewã®onTouchEventã§Regionã®ç¯å²å
ã®æã«Listenerãå©ãã¨ãã£ãæã。
ã§ï½¤ä¸ã®ç»åã®Viewæ§æã¯ï½¤AchievementViewã¨ããViewæ¡å¼µããViewãIngressListViewã§è¡¨ç¤ºãã¦ãæããªãã§ã。
ãã®æã«ï½¤Viewã®éãªã£ãé¨åã®TouchEventã被ããã、onInterceptTouchEventã常ã«falseãè¿ãã¦Viewã«TouchEventãããããã«ãããã§ããã¼ï½¡
ViewGroup#addViewã®æã®å¦ç
ViewGroupã®ã³ã¼ãèªãã ã
public void addView(View child, int index, LayoutParams params){ //... }
ã®å¦çã§addViewãçµãã£ã¦ãã。
ãªã®ã§ï½¤è²ã
ã¨å¤ããããã ã£ãããããªæãããª?
@Override public void addView(View child, int index, LayoutParams params) { if (!(child instanceof AchievementView)) { throw new IllegalArgumentException("AchievementView以å¤ãæ¥ã¦ããã¼ã¼ã¼ã¼ã¼"); } ((AchievementView) (child)).setOnClickListener(mOnClickListener); super.addView(child, index, params); }
ããã ãæ¸ãã¦ããã°ï½¤addView(View child)ã§ãåæã«ããæãã«ãªãã¾ãã。
AttributeSetãå§ãã¦ã¡ããã¨ä½¿ã£ã
ã©ã¤ãã©ãªåããæã«ä½¿ãå´ã¨ãã¡ã¤ã«åã被ããªãããã«ããªãã¨ãããªãã£ã½ã。
ä»ã¯
Viewå_attrs.xml
ã«ãã¦ããã©ã¡ããã¨ããå½åè¦åããããã ã£ããç¥ããããªï½¡
å è§å½¢ã®æç»
60度ãã¤ã®å¤åã®ãã、sinã¨cosã®å¤ãå®æ°ã§æã£ã¦ããã°ããã£ãã¨å¾æ。
ã®ã¡ã®ã¡ã«æ±ç¨æ§ãæããããã£ãã¨è¨ã訳ã...
ããããã®çµ¶å¦ãªè¨ç®
IngressListViewã§ä¸¦ã¹ãã¨ããAchievementViewãªãµã¤ãºããã¨ãã«ãªãã ããã çµæ§è¨ç®ãã¦ãã§ããã¼ï½¡
ã»ãã¨çç³»ã§ããã£ã。
ã§ãã¦ãªãæ
AchievementViewã«ç»åãã»ãããããã¨ãåºæ¥ããã§ããã©ï½¤ãããã°ã®å¡ã§ï½¡
onSizeChangedã§ã»ããããç»åã®Bitmapã®ãªãµã¤ãºå¦çãèµ°ããã§ããã©ï½¤IngressListViewã§ããããAchievementViewãå
¥ã£ã¦ãæ、ãã¹ã¦ã®AchievementViewã§ãªãµã¤ãºã§å¦çãèµ°ãOOMã§è½ã¡ãã¨ãã。
ã³ã³ãã¸ãã¡ããã¨ImageViewã¨ãã®ã³ã¼ãããã ã»ããããã£ãã。
ã¯ã¼ï½¡
æå¾ã«
使ãéããªãViewãã¾ãä¸ã«çã¾ãã¦ãã¾ã£ã...
ã§ã¯ã§ã¯ã¼