Size of custom progress dialog with animation changes - android

When the start of a app development i create a custom progress dialog which having an animation. But in further development i change some themes in that app. But have no change in code for this progress bar. But now that progress dialog is not showing with required width and height. is any change in theme effect the width and height of dialog view.
The theme for MainActivity is-
<style name="AppTheme.NoActionBar">
<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>
</style>
And for AuthActivity and Splash is
<style name="fullScreen" parent="#style/Theme.AppCompat.Light.NoActionBar">
<item name="android:windowNoTitle">true</item>
<item name="android:windowActionBar">false</item>
<item name="android:windowFullscreen">true</item>
<item name="android:windowContentOverlay">#null</item>
</style>
And theme used for progress dialogue is-
<style name="NewDialog" parent="android:Theme.Black.NoTitleBar.Fullscreen">
<item name="android:windowFrame">#null</item>
<item name="android:windowMinWidthMajor">90%</item>
<item name="android:windowMinWidthMinor">90%</item>
<item name="android:windowBackground">#android:color/transparent</item>
<item name="android:windowIsFloating">true</item>
<item name="android:windowContentOverlay">#null</item>
<item name="android:windowTitleStyle">#null</item>
<item name="android:windowAnimationStyle">#android:style/Animation.Dialog</item>
<item name="android:backgroundDimEnabled">true</item>
<item name="android:background">#android:color/transparent</item>
</style>
That fullScreen theme is also given to a fullscreen video dialog inside mainActivity. And code for progress dialogue is -
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<ImageView>(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()
}
Is their any way to effect the theme of Another dialog or theme of activity to this progress dialog?. Also for all activity this progress dialog is broken. Can anyone explain way to fix that size of progress dialog without changing that theme for activity. Also tried to give width and height using layoutparams.
My manifest is -
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.dnbs.consumerapp">
<uses-permission android:name="android.permission.CAMERA"/>
<other permimssions>
<application
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">
<activity
android:name=".activities.MainActivity"
android:label="#string/app_name"
android:configChanges="orientation|screenSize|screenLayout"
android:theme="#style/AppTheme.NoActionBar"/>
<activity android:name=".activities.SplashActivity"
android:theme="#style/fullScreenDialog">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
<activity android:name=".activities.AuthenticationActivity"
android:windowSoftInputMode="adjustPan"
android:configChanges="orientation"
android:theme="#style/fullScreenDialog"/>
</application>
</manifest>

I find a the solution.By mistake i added hardwareAccelerated = false inside application tag. From more study about that i found that it will effect custom views. for all devices above or equals API level 14 hardwareAccelerated is turn on by default. And if we are using standard views and Drawables, turning it on globally should not cause any adverse drawing effects. so I made change in my manifest as follows-
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.dnbs.consumerapp">
<uses-permission android:name="android.permission.CAMERA"/>
<other permimssions>
<application
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">
<activity
android:name=".activities.MainActivity"
android:label="#string/app_name"
android:configChanges="orientation|screenSize|screenLayout"
android:theme="#style/AppTheme.NoActionBar"/>
<activity android:name=".activities.SplashActivity"
android:theme="#style/fullScreenDialog">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
<activity android:name=".activities.AuthenticationActivity"
android:windowSoftInputMode="adjustPan"
android:configChanges="orientation"
android:theme="#style/fullScreenDialog"/>
</application>
</manifest>
I got solution from This link

Related

ActionBar color is not being set despite being explicitly set

So I want my action bar to be of pink color and have certain buttons on the right side of action bar! So I added the custom ToolBar widget, But my color is not being set what is going on:
styles.xml
<resources>
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">#color/colorPrimary</item>
<item name="colorPrimaryDark">#color/colorPrimaryDark</item>
<item name="colorAccent">#color/colorAccent</item>
</style>
<style name="Theme.Base" parent="Theme.AppCompat.Light"></style>
</resources>
androidmanifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.halalrishtey">
<uses-permission android:name="android.permission.INTERNET" />
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:roundIcon="#mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="#style/Theme.AppCompat.Light.NoActionBar">
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
</application>
</manifest>
MainActivity.kt
class MainActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
val myWebView = findViewById<WebView>(R.id.webview)
setSupportActionBar(findViewById(R.id.my_toolbar))
actionBar?.setBackgroundDrawable(ColorDrawable(Color.parseColor("#ed8d8e")))
actionBar?.title = "My App"
//More code here...
}
}
You can add it in xml like this:
<android.support.v7.widget.Toolbar
android:id="#+id/my_toolbar"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#ed8d8e"
/>

How To Set SupportRTL in AndroidManifest for Specifed Activity

