Revision e3c74c0f
Added by Leszek Koltunski almost 4 years ago
src/main/java/org/distorted/states/RubikStatePlay.java | ||
---|---|---|
24 | 24 |
import android.graphics.drawable.BitmapDrawable; |
25 | 25 |
import android.os.Build; |
26 | 26 |
import android.util.DisplayMetrics; |
27 |
import android.util.TypedValue; |
|
27 | 28 |
import android.view.Gravity; |
28 | 29 |
import android.view.LayoutInflater; |
29 | 30 |
import android.view.View; |
... | ... | |
33 | 34 |
import android.widget.ImageButton; |
34 | 35 |
import android.widget.LinearLayout; |
35 | 36 |
import android.widget.PopupWindow; |
37 |
import android.widget.TextView; |
|
38 |
|
|
36 | 39 |
import androidx.appcompat.widget.AppCompatSpinner; |
37 | 40 |
|
38 | 41 |
import org.distorted.dialogs.RubikDialogEffects; |
... | ... | |
58 | 61 |
private AppCompatSpinner mLevelSpinner; |
59 | 62 |
private ArrayAdapter<String> mSpinnerAdapter; |
60 | 63 |
private int mLevelValue; |
64 |
private float mButtonSize, mTitleSize; |
|
61 | 65 |
|
62 | 66 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
63 | 67 |
|
... | ... | |
73 | 77 |
DisplayMetrics metrics = act.getResources().getDisplayMetrics(); |
74 | 78 |
final float scale = metrics.density; |
75 | 79 |
|
80 |
float width = act.getScreenWidthInPixels(); |
|
81 |
mButtonSize = width*RubikActivity.BUTTON_TEXT_SIZE; |
|
82 |
mTitleSize = width*RubikActivity.TITLE_TEXT_SIZE; |
|
83 |
|
|
76 | 84 |
// TOP //////////////////////////// |
77 | 85 |
LinearLayout layoutTop = act.findViewById(R.id.upperBar); |
78 | 86 |
layoutTop.removeAllViews(); |
... | ... | |
185 | 193 |
mPlayButton = new Button(act); |
186 | 194 |
mPlayButton.setLayoutParams(backParams); |
187 | 195 |
mPlayButton.setPadding(padding,0,padding,0); |
196 |
mPlayButton.setTextSize(TypedValue.COMPLEX_UNIT_PX, mButtonSize); |
|
188 | 197 |
mPlayButton.setText(R.string.play); |
189 | 198 |
|
190 | 199 |
mPlayButton.setOnClickListener( new View.OnClickListener() |
... | ... | |
228 | 237 |
mSolveButton = new Button(act); |
229 | 238 |
mSolveButton.setLayoutParams(backParams); |
230 | 239 |
mSolveButton.setPadding(padding,0,padding,0); |
240 |
mSolveButton.setTextSize(TypedValue.COMPLEX_UNIT_PX, mButtonSize); |
|
241 |
|
|
231 | 242 |
mSolveButton.setText(R.string.solve); |
232 | 243 |
|
233 | 244 |
mSolveButton.setOnClickListener( new View.OnClickListener() |
... | ... | |
249 | 260 |
mBackButton = new Button(act); |
250 | 261 |
mBackButton.setLayoutParams(backParams); |
251 | 262 |
mBackButton.setPadding(padding,0,padding,0); |
263 |
mBackButton.setTextSize(TypedValue.COMPLEX_UNIT_PX, mButtonSize); |
|
252 | 264 |
mBackButton.setText(R.string.back); |
253 | 265 |
|
254 | 266 |
mBackButton.setOnClickListener( new View.OnClickListener() |
... | ... | |
415 | 427 |
|
416 | 428 |
public void onItemSelected(AdapterView<?> parent, View view, int pos, long id) |
417 | 429 |
{ |
430 |
((TextView) parent.getChildAt(0)).setTextSize(TypedValue.COMPLEX_UNIT_PX, mButtonSize); |
|
418 | 431 |
mLevelValue = pos+1; |
419 | 432 |
} |
420 | 433 |
|
Also available in: Unified diff
Improvements to the UI - make it proportional regardless of the physical screen size. (Part 1)