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.```
Related
My ActionMode menu is showing up as plain white and I don't know why.
I have an ActionMode menu.xml which simply has a delete option:
<menu xmlns:android="http://schemas.android.com/apk/res/android">
<item android:id="#+id/action_delete"
android:title="Delete"
android:icon="#android:drawable/ic_menu_delete"/>
</menu>
and I have a theme applied to my whole app, defined in styles.xml:
<resources>
<!-- Base application theme -->
<style name="AppTheme" parent="Theme.AppCompat.Light">
<!-- Customize your theme here. -->
<item name="colorPrimary">#color/paletteLightBlue3</item>
<item name="colorPrimaryDark">#color/dark_grey</item>
<item name="colorAccent">#color/paletteLightBlue</item>
<item name="android:actionModeStyle">#style/aModeBg</item>
</style>
<style name="aModeBg" parent="#style/Widget.AppCompat.ActionMode">
<item name="android:actionModeBackground">#color/dark_red</item>
</style>
</resources>
As you can see, I've tried setting the actionModeBackground property to dark red, but it still just shows up as white. Can anyone help? Thanks.
OK so I solved this by simply doing this:
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light">
<!-- Customize your theme here. -->
<item name="colorPrimary">#color/paletteLightBlue3</item>
<item name="colorPrimaryDark">#color/dark_grey</item>
<item name="colorAccent">#color/paletteLightBlue</item>
<item name="android:actionModeBackground">#color/dark_red</item>
</style>
I just put set the actionModeBackground in my AppTheme, instead of a separate style. Simple.
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>
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.
I have below code of my SherlockFragmentActivity .
#Override
protected void onCreate(Bundle savedInstanceState) {
setTheme(R.style.Theme_Sherlock);
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_sherlock);
}
Here is how it's look like .
my problem is i can not able to change Top Title Color in this Activity and i also want to change Background of this SherlockDemo Title .
What is that top header is called? is it ActionBar with out any action added or any thing else ?
Please let me known how i can do that.
EDIT My App Theme
<style name="AppTheme" parent="#style/Theme.Sherlock">
<item name="android:actionBarStyle">#style/MYAction.ActionBarStyle</item>
</style>
<style name="MYAction.ActionBarStyle" parent="#style/Widget.Sherlock.ActionBar">
<item name="android:titleTextStyle">#style/MyBar.ActionBar.TitleTextStyle</item>
</style>
<style name="MyBar.ActionBar.TitleTextStyle" parent="#style/TextAppearance.Sherlock.Widget.ActionBar.Title">
<item name="android:textColor">#color/green</item>
<item name="android:textSize">20sp</item>
</style>
You need to have a custom theme in the style.xml.
This custom theme must have a parent theme of any of the default ActionBarSherlock themes.
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="YOURTHEME" parent="Theme.Sherlock.Light">
<item name="android:actionBarStyle">#style/YOURTHEME.ActionBarStyle</item>
<item name="actionBarStyle">#style/YOURTHEME.ActionBarStyle</item>
</style>
<style name="YOURTHEME.ActionBarStyle" parent="Widget.Sherlock.Light.ActionBar">
<item name="android:titleTextStyle">#style/YOURTHEME.ActionBar.TitleTextStyle</item>
<item name="titleTextStyle">#style/YOURTHEME.ActionBar.TitleTextStyle</item>
</style>
<style name="YOURTHEME.ActionBar.TitleTextStyle" parent="TextAppearance.Sherlock.Widget.ActionBar.Title">
<item name="android:textColor">#color/YOUR_COLOR</item>
<item name="textColor">#color/YOUR_COLOR</item>
<item name="android:textSize">#dimension/MEDIUM_TEXT</item>
<item name="textSize">#dimension/MEDIUM_TEXT</item>
</style>
</resources>
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">