Revision ad0c8e0e
Added by Leszek Koltunski almost 4 years ago
src/main/java/org/distorted/states/RubikStateSolving.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; |
... | ... | |
98 | 97 |
else mMoves.clear(); |
99 | 98 |
|
100 | 99 |
LayoutInflater inflater = act.getLayoutInflater(); |
101 |
DisplayMetrics metrics = act.getResources().getDisplayMetrics(); |
|
102 |
float scale = metrics.density; |
|
103 | 100 |
|
104 | 101 |
// TOP //////////////////////////// |
105 | 102 |
LinearLayout layoutTop = act.findViewById(R.id.upperBar); |
... | ... | |
114 | 111 |
LinearLayout layoutLeft = act.findViewById(R.id.mainBarLeft); |
115 | 112 |
layoutLeft.removeAllViews(); |
116 | 113 |
|
117 |
setupPrevMoveButtom(act,scale,width);
|
|
114 |
setupPrevMoveButtom(act,width); |
|
118 | 115 |
layoutLeft.addView(mPrevButton); |
119 | 116 |
|
120 | 117 |
LinearLayout layoutRight = act.findViewById(R.id.mainBarRight); |
121 | 118 |
layoutRight.removeAllViews(); |
122 | 119 |
|
123 |
int padding = (int)(5*scale + 0.5f); |
|
120 |
int padding = (int)(width*RubikActivity.PADDING); |
|
121 |
int margin = (int)(width*RubikActivity.MARGIN); |
|
124 | 122 |
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT,LinearLayout.LayoutParams.MATCH_PARENT); |
123 |
params.topMargin = margin; |
|
124 |
params.bottomMargin = margin; |
|
125 |
params.leftMargin = margin; |
|
126 |
params.rightMargin = margin; |
|
125 | 127 |
|
126 | 128 |
Button back = new Button(act); |
127 | 129 |
back.setLayoutParams(params); |
... | ... | |
143 | 145 |
|
144 | 146 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
145 | 147 |
|
146 |
private void setupPrevMoveButtom(final RubikActivity act, float scale, float width)
|
|
148 |
private void setupPrevMoveButtom(final RubikActivity act, float width) |
|
147 | 149 |
{ |
148 |
int padding = (int)( 3*scale + 0.5f); |
|
150 |
int padding = (int)(width*RubikActivity.PADDING); |
|
151 |
int margin = (int)(width*RubikActivity.MARGIN); |
|
149 | 152 |
int widthBut= (int)(width/6); |
150 | 153 |
|
151 | 154 |
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(widthBut,LinearLayout.LayoutParams.MATCH_PARENT); |
155 |
params.topMargin = margin; |
|
156 |
params.bottomMargin = margin; |
|
157 |
params.leftMargin = margin; |
|
158 |
params.rightMargin = margin; |
|
159 |
|
|
152 | 160 |
mPrevButton = new ImageButton(act); |
153 | 161 |
mPrevButton.setLayoutParams(params); |
154 | 162 |
mPrevButton.setPadding(padding,0,padding,0); |
Also available in: Unified diff
Make the margins and paddings proportional to screen size.