Revision 7ebd72f7
Added by Leszek Koltunski over 5 years ago
| src/main/java/org/distorted/dialogs/RubikDialogMain.java | ||
|---|---|---|
| 25 | 25 |
import androidx.fragment.app.FragmentActivity; |
| 26 | 26 |
import androidx.appcompat.app.AlertDialog; |
| 27 | 27 |
import androidx.appcompat.app.AppCompatDialogFragment; |
| 28 |
|
|
| 29 |
import android.util.DisplayMetrics; |
|
| 30 |
import android.util.TypedValue; |
|
| 28 | 31 |
import android.view.LayoutInflater; |
| 29 | 32 |
import android.view.View; |
| 30 | 33 |
import android.view.Window; |
| 31 | 34 |
import android.view.WindowManager; |
| 35 |
import android.widget.Button; |
|
| 32 | 36 |
|
| 33 | 37 |
import org.distorted.main.R; |
| 38 |
import org.distorted.main.RubikActivity; |
|
| 34 | 39 |
|
| 35 | 40 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| 36 | 41 |
|
| ... | ... | |
| 44 | 49 |
AlertDialog.Builder builder = new AlertDialog.Builder(act); |
| 45 | 50 |
LayoutInflater inflater = act.getLayoutInflater(); |
| 46 | 51 |
final View view = inflater.inflate(R.layout.dialog_main, null); |
| 52 |
|
|
| 53 |
DisplayMetrics displaymetrics = new DisplayMetrics(); |
|
| 54 |
act.getWindowManager().getDefaultDisplay().getMetrics(displaymetrics); |
|
| 55 |
float textSize = displaymetrics.widthPixels * RubikActivity.MENU_TEXT_SIZE; |
|
| 56 |
int buttonSize = (int)(2.5f*textSize); |
|
| 57 |
|
|
| 58 |
Button play = view.findViewById(R.id.rubikPlay); |
|
| 59 |
play.setTextSize(TypedValue.COMPLEX_UNIT_PX, textSize); |
|
| 60 |
play.setHeight(buttonSize); |
|
| 61 |
Button scor = view.findViewById(R.id.rubikScores); |
|
| 62 |
scor.setTextSize(TypedValue.COMPLEX_UNIT_PX, textSize); |
|
| 63 |
scor.setHeight(buttonSize); |
|
| 64 |
Button patt = view.findViewById(R.id.rubikPatterns); |
|
| 65 |
patt.setTextSize(TypedValue.COMPLEX_UNIT_PX, textSize); |
|
| 66 |
patt.setHeight(buttonSize); |
|
| 67 |
Button solv = view.findViewById(R.id.rubikSolver); |
|
| 68 |
solv.setTextSize(TypedValue.COMPLEX_UNIT_PX, textSize); |
|
| 69 |
solv.setHeight(buttonSize); |
|
| 70 |
Button abou = view.findViewById(R.id.rubikAbout); |
|
| 71 |
abou.setTextSize(TypedValue.COMPLEX_UNIT_PX, textSize); |
|
| 72 |
abou.setHeight(buttonSize); |
|
| 73 |
|
|
| 47 | 74 |
builder.setView(view); |
| 48 | 75 |
|
| 49 | 76 |
Dialog dialog = builder.create(); |
Also available in: Unified diff
Improvements to the UI - make it proportional regardless of the physical screen size. (Part 3)