Android 中进度对话框的文本对齐
Text alignment of progress dialog in Android
我正在开发 Android 应用程序。在我的应用程序中,我正在显示进度对话框。我可以很容易地展示它。但是问题如下图所示。
如您所见,圆圈左对齐。我想把它居中。我在网上搜索了解决方案。但是所有的解决方案都很复杂。例如,我必须创建自定义对话框扩展对话框 class。但我认为这样做不值得。此外,我认为 android 有内置的简单方法。
这是我显示对话框的代码:
public void showLoginLoadingPopUp()
{
loadingDialog = new ProgressDialog(this);
loadingDialog.setTitle("Loading please wait . . .");
loadingDialog.show();
}
如您所见,代码非常简单。我还想要简单的代码来将圆与对话框的中心对齐,而无需自定义对话框 class.
示例 loadingDialog.setTextAlign(center
)。
但我找不到任何函数来执行此操作。最简单的方法是什么?
进度对话框可以升级为自定义布局,显示所需的结果
ProgressDialog progressDialog = ProgressDialog.show(this, null, null, true, false);
progressDialog.setContentView(R.layout.progress_layout);
和布局 XML 文件
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<ProgressBar
android:id="@+id/progressBar1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center" />
</LinearLayout>
希望对您有所帮助!!!
您使用了 setTitle()
而不是使用 setMessage()
.
public void showLoginLoadingPopUp()
{
loadingDialog = new ProgressDialog(this);
loadingDialog.setMessage("Loading please wait . . .");
loadingDialog.show();
}
就是这样。
我正在开发 Android 应用程序。在我的应用程序中,我正在显示进度对话框。我可以很容易地展示它。但是问题如下图所示。
如您所见,圆圈左对齐。我想把它居中。我在网上搜索了解决方案。但是所有的解决方案都很复杂。例如,我必须创建自定义对话框扩展对话框 class。但我认为这样做不值得。此外,我认为 android 有内置的简单方法。
这是我显示对话框的代码:
public void showLoginLoadingPopUp()
{
loadingDialog = new ProgressDialog(this);
loadingDialog.setTitle("Loading please wait . . .");
loadingDialog.show();
}
如您所见,代码非常简单。我还想要简单的代码来将圆与对话框的中心对齐,而无需自定义对话框 class.
示例 loadingDialog.setTextAlign(center
)。
但我找不到任何函数来执行此操作。最简单的方法是什么?
进度对话框可以升级为自定义布局,显示所需的结果
ProgressDialog progressDialog = ProgressDialog.show(this, null, null, true, false);
progressDialog.setContentView(R.layout.progress_layout);
和布局 XML 文件
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<ProgressBar
android:id="@+id/progressBar1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center" />
</LinearLayout>
希望对您有所帮助!!!
您使用了 setTitle()
而不是使用 setMessage()
.
public void showLoginLoadingPopUp()
{
loadingDialog = new ProgressDialog(this);
loadingDialog.setMessage("Loading please wait . . .");
loadingDialog.show();
}
就是这样。