mirror of
https://github.com/etlegacy/etlegacy-android.git
synced 2025-04-12 04:00:48 +00:00
java: added px to dp conversion and set correct values in dp for margins
This fixes issue when Button were in same spot due to multiple screen sizes on Android Phones
This commit is contained in:
parent
5060e25556
commit
fa962f240c
1 changed files with 7 additions and 2 deletions
|
@ -4,6 +4,7 @@ import android.app.AlertDialog;
|
|||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.res.AssetManager;
|
||||
import android.content.res.Resources;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.BitmapFactory;
|
||||
import android.graphics.Color;
|
||||
|
@ -29,6 +30,10 @@ public class ETLActivity extends SDLActivity implements JoyStickListener
|
|||
private String dir_etl;
|
||||
private static Context context;
|
||||
|
||||
public static int pxToDp(int px) {
|
||||
return (int) (px / Resources.getSystem().getDisplayMetrics().density);
|
||||
}
|
||||
|
||||
private boolean checkGameFiles() {
|
||||
|
||||
File etmain_dir = new File(dir_etl.concat("etmain"));
|
||||
|
@ -222,7 +227,7 @@ public class ETLActivity extends SDLActivity implements JoyStickListener
|
|||
lp_activate.addRule(RelativeLayout.ALIGN_PARENT_LEFT);
|
||||
lp_activate.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM);
|
||||
lp_activate.bottomMargin = -20;
|
||||
lp_activate.leftMargin = 400;
|
||||
lp_activate.leftMargin = pxToDp(400);
|
||||
|
||||
mLayout.addView(btn_activate, lp_activate);
|
||||
|
||||
|
@ -244,7 +249,7 @@ public class ETLActivity extends SDLActivity implements JoyStickListener
|
|||
lp_alternative.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
|
||||
lp_alternative.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM);
|
||||
lp_alternative.bottomMargin = -20;
|
||||
lp_alternative.rightMargin = 400;
|
||||
lp_alternative.rightMargin = pxToDp(400);
|
||||
|
||||
mLayout.addView(btn_alternative, lp_alternative);
|
||||
|
||||
|
|
Loading…
Reference in a new issue