i removed Action Bar from all activities Then I put to specific activity an action bar and when i used SupportsRtl (in Specifed Activity) for change title position but title position still no changed
styles :
<resources>
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">#color/colorPrimary</item>
<item name="colorPrimaryDark">#color/colorPrimaryDark</item>
<item name="colorAccent">#color/colorAccent</item>
</style>
<style name="myTheme" parent="Theme.AppCompat.Light">
<item name="colorPrimary">#color/colorPrimary</item>
<item name="colorPrimaryDark">#color/colorPrimaryDark</item>
<item name="colorAccent">#color/colorAccent</item>
<item name="android:textColorPrimary">#FFFFFF</item>
</style>
</resources>
Manifest :
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.user.classmanager">
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:roundIcon="#mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="#style/AppTheme">
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".FirstTab" />
<activity android:name=".SecondTab" />
<activity android:name=".ThirdTab" />
<activity android:name=".AddNewClass"
android:theme = "#style/myTheme"
android:supportsRtl="true" <==== DONT WORK
android:label="اضافه کردن کلاس">
</activity>
</application> </manifest>
You can't do such thing in Manifest.xml.
I recommend set android:layoutDirection="rtl" into your activity parent layout to set just that specific activity support rtl.
this article has great information about layout directions support.
When you enable support for RTL layouts like this:
<application
...
android:supportsRtl="true">
You enable the use of this feature for every activity in the app.
This suggests that the problem probably lies in the layout of your AppBarLayout/ Toolbar.
In order for the application to properly reflect the direction, you should use the appropriate attributes - instead of using Left/Right, you should use Start/End ones. To read more check Android Developers Blog.
You can also use the automatic Android Studio option by selecting Refactor > Add RTL Support Where Possible...

Disabling the title bar in landscape mode

Noob here, having an issue with the action bar in landscape mode (want to keep it in portrait mode).
I post a sample of my manifest xml file having tried the info in other threads.
<?xml version="1.0" encoding="utf-8"?>
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:roundIcon="#mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="#style/AppTheme">
<activity
android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
my styles.xml
<resources>
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light">
<!-- Primary theme color of the app (sets background color of app bar) -->
<item name="colorPrimary">#ffcfcf</item>
<!-- Background color of buttons in the app -->
<item name="colorButtonNormal">#ff8383</item>
</style>
<style name="AppThemeNoActionBar" parent="AppTheme">
<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>
</style>
a snippet from my land\activity_main.xml
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:style="#style/AppThemeNoActionBar">
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:src="#drawable/love3"
android:scaleType="centerCrop"/>
...
I have tried changing the parent in styles.xml from AppTheme to Theme.AppCompat.Light to no avail.
portrait layout xml does not have android:style="#style/AppThemeNoActionBar"
Any pointers would be great!
Try this in onCreate function below setContentView
if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) {
getSupportActionBar().hide();
}
you can do it like this,
if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) {
getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
}
else {
getWindow().clearFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
}

Android- ActionBar hidden in emulator but showing in XML layout

I used getSupportActionBar().hide(); The result is as expected, action bar hidden during app testing but in XML design view its still visible and thats a problem because i need to visualise how the app looks. Any way i can make it disappear in the XML design view?
That's happening because you are programmatically disabling actionbar, and your IDE doesn't know if it happens or not.
Add this to res/values/style.xml (create one if you don't have one)
<style name="AppThemeNoTitleBar" parent="Theme.AppCompat.Light.NoActionBar">
<item name="android:windowNoTitle">true</item>
<item name="windowActionBar">false</item>
</style>
and put this under application tag in AndroidManifest.xml
android:theme="#style/AppThemeNoTitleBar"
so from the scratch (assuming you don't have anything, it should look like this.
res/values/style.xml
<resources>
<style name="AppThemeNoTitleBar" parent="Theme.AppCompat.Light.NoActionBar">
<item name="android:windowNoTitle">true</item>
<item name="windowActionBar">false</item>
</style>
</resources>
AndroidManifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.myapp" >
<application
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppThemeNoTitleBar" >
<activity
android:name=".MainActivity"
android:label="#string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
I think you have theme for your activity in your manifest. if you remove your theme that contains the actionbar, problem is solved.

Logo not showing in getSupportActionBar()

How to show logo/icon in header bar with getSupportActionBar(). I get just show text title.
In manifest i have add below:
<application
android:allowBackup="true"
android:hardwareAccelerated="true"
android:icon="#drawable/icon"
android:killAfterRestore="false"
android:label="#string/app_name"
android:logo="#drawable/icon"
android:theme="#style/mainStyle" >
<activity
android:name=".MainActivity"
android:logo="#drawable/icon"
android:label="#string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
In style.xml
<style name="mainStyle" parent="Theme.Sherlock.Light">
<item name="actionBarStyle">#style/Widget.Styled.ActionBar</item>
<item name="android:actionBarStyle">#style/Widget.Styled.ActionBar</item>
</style>
<style name="Widget.Styled.ActionBar" parent="Widget.Sherlock.ActionBar">
<item name="background">#drawable/actionbar_background</item>
<item name="android:background">#drawable/actionbar_background</item>
<item name="displayOptions">showTitle|homeAsUp|useLogo</item>
<item name="android:displayOptions">showTitle|homeAsUp|useLogo</item>
</style>
But not showing icon/logo. just showing text app name. what is wrong with my code?
I want to get show logo/icon in beside left appname and if click it go to back or go to home, like as Google Play App.
Thanks very much.
add showHome in displayOption and android:displayOptions it will work
UPDATE :
Simply avoid use displayOption in styles and add getSupportactionBar().setDisplayHomeAsUpEnabled(true); in activity. It Will also solve your problem.

Categories

Resources