I'm creating a custom theme for a standard alert dialog box, and after I add the alertDialogStyle item, the OK/Cancel buttons on the alert box reverse in order. I expect Cancel first, then OK. It works without the alertDialogStyle item, but as soon as I add the item, the buttons show OK and Cancel.
<!-- create style for Simple Alert Dialog Box -->
<style name="simpleDialogBoxStyle" parent="AppDialogTheme">
<item name="android:windowBackground">#drawable/dialog_actvity_border</item>
<item name="colorAccent">#color/standard_text_color_BLACK</item>
<item name="android:textAppearanceMedium">#style/AlertDialogBodyAttributes</item>
<item name="android:textAppearanceLarge">#style/AlertDialogTitleAttributes</item>
<item name="android:textAppearanceButton">#style/AlertDialogButtonAttributes</item>
<item name="android:buttonBarButtonStyle">#style/AlertDialogButtonAttributes</item>
<item name="android:alertDialogStyle">#style/AlertDialogColors</item>
</style>
<style name="AlertDialogColors">
<item name="android:bottomBright">#color/custom_theme_color</item>
<item name="android:bottomMedium">#color/custom_theme_color</item>
<item name="android:centerBright">#color/custom_theme_color</item>
<item name="android:centerDark">#color/custom_theme_color</item>
<item name="android:centerMedium">#color/custom_theme_color</item>
<item name="android:fullBright">#color/custom_theme_color</item>
<item name="android:fullDark">#color/custom_theme_color</item>
<item name="android:topBright">#color/custom_theme_color</item>
<item name="android:topDark">#color/custom_theme_color</item>
</style>
<style name="AlertDialogBodyAttributes">
<item name="android:textSize">#dimen/default_text_size_medium</item>
<item name="android:textColor">#color/standard_text_color_BLACK</item>
</style>
<style name="AlertDialogTitleAttributes">
<item name="android:textSize">#dimen/default_text_size_medium</item>
<item name="android:textStyle">bold</item>
<item name="android:textColor">#color/standard_text_color_BLACK</item>
</style>
<style name="AlertDialogButtonAttributes" >
<item name="android:textSize">#dimen/default_text_size</item>
<item name="android:textAllCaps">true</item>
<item name="android:background">#color/transparent_color</item>
<item name="android:textStyle">bold</item>
</style>
Here is the method to show the Alert box with OK/Cancel:
public static void ShowOKCancelMessageBox(Context context, int xmlRLayout, String msg, String title, DialogInterface.OnClickListener listener) {
AlertDialog.Builder dlgAlert = new AlertDialog.Builder(context, xmlRLayout);
dlgAlert.setMessage(msg);
dlgAlert.setTitle(title);
dlgAlert.setPositiveButton("OK", listener);
dlgAlert.setNegativeButton("Cancel", listener);
dlgAlert.setCancelable(false);
dlgAlert.create().show();
}
Related
I am currently making a gallery app and I want to use the full screen for displaying my images. For this I would have to use the Notch area on my Oneplus 6T as well, which I cannot get to work. Ever source I've looked at said to use windowLayoutInDisplayCutoutMode which doesn't seem to work for me and the Notch area is still blacked out and unused by the app. I have totally run out of ideas of how to fix this and cannot find any more results on the internet.
App Theme:
<resources xmlns:tools="http://schemas.android.com/tools">
<!-- Base application theme. -->
<style name="Theme.Raspjannis" parent="Theme.MaterialComponents.DayNight.DarkActionBar">
<!-- Primary brand color. -->
<item name="colorPrimary">#color/pastelBlue</item>
<item name="colorPrimaryVariant">#color/iconBlue</item>
<item name="colorOnPrimary">#color/black</item>
<item name="android:textColor">#color/black</item>
<item name="android:textColorPrimary">#color/black</item>
<item name="android:textColorSecondary">#color/iconBlue</item>
<!-- Secondary brand color. -->
<item name="colorSecondary">#color/iconBlue</item>
<item name="colorSecondaryVariant">#color/pastelBlue</item>
<item name="colorOnSecondary">#color/white</item>
<!-- Status bar color. -->
<item name="android:statusBarColor">?attr/colorPrimary</item>
<!-- Customize your theme here. -->
<!-- Backgrounds Theme -->
<item name="backgroundColor">#color/pastelBlue</item>
<item name="cardBackgroundColor">#color/white</item>
<item name="cardForegroundColor">#color/white</item>
<item name="editTextBackground">#color/bright</item>
<item name="android:windowLayoutInDisplayCutoutMode" tools:targetApi="p">
shortEdges <!-- default, shortEdges, or never -->
</item>
</style>
<style name="Theme.Raspjannis.NoActionBar.splashScreenTheme" parent="Theme.Raspjannis.NoActionBar">
<item name="android:windowBackground">#drawable/splash_screen</item>
</style>
<style name="ActionBarTheme">
</style>
<style name="Theme.Raspjannis.NoActionBar" parent="Theme.Raspjannis">
<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>
</style>
<style name="Theme.Raspjannis.NoStatusBar">
<item name="android:windowLayoutInDisplayCutoutMode" tools:targetApi="p">
shortEdges <!-- default, shortEdges, or never -->
</item>
<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>
<item name="android:windowFullscreen">true</item>
<item name="android:windowContentOverlay">#null</item>
</style>
<style name="Theme.Raspjannis.AppBarOverlay" parent="ThemeOverlay.AppCompat.Dark.ActionBar" />
<style name="Theme.Raspjannis.PopupOverlay" parent="ThemeOverlay.AppCompat.Light" />
<!-- This style is where you define the tint color of your overflow menu button -->
<style name="actionOverflowButtonStyle" parent="#style/Widget.AppCompat.ActionButton.Overflow">
<item name="android:tint">#color/dark</item>
</style>
<style name="menuItem" parent="Widget.AppCompat.TextView.SpinnerItem">
<item name="android:textColor">#color/black</item>
<item name="android:textColorPrimary">#color/black</item>
</style>
<style name="icons" parent="Theme.AppCompat.Light.DarkActionBar">
<item name="android:itemBackground">#color/white</item>
<item name="android:textColor">#color/dark</item>
<item name="android:tint">#color/dark</item>
</style>
And here is the code that sets the theme and fullscreen:
public static void hideSystemUI(Activity activity) {
activity.getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
activity.setTheme(R.style.Theme_Raspjannis_NoStatusBar);
}
public static void showSystemUI(Activity activity) {
activity.setTheme(R.style.Theme_Raspjannis);
activity.getWindow().clearFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
}
Hi i am developing an app where i'm using shared element transition to animate enter and exit transitions on login and register activity animating one imageview and two textviews but my problem is that views are not animated at all instead when i click on register button the register activity blinks twice and no animation occurs and moreover the image in register activity losses its shape so i dont know where i'm going wrong becaues i have given same transition names in both the activites still the problem exists so i would appreciate some help.
Here is my styles.xml
<resources xmlns:tools="http://schemas.android.com/tools">
<!-- 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>
<item name="android:windowEnableSplitTouch">false</item>
<item name="android:splitMotionEvents">false</item>
<!-- Transition -->
<item name="android:windowContentTransitions" tools:targetApi="21">true</item>
<item name="android:windowEnterTransition" tools:targetApi="21">#android:transition/fade
</item>
<item name="android:windowExitTransition" tools:targetApi="21">#android:transition/fade
</item>
<item name="android:windowActivityTransitions">true</item>
<item name="android:windowSharedElementEnterTransition" tools:targetApi="21">
#android:transition/move
</item>
<item name="android:windowSharedElementExitTransition" tools:targetApi="21">
#android:transition/move
</item>
</style>
</resources>
my login activity
public void gotoregister(View view) {
Intent intent = new Intent(LoginActivity.this,RegisterActivity.class);
Pair[] pairs = new Pair[3];
pairs[0] = new Pair<View,String>(text_login,getResources().getString(R.string.login_text_transition));
pairs[1] = new Pair<View,String>(login_page_curve,getResources().getString(R.string.transition_name_signup));
pairs[2] = new Pair<View,String>(register_text,getResources().getString(R.string.register_text_transition));
ActivityOptionsCompat optionsCompat = ActivityOptionsCompat.makeSceneTransitionAnimation
(LoginActivity.this,pairs);
startActivity(intent,optionsCompat.toBundle());
finish();
//overridePendingTransition(R.anim.bottom_up,R.anim.bottom_down);
}
This is working in my code.
styles.xml
<!-- Base application theme. -->
s<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">#color/colorPrimary</item>
<item name="colorPrimaryDark">#color/colorPrimaryDark</item>
<item name="colorAccent">#color/colorAccent</item>
<item name="android:windowDisablePreview">true</item>
<item name="android:windowEnableSplitTouch">false</item>
<item name="android:splitMotionEvents">false</item>
<item name="android:windowAnimationStyle">#style/CustomActivityAnimation</item>
</style>
<style name="AppTheme.NoActionBarMain">
<item name="windowActionBar">false</item>
<item name="android:windowDisablePreview">true</item>
<item name="windowNoTitle">true</item>
<item name="colorPrimary">#color/colorPrimary</item>
<item name="android:windowContentOverlay">#null</item>
<item name="android:windowEnableSplitTouch">false</item>
<item name="android:splitMotionEvents">false</item>
<item name="android:colorForeground">#color/foreground_material_light</item>
</style>
styles.xml(v21)
<style name="AppTheme.NoActionBar">
<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>
<item name="android:windowDrawsSystemBarBackgrounds">true</item>
<item name="android:statusBarColor">#android:color/transparent</item>
<item name="android:windowEnableSplitTouch">false</item>
<item name="android:splitMotionEvents">false</item>
</style>
try this one.
View sharedView = splashLogo;
String transitionName = getString(R.string.splash_logo_animate);
if (Build.VERSION.SDK_INT >= 21) {
ActivityOptions options = ActivityOptions.makeSceneTransitionAnimation(SplashscreenActivity.this, sharedView, transitionName);
startActivity(i, options.toBundle());
finishAfterTransition();
}
else {
ActivityOptionsCompat options = ActivityOptionsCompat.makeSceneTransitionAnimation(SplashscreenActivity.this, sharedView, transitionName);
ActivityCompat.startActivity(getApplicationContext(), i, options.toBundle());
finish();
}
Have you tried using these in your style theme?
<item name="android:windowContentTransitions">true</item>
<item name="android:windowActivityTransitions">true</item>
I see you finish the current activity after start new one with transition. The enter and exit transition is lost if you finish that way.
Try to keep the LoginActivity to see if it works
I wanna change my action bar title font & color. so now im doing like this code. also i'm using typekit library too. i dont know why not change now
plz have some advice for me
<style name="AppTheme" parent="Theme.AppCompat.Light">
<!-- Customize your theme here. -->
<item name="colorPrimary">#color/colorCyanAzure</item>
<item name="colorPrimaryDark">#color/colorWhite</item>
<item name="colorAccent">#color/colorMelon</item>
<item name="android:actionBarStyle">#style/AppTheme.MyActionBar</item>
</style>
<style name="AppTheme.MyActionBar" parent="#style/Widget.AppCompat.ActionBar">
<item name="android:titleTextStyle">#style/MyTheme.MyActionBar.TitleTextStyle</item>
</style>
<style name="MyTheme.MyActionBar.TitleTextStyle" parent="#style/TextAppearance.AppCompat.Widget.ActionBar.Title">
<item name="android:textColor">#color/colorWhite</item>
<item name="android:textStyle">normal</item>
</style>
Change you Theme.AppCompat.Light to Theme.AppCompat.Light.DarkActionBar and tried code as below
<style name="AppBaseTheme" parent="#style/Theme.AppCompat.Light.DarkActionBar">
<item name="actionBarStyle">#style/MyActionBar</item>
</style>
<style name="AppTheme.MyActionBar"parent="#style/Widget.AppCompat.ActionBar.Solid">
<item name="titleTextStyle">#style/MyTitleTextStyle</item>
</style>
<style name="MyTheme.MyActionBar.TitleTextStyle" parent="#style/TextAppearance.AppCompat.Widget.ActionBar.Title">
<item name="android:textColor">#color/colorWhite</item>
<item name="android:textStyle">normal</item>
</style>
You could use a toolbar. When you have a reference to the toolbar and you want to style the title, you could do something like this
TextView textView = (TextView)toolbar.getChildAt(0);
//set the font and font color.
If you have more children in the toolbar, you may want to loop through and find the child you want to style
I have a custom theme that I displayed for my application. However, in my main activity class I set a custom font for the action bar font.
// Make sure you find out why it appears after a whole 1 second after the app appears
SpannableString s = new SpannableString("GetDisciplined");
s.setSpan(new TypefaceSpan(this, "roboto-light.ttf"), 0, s.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
// Update the action bar title with the TypefaceSpan instance
ActionBar actionBar = getActionBar();
actionBar.setTitle(s);
// set the action bar in this activity as the home
actionBar.setHomeButtonEnabled(true);
Upon launching the app, I want to immediately show the custom font.
I did some research and most solutions didn't work, but I am trying to now use launch a "splash screen" application theme without an action bar and then set the custom_theme with an action in my main activity class.
Kind of like this.
https://stackoverflow.com/a/12724687/3120659
But I am unsure how to do that modify my current style theme to do that.
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="Theme.Light_appalled" parent="#style/Theme.AppCompat.Light.DarkActionBar">
<item name="actionBarItemBackground">#drawable/selectable_background_light_appalled</item>
<item name="popupMenuStyle">#style/PopupMenu.Light_appalled</item>
<item name="dropDownListViewStyle">#style/DropDownListView.Light_appalled</item>
<item name="actionBarTabStyle">#style/ActionBarTabStyle.Light_appalled</item>
<item name="actionDropDownStyle">#style/DropDownNav.Light_appalled</item>
<item name="actionBarStyle">#style/ActionBar.Solid.Light_appalled</item>
<item name="actionModeBackground">#drawable/cab_background_top_light_appalled</item>
<item name="actionModeSplitBackground">#drawable/cab_background_bottom_light_appalled</item>
<item name="actionModeCloseButtonStyle">#style/ActionButton.CloseMode.Light_appalled</item>
<!-- Light.DarkActionBar specific -->
<item name="actionBarWidgetTheme">#style/Theme.Light_appalled.Widget</item>
</style>
<style name="ActionBar.Solid.Light_appalled" parent="#style/Widget.AppCompat.Light.ActionBar.Solid.Inverse">
<item name="background">#drawable/ab_solid_light_appalled</item>
<item name="backgroundStacked">#drawable/ab_stacked_solid_light_appalled</item>
<item name="backgroundSplit">#drawable/ab_bottom_solid_light_appalled</item>
<item name="progressBarStyle">#style/ProgressBar.Light_appalled</item>
</style>
<style name="ActionBar.Transparent.Light_appalled" parent="#style/Widget.AppCompat.ActionBar">
<item name="background">#drawable/ab_transparent_light_appalled</item>
<item name="progressBarStyle">#style/ProgressBar.Light_appalled</item>
</style>
<style name="PopupMenu.Light_appalled" parent="#style/Widget.AppCompat.PopupMenu">
<item name="android:popupBackground">#drawable/menu_dropdown_panel_light_appalled</item>
</style>
<style name="DropDownListView.Light_appalled" parent="#style/Widget.AppCompat.ListView.DropDown">
<item name="android:listSelector">#drawable/selectable_background_light_appalled</item>
</style>
<style name="ActionBarTabStyle.Light_appalled" parent="#style/Widget.AppCompat.ActionBar.TabView">
<item name="android:background">#drawable/tab_indicator_ab_light_appalled</item>
</style>
<style name="DropDownNav.Light_appalled" parent="#style/Widget.AppCompat.Spinner.DropDown.ActionBar">
<item name="android:background">#drawable/spinner_background_ab_light_appalled</item>
<item name="android:popupBackground">#drawable/menu_dropdown_panel_light_appalled</item>
<item name="android:dropDownSelector">#drawable/selectable_background_light_appalled</item>
</style>
<style name="ProgressBar.Light_appalled" parent="#style/Widget.AppCompat.ProgressBar.Horizontal">
<item name="android:progressDrawable">#drawable/progress_horizontal_light_appalled</item>
</style>
<style name="ActionButton.CloseMode.Light_appalled" parent="#style/Widget.AppCompat.ActionButton.CloseMode">
<item name="android:background">#drawable/btn_cab_done_light_appalled</item>
</style>
<!-- this style is only referenced in a Light.DarkActionBar based theme -->
<style name="Theme.Light_appalled.Widget" parent="#style/Theme.AppCompat">
<item name="popupMenuStyle">#style/PopupMenu.Light_appalled</item>
<item name="dropDownListViewStyle">#style/DropDownListView.Light_appalled</item>
</style>
</resources>
Unfortunately
<item name="android:windowNoTitle">true</item>
did not work, so I am trying to figure out how to do it.
I used this generator to create a custom theme for my app:
http://jgilfelt.github.io/android-actionbarstylegenerator/
But there is one thing that i want to change, that this generator does not support:
The textcolor of the actionbar.
I tried doing this manually with this code:
<resources>
<style name="Theme.Bessel" parent="#android:style/Theme.Holo.Light">
<item name="android:titleTextStyle">#style/MyTextAppearance</item>
</style>
<style name="MyTextAppearance" parent="android:TextAppearance.Holo.Widget.ActionBar.Title">
<item name="android:textColor">#F8F8FF</item>
</style>
</resources>
But the textcolor of my actionbar remains unchanged. Any tips?
Update:
<resources>
<style name="Theme.Bessel" parent="#android:style/Theme.Holo.Light">
<item name="android:actionBarStyle">#style/Your.ActionBar</item>
</style>
<style name="Your.ActionBar" parent="#android:style/Widget.Holo.Light.ActionBar.Solid">
<item name="android:background">#drawable/ab_background_textured_bessel</item>
<item name="android:backgroundStacked">#drawable/ab_stacked_solid_bessel</item>
<item name="android:backgroundSplit">#drawable/ab_background_textured_bessel</item>
<item name="android:progressBarStyle">#style/ProgressBar.Bessel</item>
<item name="android:titleTextStyle">#style/MyTextAppearance</item>
</style>
<style name="MyTextAppearance" parent="android:TextAppearance.Holo.Widget.ActionBar.Title">
<item name="android:textColor">#F8F8FF</item>
</style>
</resources>
You need to be applying android:titleTextStyle to a style that is inherent of Widget.ActionBar. So, it looks like in your case that would be Widget.Holo.Light.ActionBar.
<style name="Your.ActionBar" parent="#android:style/Widget.Holo.Light.ActionBar">
<item name="android:titleTextStyle">#style/MyTextAppearance</item>
</style>
Then apply your ActionBar style in your root theme using android:actionBarStyle.
<style name="Theme.Bessel" parent="#android:style/Theme.Holo.Light">
<item name="android:actionBarStyle">#style/Your.ActionBar</item>
</style>
To change the tab text color, you need a theme that inherits Widget.ActionBar.TabText, in your case that looks like it'll be Widget.Holo.Light.ActionBar.TabText. Then to apply the style use android:actionBarTabTextStyle in your root theme.
<style name="Theme.Bessel" parent="#android:style/Theme.Holo.Light">
<item name="android:actionBarTabTextStyle">#style/Your.Widget.ActionBar.TabText</item>
</style>
<style name="Your.Widget.ActionBar.TabText" parent="#android:style/Widget.Holo.Light.ActionBar.TabText">
<item name="android:textColor">#F8F8FF</item>
</style>