How to set dialog (Custom) a glittering effect? - java

In my android app, I've designed some layouts to set the custom dialog. But I face some problems while making border with glittering effect.
I've set the following style to my dialog:
<style name="MyDialog" parent="android:Theme.Holo.Light.Dialog">
<item name="android:windowTitleStyle">#style/DialogWindowTitle</item>
<item name="android:windowFrame">#color/transparent</item>
<item name="android:windowNoTitle">true</item>
<item name="android:windowFrame">#drawable/alertbgc</item>
In the java snippet,I added the lines as follows:
final Dialog mydialog= new Dialog(this,R.style.MyDialog);
mydialog.setContentView(R.layout.mylayout);
But with this snippets I'm getting very dark background (I used nine patch images too, but no use). Please help me providing your ideas.
Thanks in advance

Related

How to full screen activity with transparent status bar?

I would like to show transparent status bar without using immersive mode. Just like the image below. I have tried lot of solutions however I'm unable to achieve this. Please refer the image below.
This is the output I'm looking for. Please note here that I'm looking for solution which doesn't affect navigation bar at all. I don't want any modifications to navigation bar just like image below.
Thanks in advance!
My theme:
<style name="AppTheme" parent="#style/Theme.MaterialComponents.DayNight.NoActionBar.Bridge">
<item name="android:colorEdgeEffect">#color/color_subtitle_text</item>
<item name="android:windowDrawsSystemBarBackgrounds">true</item>
<item name="android:windowTranslucentStatus">true</item>
try this:
getWindow().setFlags(WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS, WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS);
You can use like this.
For Kotlin:
window.setFlags(WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS, WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS)
For Java:
getWindow().setFlags(WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS, WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS);

Change the Color of Status Bar TEXT and icon in API 30

I want the icons and text on the StatusBar to be black. I have tried in various ways, but obviously it is a problem because API 30 does not respond to the already existing solutions I found on the net. Can anyone give specific instructions on how to change the color of icons and text. Please note that I am using Theme.AppCompat.DayNight.DarkActionBar
I ask for your help.
This is what it should look like:
My style.xml
<style name="AppTheme" parent="Theme.AppCompat.DayNight.DarkActionBar">
<item name="colorPrimary">#android:color/transparent</item>
<item name="colorPrimaryDark" targetApi="23">#android:color/transparent</item>
<item name="android:windowTranslucentStatus">true</item>
<item name="colorAccent">#color/colorAccent</item>
<item name="customBackgroundColor">#android:color/transparent</item>
<item name="customPrimaryTextColor">#000000</item>
</style>
This code changes the background color of the StatusBar, but I needs to change the color of the text and icons on the StatusBar.
if (Build.VERSION.SDK_INT >= 21) {
Window window = this.getWindow();
window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
window.setStatusBarColor(this.getResources().getColor(R.color.primary_color));
}
As per documentation: you need to use WindowInsetsController to set setAppearanceLightStatusBars which changes the foreground color of the status bars (icons & text):
new WindowInsetsControllerCompat(getWindow(),
getWindow().getDecorView()).setAppearanceLightStatusBars(true);
UPDATE
No need to the below, also they have deprecated APIs:
if (Build.VERSION.SDK_INT >= 21) {
Window window = this.getWindow();
window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
}
To make the status bar light & icons/text dark on API Level 30:
Method 1: Programmatically:
new WindowInsetsControllerCompat(getWindow(),
getWindow().getDecorView()).setAppearanceLightStatusBars(true);
getWindow().setStatusBarColor( ResourcesCompat.getColor(getResources(), R.color.primary_color, null)); // Or Color.WHITE make it white
Method 2: In themes.xml:
add this in your app's theme:
<item name="android:windowLightStatusBar">true</item>
<item name="android:statusBarColor">#color/primary_color</item>

Android: How can I remove the title bar without removing splitactionbar at the bottom?

Yeah pretty much the title. I tried different android styles, but I lose both the title and the action bar at the bottom. I also tried using
getActionBar().setDisplayShowTitleEnabled(false);
getActionBar().setHomeButtonEnabled(false);
getActionBar().setDisplayUseLogoEnabled(false);
But with this I get a blank title bar. I want to remove the title bar completely. Does anyone know a solution for this? Thanks!
If you are using Theme.Holo.Light and want to use the Theme.Holo.Light.NoTitleBarBar variant on pre 3.2 devices you can add this to your styles.xml:
<style name="NoTitleBar" parent="#android:style/Theme.Holo.Light">
<item name="android:windowActionBar">true</item>
<item name="android:windowNoTitle">false</item>
and then set it as your activity's theme:
<activity android:theme="#style/NoTitleBar" ... />
In your oncreate do this
requestWindowFeature(Window.FEATURE_NO_TITLE);
setContentView(R.layout.main);
I found a solution: It is pretty much
<style name="MyActionBarStyle" parent="#android:style/Widget.Holo.ActionBar">
<item name="android:displayOptions"></item>
<item name="android:height">0dip</item>
</style>
I just sized it to zero and it works.

How do you change the action bar text color without Sherlock?

I don't want to use the Sherlock action bar, but I do want to change the text color. I know how to change the actual text
ActionBar actionBar = getActionBar();
actionBar.setTitle("Whatever");
but I don't know how to change the color. I have also tried this:
<style name="ActionBar.Solid.Example" parent="#android:style/Widget.Holo.Light.ActionBar.Solid">
<item name="android:background">#drawable/ab_background_textured_example</item>
<item name="android:backgroundStacked">#drawable/ab_stacked_solid_example</item>
<item name="android:backgroundSplit">#drawable/ab_background_textured_example</item>
<item name="android:progressBarStyle">#style/ProgressBar.Example</item>
<item name="android:textColor">#android:color/white</item>
</style>
From the "Android Holo Colors Generator", I added the line
<item name="android:textColor">#android:color/white</item>
but it didn't do anything.
Any help? Thanks!
Seems you must use
<item name="android:actionBarStyle">#style/Widget.MyApp.ActionBar</item>
Here is solved the similiar problem:
Action Bar Sherlock 4 title text colour - where am I going wrong?

Android action bar overlay & hidden by default in xml

I need to have the action bar hidden on application start. Then, after some user action, it has to show up again overlaying the content. Currently I turn it off in a custom style by setting <item name="android:windowActionBar">false</item>, and then call
getWindow().requestFeature(Window.FEATURE_ACTION_BAR);
getWindow().requestFeature(Window.FEATURE_ACTION_BAR_OVERLAY);
getActionBar().hide();
in onCreate() of the activity.
That seems a little awkward though. Can I do all of it in xml configs?
I don't know about the hiding part, but you cna style the ActionBar as an overlay in your apps theme like this:
<style name="AppTheme" parent="#style/Theme.AppCompat">
<item name="android:windowNoTitle">false</item>
<item name="android:windowFullscreen">true</item>
<item name="android:windowActionBarOverlay">true</item>
</style>

Categories