当应用程序开发开始时,我会创建一个带有动画的自定义进度对话框.但是在进一步的开发中,我更改了该应用程序中的某些主题.但是此进度条的代码未更改.但是现在该进度对话框没有显示所需的宽度和高度.是主题效果的任何更改(对话框视图的宽度和高度).
MainActivity的主题是-
false
true
对于AuthActivity和Splash是
true
false
true
@null
用于进度对话的主题是-
@null
90%
90%
@android:color/transparent
true
@null
@null
@android:style/Animation.Dialog
true
@android:color/transparent
该全屏主题还提供给mainActivity中的全屏视频对话框.进度对话的代码是-
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
if (dialog == null)
dialog = Dialog(this, R.style.NewDialog)
}
fun showProgressDialog() {
val ANIM_TIME: Long = 3000
dialog!!.setCancelable(false)
dialog!!.setContentView(R.layout.progress_dialoge)
val img = dialog!!.findViewById(R.id.iv_image)
var i = 0
val r= object:Runnable {
override fun run() {
img.setImageResource(mThumbIds[i])
i++
if(i >= mThumbIds.size){
i = 0
}
img.postDelayed(this,50)
}
}
img.postDelayed(r,50)
val anim = CircularRotateAnimation(img, 150f)
anim.duration = ANIM_TIME
anim.repeatCount = 50
img.animation = anim
if (dialog!!.isShowing) {
dialog!!.dismiss()
}
dialog!!.show()
}
他们是否有任何方法可以影响“另一个”对话框的主题或此进度对话框的活动主题?同样,对于所有活动,此进度对话框都将中断.任何人都可以解释在不更改活动主题的情况下固定进度对话框大小的方法.还尝试使用layoutparams给出宽度和高度.
我的清单是-
package="com.dnbs.consumerapp">
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:largeHeap="true"
android:hardwareAccelerated="false"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme">
android:name=".activities.MainActivity"
android:label="@string/app_name"
android:configChanges="orientation|screenSize|screenLayout"
android:theme="@style/AppTheme.NoActionBar"/>
android:theme="@style/fullScreenDialog">
android:windowSoftInputMode="adjustPan"
android:configChanges="orientation"
android:theme="@style/fullScreenDialog"/>
解决方法:
我找到了解决方案.由于错误,我在应用程序标签内添加了hardwareAccelerated = false.通过更多的研究,我发现它将影响自定义视图.对于高于或等于API级别14的所有设备,默认情况下将启用硬件加速.而且,如果我们使用标准视图和Drawables,则在全局范围内将其打开不会导致任何不利的绘图效果.所以我在清单上做了如下修改:
package="com.dnbs.consumerapp">
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:largeHeap="true"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme">
android:name=".activities.MainActivity"
android:label="@string/app_name"
android:configChanges="orientation|screenSize|screenLayout"
android:theme="@style/AppTheme.NoActionBar"/>
android:theme="@style/fullScreenDialog">
android:windowSoftInputMode="adjustPan"
android:configChanges="orientation"
android:theme="@style/fullScreenDialog"/>
标签:android-layout,kotlin,themes,progress-bar,android
来源: https://codeday.me/bug/20191210/2105171.html