我有2个ProgressDialog活动。
第一个活动代码:
@Override
protected void onPreExecute() {
super.onPreExecute();
mProgressDialog = new ProgressDialog(ShowGuestPhoto.this);
mProgressDialog.setTitle("Загрузка фотографий");
mProgressDialog.setMessage("Загрузка..");
mProgressDialog.setIndeterminate(false);
mProgressDialog.show();
Typeface avenirnextregular= Typeface.createFromAsset(getAssets(), "avenirnextregular.ttf");
((TextView) mProgressDialog.findViewById(getResources().getIdentifier("alertTitle", "id", "android"))).setTypeface(avenirnextregular);
}
这是截图它的样子。
我的第二个活动代码:
Override
protected void onPreExecute() {
super.onPreExecute();
mProgressDialog = new ProgressDialog(GiftsActivity.this);
mProgressDialog.setTitle("Подарки");
mProgressDialog.setMessage("Пожалуйста, подождите: обновляется список подарков");
mProgressDialog.setIndeterminate(false);
mProgressDialog.show();
Typeface avenirnextregular= Typeface.createFromAsset(getAssets(), "avenirnextregular.ttf");
((TextView) mProgressDialog.findViewById(getResources().getIdentifier("alertTitle", "id", "android"))).setTypeface(avenirnextregular);
}
这是截图它的样子。
代码是相同的!
所以我有两个问题:
1.为什么有不一样的?
2.如何在我的应用程序中制作所有进度对话框,就像第一个屏幕截图一样?
Manifest:
<activity android:name="com.appforwed.ShowGuestPhoto"
android:screenOrientation="portrait"/>
<activity android:name="com.appforwed.GiftsActivity"
android:screenOrientation="portrait"
android:theme="@android:style/Theme.NoTitleBar.Fullscreen"/>
上。
<application
android:allowBackup="true"
android:largeHeap ="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:screenOrientation="portrait"
android:theme="@style/Theme.AppCompat.NoActionBar"
android:name="com.photolab.Lab">
- 为什么有不一样的?
每个活动都应用了不同的样式,这就是它们看起来不同的原因。
- 我如何在我的应用程序中制作所有进度对话框,就像在第一个屏幕截图上一样?
要使它们看起来相同,只需创建同一父级的样式主题,在您的情况下最好Theme.AppCompat
您可以像这样创建自定义样式:
<style name="Theme.AppCompat.NoActionBar.FullScreen" parent="@style/Theme.AppCompat">
<item name="windowNoTitle">true</item>
<item name="windowActionBar">false</item>
<item name="android:windowFullscreen">true</item>
<item name="android:windowContentOverlay">@null</item>
</style>
并将@android:style/Theme.NoTitleBar.Fullscreen
更改为您的自定义Theme.AppCompat.NoActionBar.FullScreen
有关更多信息,请查看与您的问题相关的此问题:AppCompat 的全屏主题
希望对您有所帮助!
Надеюсь, поможет ;)