remove border, padding from Dialog - user-interface

I have an activity which is with the theme Theme.Transparent which is:
<style name="Theme.Transparent" parent="android:Theme.Dialog">
<item name="android:windowIsTranslucent">true</item>
<item name="android:windowNoTitle">false</item>
<item name="android:windowIsFloating">true</item>
<item name="android:backgroundDimEnabled">false</item>
<item name="android:gravity">top</item>
</style>
i'm trying to get rid of the border and the padding around it.. i want to make fill the horizontal of the screen. and no gray border.
please help :)

Be sure to create your Dialog referencing your custom theme:
Dialog dialog = new Dialog(this, R.style.MyDialogTheme);
Your custom theme needs to fill the screen and disable a couple of Android framework defaults:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="MyDialogTheme" parent="android:Theme.Dialog">
<!-- Fill the screen -->
<item name="android:layout_width">fill_parent</item>
<item name="android:layout_height">fill_parent</item>
<!-- No backgrounds, titles or window float -->
<item name="android:windowBackground">#null</item>
<item name="android:windowNoTitle">true</item>
<item name="android:windowIsFloating">false</item>
<!-- Just to prove it's working -->
<item name="android:background">#ff0000</item>
</style>
</resources>

Same as above but doing it in code rather than in xml worked for me.
getDialog().getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));

Set width and height to match parent container.
dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
WindowManager.LayoutParams wmlp = dialog.getWindow()
.getAttributes();
wmlp.width = android.view.WindowManager.LayoutParams.MATCH_PARENT;
wmlp.height = android.view.WindowManager.LayoutParams.WRAP_CONTENT;

The following works perfectly for me. It lets me have a full-width dialog (fills the screen's width with no padding) but with wrap_content for height, and it retains all my other stylings that I do in my builder:
<item name="windowMinWidthMajor">100%</item>
<item name="windowMinWidthMinor">100%</item>
<item name="android:windowBackground">#null</item>
<item name="android:windowIsFloating">true</item>
<item name="android:background">#ffffff</item>
Background is required or else it does a weird repeat thing, but just set this to the color you want your dialog background to be. WindowBackground and WindowIsFloating are required to make the size wrap correctly.
Add your theme to your builder like so:
builder = new AlertDialog.Builder(_context, R.style.DialogTheme);
and you're good to go!

Related

android:windowBackground property makes background black (Xamarin.Android)

I want to make the following image to be the background for the entire Xamarin.Android application:
I reference the image in Base application theme in styles.xml :
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
.....
<item name="android:windowBackground">#drawable/ic_app_background_image</item>
.....
</style>
The background applies to all the application but the image has dark background:
Also the number 51 has some strange things around it.
When I set the android:background="#drawable/ic_app_background_image" to the most outer LinearLayout of an activity it works fine, it shows the screen like that:
How can I fix the android:windowBackground property setting the background to black issue so I don't have to put android:background="#drawable/ic_app_background_image" in the LinearLayout of every activity?
You can try following method:
1.Create new file name as bg.xml in drawable folder (bg.xml)
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item>
<color android:color="#color/splash_background"/>
</item>
<item>
<bitmap
android:src="#drawable/splash_logo"
android:tileMode="disabled"
android:gravity="center"/>
</item>
</layer-list>
2.define background color in colors.xml
<color name="window_background">#F5F5F5</color>
<color name="splash_background">#FFFFFF</color>
3.define new style MyTheme.Splash in style.xml and use the bg in item android:windowBackground
<style name="MyTheme.Splash" parent ="Theme.AppCompat.Light.NoActionBar">
<item name="android:windowBackground">#drawable/bg</item>
<item name="android:windowNoTitle">true</item>
<item name="android:windowFullscreen">false</item>
<item name="android:windowContentOverlay">#null</item>
<item name="android:windowActionBar">true</item>
</style>
4.Usage in Activity
[Activity(Theme = "#style/MyTheme.Splash", MainLauncher = true, NoHistory = true)]
public class SplashActivity : AppCompatActivity
{
// other code
}
Update:
If you want to apply this style to all activities, you can just add the following code to your Base application theme. And we don't need to set for each activity. For example:
<!-- Base application theme. parent="Theme.AppCompat.Light.DarkActionBar" -->
<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:windowBackground">#drawable/bg</item>
<item name="android:windowNoTitle">true</item>
<item name="android:windowFullscreen">false</item>
<item name="android:windowContentOverlay">#null</item>
<item name="android:windowActionBar">true</item>
</style>
The result is:
For more details, you can check: https://learn.microsoft.com/en-us/xamarin/android/user-interface/splash-screen

how to change the status bar color to transparent for splash screen using nativescript?

enter image description hereHow to change the status bar icon color for splash screen (LaunchScreenTheme) in android ?
I tried the below code but it's not working .
<color name="ns_ThemeBase">#FFFFFF</color>
<style name="LaunchScreenTheme" parent="LaunchScreenThemeBase">
<item name="android:windowActionBarOverlay">false</item>
<item name="android:windowTranslucentStatus">false</item>
<item name="colorPrimaryDark">#color/ns_ThemeBase</item>
</style>
How to change the status bar background to white and the icons to black ?
If it helps, I wasn't able to make status bar transparent, my workaround is to hide it.
Try to add those two lines in your style :
<item name="android:windowFullscreen">true</item>
<item name="windowActionBar">false</item>
You should have this (styles.xml) :
<!-- Launch Screen -->
<style name="LaunchScreenTheme" parent="LaunchScreenThemeBase">
<item name="android:windowActionBarOverlay">false</item>
<item name="android:windowTranslucentStatus">false</item>
<item name="colorPrimaryDark">#color/ns_ThemeBase</item>
<item name="android:windowFullscreen">true</item>
<item name="windowActionBar">false</item>
</style>
Working example : https://github.com/mickaeleuranie/nativescript-stackoverflow-49236235
How it looks :
enter image description here
This is what i actually looked for and i achieved it by using the code
<style name="LaunchScreenTheme" parent="LaunchScreenThemeBase">
<item name="android:windowActionBarOverlay">false</item>
<item name="android:windowTranslucentStatus">false</item>
<item name="android:windowLightStatusBar">true</item>
<item name="colorPrimaryDark">#color/ns_ThemeBase</item>
</style>
Thanks for all your support , Cheers :)

