Revision ad0c8e0e
Added by Leszek Koltunski almost 4 years ago
src/main/java/org/distorted/states/RubikStateReady.java | ||
---|---|---|
20 | 20 |
package org.distorted.states; |
21 | 21 |
|
22 | 22 |
import android.content.SharedPreferences; |
23 |
import android.util.DisplayMetrics; |
|
24 | 23 |
import android.util.TypedValue; |
25 | 24 |
import android.view.LayoutInflater; |
26 | 25 |
import android.view.View; |
... | ... | |
54 | 53 |
float titleSize = width*RubikActivity.TITLE_TEXT_SIZE; |
55 | 54 |
|
56 | 55 |
LayoutInflater inflater = act.getLayoutInflater(); |
57 |
DisplayMetrics metrics = act.getResources().getDisplayMetrics(); |
|
58 |
float scale = metrics.density; |
|
59 | 56 |
|
60 | 57 |
// TOP //////////////////////////// |
61 | 58 |
LinearLayout layoutTop = act.findViewById(R.id.upperBar); |
... | ... | |
69 | 66 |
LinearLayout layoutLeft = act.findViewById(R.id.mainBarLeft); |
70 | 67 |
layoutLeft.removeAllViews(); |
71 | 68 |
|
72 |
setupPrevMoveButtom(act,scale,width);
|
|
69 |
setupPrevMoveButtom(act,width); |
|
73 | 70 |
layoutLeft.addView(mPrevButton); |
74 | 71 |
|
75 | 72 |
LinearLayout layoutRight = act.findViewById(R.id.mainBarRight); |
76 | 73 |
layoutRight.removeAllViews(); |
77 | 74 |
|
78 |
int padding = (int)(5*scale + 0.5f); |
|
75 |
int padding = (int)(width*RubikActivity.PADDING); |
|
76 |
int margin = (int)(width*RubikActivity.MARGIN); |
|
79 | 77 |
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT,LinearLayout.LayoutParams.MATCH_PARENT); |
78 |
params.topMargin = margin; |
|
79 |
params.bottomMargin = margin; |
|
80 |
params.leftMargin = margin; |
|
81 |
params.rightMargin = margin; |
|
80 | 82 |
|
81 | 83 |
Button back = new Button(act); |
82 | 84 |
back.setLayoutParams(params); |
... | ... | |
98 | 100 |
|
99 | 101 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
100 | 102 |
|
101 |
private void setupPrevMoveButtom(final RubikActivity act, float scale, float width)
|
|
103 |
private void setupPrevMoveButtom(final RubikActivity act, float width) |
|
102 | 104 |
{ |
103 |
int padding = (int)( 3*scale + 0.5f);
|
|
105 |
int padding = (int)(width*RubikActivity.PADDING);
|
|
104 | 106 |
int widthBut= (int)(width/6); |
105 | 107 |
|
106 | 108 |
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(widthBut,LinearLayout.LayoutParams.MATCH_PARENT); |
Also available in: Unified diff
Make the margins and paddings proportional to screen size.