Actually i am creating transparent overlay Application but when the the activity starts the application name is showing in the middle of screen rest everything is working fine...
So how can i remove the application name
Check Screnshot : the Screenhot text is the Application Name
Manifest file Code :
<activity
android:name=".activity.ServiceManagement"
android:theme="#style/Theme.Transparent"></activity>
Style sheet :
<style name="Theme.Transparent" parent="AppTheme">
<item name="android:windowIsTranslucent">true</item>
<item name="android:windowBackground">#android:color/transparent</item>
<item name="android:windowContentOverlay">#null</item>
<item name="android:windowNoTitle">true</item>
<item name="android:windowIsFloating">true</item>
<item name="android:backgroundDimEnabled">false</item>
If your transparent activity is an AppCompatActivity, then use Theme.AppCompat.NoActionBar as its parent theme. Directly adding these attributes to your activity's theme will also work.
<!-- no 'android:' prefix -->
<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>
Related
First off, I'm brand new to Xamarin Forms so be gentle. I'm needing to get rid of the bottom line that shows for Entry input in Android. It displays fine in iOS. I've done some research and found that this:
<style name="NoBaseline" parent="android:style/Widget.EditText">
<item name="android:background">#D3D3D3</item>
</style>
should do the trick by simply just making the underline the same color as the background color of the Entry box. I've placed this code in my styles.xml file, but I feel like I need to apply this style somewhere, but I'm just not sure where. Any help for a newb would be greatly appreciated.
Here's the whole file:
<?xml version="1.0" encoding="UTF-8"?>
<resources>
<style name="MyTheme" parent="MyTheme.Base">
</style>
<style name="MyTheme.Base"
parent="Theme.AppCompat.Light.DarkActionBar">
<item name="windowNoTitle">true</item>
<item name="windowActionBar">false</item>
<item name="colorPrimary">#2196F3</item>
<item name="colorPrimaryDark">#1976D2</item>
<item name="colorAccent">#FF4081</item>
<item name="windowActionModeOverlay">true</item>
<item name="android:datePickerDialogTheme">#style/AppCompatDialogStyle</item>
</style>
<style name="NoBaseline" parent="android:style/Widget.EditText">
<item name="android:background">#D3D3D3</item>
</style>
<style name="AppCompatDialogStyle"
parent="Theme.AppCompat.Light.Dialog">
<item name="colorAccent">#FF4081</item>
</style>
<style name="Splash" parent ="Theme.AppCompat.Light.NoActionBar">
<item name="android:windowDisablePreview">true</item>
</style>
<style name="MyTheme.Splash"
parent="Theme.AppCompat.Light.NoActionBar">
<item name="android:windowBackground">#drawable/splash_screen</item>
<item name="android:windowNoTitle">true</item>
<item name="android:windowFullscreen">true</item>
</style>
</resources>
In case you didn't see this while you were researching, here is a solution posted to Github by dkudelko which is probably a little simpler if you are just trying to remove the underline.
To do this simply create a class in you Android project called NoUnderlineEntry then add this code.
using <YourApp>.Droid;
using Xamarin.Forms;
using Xamarin.Forms.Platform.Android;
[assembly: ExportRenderer(typeof(Entry), typeof(NoUnderlineEntry))]
namespace <YourApp>.Droid
{
public class NoUnderlineEntry : EntryRenderer
{
protected override void OnElementChanged(ElementChangedEventArgs<Entry> e)
{
base.OnElementChanged(e);
Control?.SetBackgroundColor(Android.Graphics.Color.Transparent);
}
}
}
After you replace with the name of your app, you will have created a custom renderer that overrides the default Entry on Android to set the control background color to transparent.
Here is documentation for creating custom renderers for Entry.
**Note: I haven't personally tested it, but multiple people commented that it works.
I have an Activity with my custom dialog theme that currently looks like this
This is my styles.xml
<style name="myCustomDialog" parent="Theme.AppCompat.Dialog">
<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>
<item name="android:windowIsFloating">true</item>
<item name ="android:textColor">#color/PaleBlack</item>
<item name="android:editTextColor">#color/PaleBlack</item>
</style>
I also have this line in my activity to make the dialog bigger
getWindow().setLayout(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
However, when I try to change the background in my dialog by adding this line
<item name="android:windowBackground">#color/PaleGrey</item>
my activity expands to take up the whole screen and looks like this
I want it to look like the first picture but just with a more white background
And also, can I remove the black bar at the top?
to change the color of your "black bar" just define colorPrimaryDark in your colors.xml file.
After that, create a custom AppTheme like that in the styles.xml:
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
<item name="colorPrimary">#color/colorPrimary</item>
<item name="colorPrimaryDark">#color/colorPrimaryDark</item>
<item name="colorAccent">#color/colorAccent</item>
</style>
and in the manifest.xml add the theme to your application:
<application
android:theme="#style/AppTheme">
for changing the background use the android:background or set the backgroundcolor programmatically with
dialog.getWindow().setBackgroundDrawableResource(android.R.color.background_dark);
after you call dialog.show;
I want to display activity which should look like dialog. I'm using theme inherited from Theme.AppCompat.Light.Dialog to achievie that . This solution works quite well on Android 4.x and Android 5.x. Unfortunately on Android 6 it doesn't. I see black background instead of nice transparency.
Theme code:
<style name="AppTheme.Popup" parent="Theme.AppCompat.Light.Dialog">
<item name="windowNoTitle">true</item>
</style>
Activity code - just extended from AppCompatActivity
I was trying to fix using some another settings:
<item name="android:windowIsTranslucent">true</item>
<item name="android:windowBackground">#android:color/transparent</item>
<item name="android:windowContentOverlay">#null</item>
<item name="android:windowNoTitle">true</item>
<item name="android:windowIsFloating">true</item>
<item name="android:backgroundDimEnabled">false</item>
Without any success :(
I think you need to sub theme Theme.AppCompat.Light.Dialog.Alert not Theme.AppCompat.Light.Dialog, so your theme will be like:
<style name="AppTheme.Popup" parent="Theme.AppCompat.Light.Dialog.Alert">
<item name="windowNoTitle">true</item>
</style>
I would like to add the support actionbar to one of my activities, I previously had been using the theme.translucent with this activity but in order to make the support actionbar work I needed to inherit the Theme.AppCompat, I need to maintain a translucent theme in this activity but unfortunately there isnt a Theme.AppCompat.translucent that i can see by default, is there any way that this can be done?
You can create a new set of styles to use which have the same properties as Theme.Translucent from themes.xml.
Add the following to your styles.xml file:
<style name="Theme.AppCompat.Translucent">
<item name="android:windowNoTitle">true</item>
<item name="android:windowBackground">#android:color/transparent</item>
<item name="android:colorBackgroundCacheHint">#null</item>
<item name="android:windowIsTranslucent">true</item>
<item name="android:windowAnimationStyle">#android:style/Animation</item>
</style>
You can change the prefix Theme.AppCompat to something else if you want to inherit other things from the theme such as dialog styles etc. For example, a name like Theme.AppCompat.Light.Translucent would have the properties of the Light theme.
To use the new style, set the theme property to #style/Theme.AppCompat.Translucent
<activity
android:name=".TranslucentActivity"
android:theme="#style/Theme.AppCompat.Translucent" >
</activity>
Parama ,
<style name="Theme.AppCompat.Translucent" parent="Theme.AppCompat.NoActionBar">
<item name="android:windowNoTitle">true</item>
<item name="android:windowBackground">#android:color/transparent</item>
<item name="android:colorBackgroundCacheHint">#null</item>
<item name="android:windowIsTranslucent">true</item>
<item name="android:windowAnimationStyle">#android:style/Animation</item>
</style>
This should be the style header if you want the toolbar to disappear.you can use any parent theme which has NoActionBar for other effects.
Hope this helps
If we use Translucent for transparent activity.
It raises other issues - the color of Msgbox (now white previously black), Default dialog color, the spinners do drop down but do not show the underline and drop-down arrow. The spinners are color black text black; drop-down white drop-down text black and etc.
To overcome this problem, you can just use below code
In style
<style name="Theme.AppCompat.Transparent.NoActionBar" parent="Theme.AppCompat.Light.NoActionBar">
<item name="android:windowIsTranslucent">true</item>
<item name="android:windowBackground">#android:color/transparent</item>
<item name="android:windowContentOverlay">#null</item>
<item name="android:windowNoTitle">true</item>
<item name="android:windowIsFloating">false</item>
<item name="android:backgroundDimEnabled">false</item>
</style>
In manifest file
<activity
android:name=".activity.YourActivityName"
android:theme="#style/Theme.AppCompat.Transparent.NoActionBar" />
I hope it will help
Thanks
Cameron's answer is a nice hack , but it produced a floating action bar and tinted my status bar, which i didn't wanted . So i added more xml attributes for making status bar transparent(for sdk >=19) and used java code for making action bar invisible.
mainActivity.java :
public class MainActivity extends AppCompatActivity {
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
getSupportActionBar().hide();
...
}
...
}
styles.xml
<style name="AppTheme.TranslucentBG">
<item name="android:windowNoTitle">true</item>
<item name="android:windowBackground">#android:color/transparent</item>
<item name="android:colorBackgroundCacheHint">#null</item>
<item name="android:windowIsTranslucent">true</item>
<item name="android:windowAnimationStyle">#android:style/Animation</item>
<item name="android:windowTranslucentStatus">true</item>
<item name="android:windowTranslucentNavigation">true</item>
</style>
manifest.xml
<application
android:icon="#mipmap/ic_launcher"
...
android:theme="#style/AppTheme"
...
>
<activity android:name=".MainActivity"
android:theme="#style/AppTheme.TranslucentBG"
...
>
...
</activity>
</application>
I want to get rid of the white color during the short period when my app is launching but the content isn't displayed, yet.
My main activity is using a style (from the Manifest) that extends #style/Theme.Sherlock.Light.DarkActionBar with the background set to <item name="android:background">#android:color/transparent</item>. Nowhere in my layout do I use a white background color, yet it appears for a brief moment during app launch.
In the HierarchyViewer I exported the layers and checked back that there is really no white solid in the layout hierarchy.
What setting controls the background color before the layout is drawn? Thanks.
There's another background attribute in your theme - windowBackground, and you implicitly set it to white by inheriting your style from #style/Theme.Sherlock.Light.DarkActionBar (notice the .Light. part in the name).
You can either use dark version of theme or set it explicitly by including windowBackground in your style definition:
<item name="android:windowBackground">#color/your_color</item>
<style name="Theme.Transparent" parent="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>
<item name="android:windowIsTranslucent">true</item>
</style>
Or you can use drawable. I created a theme for my spash screen like as below :)
<style name="SceneTheme.Light.NoActionBar" parent="Theme.MaterialComponents.Light.NoActionBar">
<item name="colorPrimary">#color/colorPrimary</item>
<item name="colorPrimaryDark">#color/colorPrimaryDark</item>
<item name="colorAccent">#color/colorAccent</item>
</style>
<style name="SceneTheme.Light.NoActionBar.Transparent.StatusBar" parent="SceneTheme.Light.NoActionBar">
<item name="android:windowDrawsSystemBarBackgrounds">true</item>
<item name="android:statusBarColor">#android:color/transparent</item>
<item name="android:windowTranslucentStatus">true</item>
<item name="android:windowBackground">#drawable/bg_splash</item>
</style>