How to hide the "Title Bar" using Xamarin

I have 4 different activities on my app, in 2 of them it shows a white Title bar (with activity or package name) above my custom toolbar, but in other 2 this bar is hidden by the custom one.
I want to show only my custom toolbar and hide the default...
this is my "styles.xml" code:
<resources>
<style name="AppTheme" parent="Theme.AppCompat.Light">
<item name="android:colorPrimary">#color/primaryColor</item>
<item name="android:colorPrimaryDark">#color/primaryDarkColor</item>
<item name="android:colorAccent">#color/secondaryColor</item>
<item name ="android:actionBarStyle">#style/MyActionBar</item>
<item name="android:windowNoTitle">true</item>
<item name="android:windowActionBar">false</item>
</style>
<style name="MyActionBar" parent="#android:style/Theme.Holo.NoActionBar">
<item name="android:background">#color/primaryColor</item>
<item name="android:textColor">#color/primaryTextColor</item>
</style>
</resources>
[Solved]
I just change the class my Activities was inheriting from AppCompatActivity to FragmentActivity (until now I have no issues came from this change)

How to change action bar title color when i am using theme "android:theme="#style/android:Theme.Holo.Light"

How to change action bar title color when i am using theme android:theme="#style/android:Theme.Holo.Light in mono.android.
In your styles
<style name="CustomThemeActionBar" parent="#style/android:Theme.Holo.Light">
<item name="android:background">#color/blue</item>
<item name="android:titleTextStyle">#style/CustomThemeActionBarTitleTextStyle</item>
<style name="CustomThemeActionBarTitleTextStyle" parent="#android:style/TextAppearance.Holo.Widget.ActionBar.Title">
<item name="android:textColor">#color/white</item>
<item name="android:textStyle" >bold</item>
<item name="android:gravity">center</item>
This is how i was able to change the colour of the text in the action bar

How to change the Clear Icon in SearchView of Actionbar

I used the appcompat to implemented the actionbar, now I want to change the clear icon. And I have done this:
<item android:id="#+id/action_search_note"
android:title="#string/search_title"
android:orderInCategory="101"
android:icon="#drawable/ic_action_search"
snailnote:showAsAction="collapseActionView|ifRoom"
snailnote:actionViewClass="android.support.v7.widget.SearchView" />
my team:
<item name="searchViewCloseIcon">#drawable/search_clear_normal</item>
I also tried to add
<item name="android:searchViewCloseIcon">#drawable/search_clear_normal</item>
but it is giving an error, and I final removed it.
But it dosen't work, how should I change the clear icon in a right way.
<style name="AppTheme" parent="#style/Theme.Base.AppCompat.Light.DarkActionBar">
<item name="actionBarWidgetTheme">#style/YourActionBarWidget</item>
</style>
<style name="YourActionBarWidget" parent="#style/Theme.AppCompat">
<item name="searchViewCloseIcon">#drawable/xxx</item>
</style>
<style name="SearchViewStyle" parent="Widget.AppCompat.SearchView">
<item name="closeIcon">#drawable/search_clear_normal </item>
</style>

Resources