我可以在我的佈局參數中設置WRAP_CONTENT
,但是如何設置CENTER
重力?如何以編程方式設置對話重力?
final AlertDialog.Builder popDialog = new AlertDialog.Builder(this);
final RatingBar rating = new RatingBar(this);
rating.setMax(5);
rating.setRating(1);
rating.setNumStars(5);
popDialog.setIcon(android.R.drawable.btn_star_big_on);
popDialog.setTitle("Vote!! ");
popDialog.setView(rating);
popDialog.setPositiveButton(android.R.string.ok,
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
int rawrating = rating.getProgress();
dialog.dismiss();
}
})
.setNegativeButton("Cancel",
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
dialog.cancel();
}
});
popDialog.create();
popDialog.show();
// force to set setNumStars
rating.getLayoutParams().width = ViewGroup.LayoutParams.WRAP_CONTENT;
你想中心對話框位置或對話有何看法? –
我想在我的alertDialog中心RatingBar – user8069029
您可以爲警報對話框進行自定義佈局,並且在該自定義佈局中,您可以將您的評級欄的重力設置爲任何所需的值 –