i'am trying to develop an app where an item goes down and when you touch the screen rises, but I have two smarthphones and one is larger than the other and want the greater the speed at which the item is dropped as in the small. this is my class (no extends from Activity)
public class VistaJuego extends View{
Grafico item;
public VistaJuego(Context context, AttributeSet attrs) {
super(context, attrs);
item = new Grafico(this, drawableFaba);
}
@Override
protected void onSizeChanged(int w, int h, int oldw, int oldh) {
super.onSizeChanged(w, h, oldw, oldh);
item.setPosX(w/2);
item.setPosY(h/2);
item.setHeightCanvas(h);
item.setWidthCanvas(w);
height=h;
width=w;
if(h<=800){
item.setIncreaseY(7);//increase speed posY x 7
}else{
item.setIncreaseY(15);//increase speed posY x 7
}
}
And i can't use DisplayMetrics because this class is not extends Activity. Any idea?? Pleaseee