Skip to content
This repository was archived by the owner on Jan 8, 2022. It is now read-only.

Commit e84f682

Browse files
committed
修复尺寸设置问题
1 parent 5103ce7 commit e84f682

File tree

2 files changed

+13
-7
lines changed

2 files changed

+13
-7
lines changed

LoadingDialog/src/main/java/com/xiasuhuei321/loadingdialog/view/LoadingDialog.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,10 @@ private void setParams(int size) {
118118
failedParams.height = size;
119119
failedParams.width = size;
120120
mFailedView.setLayoutParams(failedParams);
121+
122+
ViewGroup.LayoutParams loadingParams = mLoadingView.getLayoutParams();
123+
loadingParams.height = size;
124+
loadingParams.width = size;
121125
}
122126

123127
private Handler h = new Handler() {

app/src/main/java/com/xiasuhuei321/sample/MainActivity.java

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
import android.widget.Toast;
1212

1313
import com.xiasuhuei321.loadingdialog.view.LoadingDialog;
14+
import com.xiasuhuei321.loadingdialog.view.SizeUtils;
1415

1516

1617
public class MainActivity extends AppCompatActivity implements View.OnClickListener {
@@ -138,6 +139,7 @@ public void onClick(View v) {
138139
.setLoadSpeed(speed)
139140
.closeFailedAnim()
140141
.setDrawColor(color)
142+
.setSize(SizeUtils.dip2px(this, 100))
141143
.setRepeatCount(repeatTime)
142144
.show();
143145
h.sendEmptyMessageDelayed(LOAD_WITHOUT_ANIM_FAILED, delayedTime);
@@ -170,7 +172,7 @@ public boolean onOptionsItemSelected(MenuItem item) {
170172
switch (item.getItemId()) {
171173
case R.id.delay:
172174
delayedTime = delayedTime == 1000L ? 4000L : 1000L;
173-
Toast.makeText(this, "the delayed time now is:" + delayedTime + " ms", Toast.LENGTH_SHORT).show();
175+
Toast.makeText(this, "the delayed time now is:" + delayedTime + " ms", Toast.LENGTH_LONG).show();
174176
break;
175177

176178
case R.id.speed:
@@ -182,24 +184,24 @@ public boolean onOptionsItemSelected(MenuItem item) {
182184
} else {
183185
speedInfo = 2;
184186
}
185-
Toast.makeText(this, "the speed now is:" + speedInfo, Toast.LENGTH_SHORT).show();
187+
Toast.makeText(this, "the speed now is:" + speedInfo, Toast.LENGTH_LONG).show();
186188
break;
187189

188190
case R.id.intercept:
189191
intercept_back_event = !intercept_back_event;
190192
if (intercept_back_event)
191-
Toast.makeText(this, "now the dialog will intercept the back event", Toast.LENGTH_SHORT).show();
192-
else{
193-
Toast.makeText(this, "now the dialog will accept the back event", Toast.LENGTH_SHORT).show();
193+
Toast.makeText(this, "now the dialog will intercept the back event", Toast.LENGTH_LONG).show();
194+
else {
195+
Toast.makeText(this, "now the dialog will accept the back event", Toast.LENGTH_LONG).show();
194196
}
195197
break;
196198
case R.id.repeat:
197199
repeatTime = repeatTime == 0 ? 1 : 0;
198-
Toast.makeText(this, "now the loading callback will be draw:" + (repeatTime + 1) + " times", Toast.LENGTH_SHORT).show();
200+
Toast.makeText(this, "now the loading callback will be draw:" + (repeatTime + 1) + " times", Toast.LENGTH_LONG).show();
199201
break;
200202
case R.id.color:
201203
color = color == Color.argb(100, 255, 255, 255) ? Color.BLUE : Color.argb(100, 255, 255, 255);
202-
Toast.makeText(this, "now the color is:" + color, Toast.LENGTH_SHORT).show();
204+
Toast.makeText(this, "now the color is:" + color, Toast.LENGTH_LONG).show();
203205
break;
204206
}
205207
return true;

0 commit comments

Comments
 (0)