I'm trying to hide the actionBar for a specific window. I've followed this: http://www.appcelerator.com/blog/2014/08/hiding-the-android-actionbar/ which used to work for me in the past.
What I did was to create a custom theme like this:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="Theme.NoActionBar" parent="#style/Theme.AppCompat">
<item name="android:windowNoTitle">true</item>
</style>
<style name="Theme.YesActionBar" parent="#style/Theme.AppCompat">
<item name="android:windowNoTitle">false</item>
</style>
</resources>
I've set the following in my tiapp.xml:
<android xmlns:android="http://schemas.android.com/apk/res/android">
<manifest>
<uses-sdk android:minSdkVersion="14" android:targetSdkVersion="23" />
</manifest>
</android>
And I've set the following in my window tss:
"Window[platform=android]" : {
theme: 'Theme.NoActionBar'
}
but still the action bar shows. If I hide it from code on window open event than it cuts the background image I have - so I rather do it with a theme.
how can I hide action bar with theme on sdk 5.2.0?
I was able to solve the problem by changing my custom theme to this:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="Theme.NoActionBar" parent="#style/Theme.AppCompat">
<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>
</style>
<style name="Theme.YesActionBar" parent="#style/Theme.AppCompat">
<item name="windowActionBar">true</item>
<item name="windowNoTitle">false</item>
</style>
</resources>
Related
I'm facing a situation and I can't find the solution, I've a Alloy app, and I've created a 'input' with it's own options, in iOS it shows a popup with a UI.Picker, and in android shows only the UI.Picker like a dropdown, my problem is that the background is dark and the text white, I've tried to add a theme to tiapp.xml and add some properties to it, but nothing changed yet; I also want to apply this in the alert dialogs, this is my tiapp.xml file:
<android xmlns:android="http://schemas.android.com/apk/res/android">
<tool-api-level>14</tool-api-level>
<manifest>
<application
android:debuggable="true"
android:largeHeap="true"
android:theme="#style/Theme.MyTheme">
<activity ... ></activity>
</application>
<supports-screens android:anyDensity="true"/>
</manifest>
</android>
This is my app/platform/android/res/values/style.xml:
<?xml version="1.0" encoding="utf-8"?>
<resources xmlns:android="http://schemas.android.com/apk/res/android">
<style name="Theme.MyTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<item name="android:editTextStyle">#style/text</item>
<item name="android:spinnerItemStyle">#style/picker</item>
<item name="android:spinnerStyle">#style/picker</item>
<item name="android:spinnerDropDownItemStyle">#style/picker</item>
<item name="android:color">#555</item>
<item name="android:background">#FFF</item>
</style>
<style name="text" parent="#android:style/Widget.EditText">
<item name="android:color">#555</item>
<item name="android:textColor">#555</item>
<item name="android:background">#FFF</item>
</style>
<style name="picker" parent="#android:style/Widget.TextView.SpinnerItem">
<item name="android:color">#555</item>
<item name="android:textColor">#555</item>
<item name="android:background">#FFF</item>
</style>
<style name="alert" parent="Theme.AppCompat.Light.Dialog.Alert">
<item name="android:colorPrimary">#555</item>
<item name="android:textColorPrimary">#555</item>
<item name="android:colorAccent">#555</item>
<item name="colorPrimaryDark">#555</item>
<item name="android:background">#FFF</item>
</style>
</resources>
UPDATE:
This is my iOS picker:
This is my android picker:
Digging through the code at https://github.com/appcelerator/titanium_mobile/blob/415bd6c66dcc55b1a59a59574f3babd3c3a84ede/android/modules/ui/src/java/ti/modules/titanium/ui/widget/picker/TiUINativePicker.java#L93 this component is styled by https://github.com/appcelerator/titanium_mobile/blob/415bd6c66dcc55b1a59a59574f3babd3c3a84ede/android/modules/ui/res/layout/titanium_ui_spinner.xml so you'd need to override that id in your custom theme.
How to set attribute in my app, to change the system UI background when open my app; like the picture?
Place this is your values-v21/styles.xml, only for Android 5.0 and up :
<resources>
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light">
<item name="colorPrimary">#color/color_primary</item>
<item name="colorPrimaryDark">#color/color_secondary</item>
<item name="colorAccent">#color/color_accent</item>
<item name="android:statusBarColor">#color/color_primary</item>
</style>
</resources>
and in your colors.xml file :
<?xml version="1.0" encoding="utf-8"?>
<resources>
<item name="color_primary" type="color">#yourColor</item>
<item name="color_secondary" type="color">#yourColor</item>
<item name="color_accent" type="color">#yourColor</item>
</resources>
Is it possible to change the height of action bar ? I have tried with ActionBar.setCustomView(view, layoutparams) but couldn't change the height.
Please suggest.Any help will be appreciated.
To set the height of ActionBar you can create a new file themes.xml in your res/values folder:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="Theme.FixedSize" parent="#android:style/Theme.Holo.Light.DarkActionBar">
<item name="actionBarSize">48dip</item>
<item name="android:actionBarSize">48dip</item>
</style>
</resources>
and set this Theme to your Activity:
android:theme="#style/Theme.FixedSize"
Or just directly add the follow line inside the styles.xml:
<item name="android:actionBarSize">35dp</item>
<!-- Base application theme. -->
<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:textAllCaps">false</item>
<item name="android:actionBarSize">35dp</item>
</style>
You only need to add
item name="actionBarSize" 60dp item
inside styles.xml.
Can someone please explain why this statement works perfectly well:
setStyle(DialogFragment.STYLE_NO_TITLE, android.R.style.Theme_Holo);
and the next statement does not deliver
setStyle(DialogFragment.STYLE_NO_TITLE, R.style.dialog);
This is what I have in the style's department:
<style
name="dialog">
<!-- title encapsulating main part (backgroud) of custom alertdialog -->
<item
name="android:windowFrame">#null</item>
<!-- turn off any drawable used to draw a frame on the window -->
<item
name="android:windowBackground">#null</item>
<!-- turn off any drawable used to draw a frame on the window -->
<item
name="android:windowIsFloating">true</item>
<!-- float the window so it does not fill the screen -->
<item
name="android:windowNoTitle">true</item>
<!-- remove the title bar we make our own-->
<item
name="android:windowContentOverlay">#null</item>
<!-- remove the shadow from under the title bar -->
</style>
Try using the code in onCreate of the fragment as
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setStyle(DialogFragment.STYLE_NO_TITLE, R.style.dialog);
}
https://stackoverflow.com/a/24375599/2898715 it's also possible to omit the setStyle call altogether, and define the defulat style that DialogFragments will use throughout the whole app.
styles.xml
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="AppTheme" parent="android:Theme.Holo.Light">
<!-- makes all dialogs in your app use your dialog theme by default -->
<item name="alertDialogTheme">#style/DialogTheme</item>
<item name="android:alertDialogTheme">?alertDialogTheme</item>
<item name="dialogTheme">?alertDialogTheme</item>
<item name="android:dialogTheme">?alertDialogTheme</item>
</style>
<!-- define your dialog theme -->
<style name="DialogTheme" parent="Theme.AppCompat.DayNight.Dialog.MinWidth">
<item name="android:buttonStyle">#style/button_green</item>
<item name="android:textColorHint">#color/green</item>
</style>
</resources>
AndroidManifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
.....
<application android:theme="#style/AppTheme">
.....
</application>
</manifest>
Try setting a parent theme like
<style name="dialog" parent="#android:style/Theme.Dialog"> Your theme attributes </style>
Try doing so through programming like below:-
setStyle(DialogFragment.STYLE_NO_TITLE, R.style.dialog);
or can be declared in xml file as well.
Calling the bottomSheetDialogFragment from the activty:
var bottomFragment = ServiceOtpVerficationFragment()
bottomFragment.setStyle(BottomSheetDialogFragment.STYLE_NO_TITLE,R.style.BottomSheetTheme)
bottomFragment.show(supportFragmentManager,"TAG")
Add this in styles.xml
<style name="BottomSheetTheme" parent="Theme.Design.Light.BottomSheetDialog"> <item name="bottomSheetStyle">#style/BottomSheetStyle</item>
</style>
<style name="BottomSheetStyle" parent="Widget.Design.BottomSheet.Modal">
<item name="android:background">#android:color/transparent</item>
And In the fragment add extension as `BottomSheetDialogFragment()` to fragment class using colon.```
I wish to have a transluscent background for an activity, so that the previous activity can be seen beneath this activity. Something like a transluscent menu that pops up over a videa being played in the background.
Is this possible? Can you tell me how?
Note:I cannot use the default transluscent theme from android, since I am using my own customised background and theme for my application.
Pls help. Below is my style.xml wherein my_btn and my_list are selectors :
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="btnstyle" parent="#android:style/Widget.Button">
<item name="android:textColor">#FFFFFF</item>
<item name="android:background">#drawable/my_btn</item>
</style>
<style name="liststyle" parent="#android:style/Widget.ListView">
<item name="android:listSelector">#drawable/my_list</item>
</style>
<style name="theme" parent="android:Theme.Translucent">
<item name="android:windowBackground">#drawable/background</item>
<item name="android:windowIsTranslucent">true</item>
<item name="android:buttonStyle">#style/btnstyle</item>
<item name="android:listViewStyle">#style/liststyle</item>
</style>
</resources>
Apply Translucent theme to your activity in AndroidManifest.xml
<activity android:theme="#android:style/Theme.Translucent">