I am trying to create a splash screen for my app. The problem is it first renders empty layout with default title bar and then fades in my image.
This is all I have onCreate
super.onCreate(savedInstanceState);
this.requestWindowFeature(Window.FEATURE_NO_TITLE);
this.setContentView(R.layout.activity_splash);
Attempted solution from switching activities without animation
Also tried to set window attributes
WindowManager.LayoutParams lp = this.getWindow().getAttributes();
lp.windowAnimations = lp.windowAnimations | android.R.attr.windowDisablePreview;
this.getWindow().setAttributes(lp);
neither made any visible difference.
you can get rid of titlebar by setting theme for your splash activity. Add this to declaration of activity in your Manifest
android:theme="#android:style/Theme.NoTitleBar"
Related
When trying to change an icon to a downloaded drawable (or actually changing to any other icon during runtime), the icon changes once on the ActionBar.
I actually want to remove the ActionBar and leave only the bottomnav (tabs) for navigation, yet whatever i'm doing the icon changes only on the ActionBar.
The item inside bottom_nav_menu.xml:
<item
android:id="#+id/navigation_notifications"
android:icon="#drawable/ic_dashboard_black_24dp"
android:title="#string/title_notifications"
app:showAsAction="ifRoom"/>
The code that changes the icon:
#Override
public boolean onPrepareOptionsMenu (Menu menu){
menu.clear();
getMenuInflater().inflate(R.menu.bottom_nav_menu, menu);
menu.getItem(2).setIcon(this.bitmap_pic);
Log.e(TAG, "Icon Changed");
return super.onPrepareOptionsMenu(menu);
}
The result - Icon stays blank on BottomNav but appears on the ActionBar.
Expected result: BottomNav icon will be the image that shown on the top right.
Thanks
EDIT!
Issue was fixed after inflating the main_activity layout that contains the BottomNavView
Now the problem the picture isn't showing properly, attached a screenshot (Image is grey instead of showing the icon like in the ActionBar in the first picture):
Edit 2
Icon is still grey instead of showing the bitmap picture.
Added:
MenuItemCompat.setIconTintMode(bottomNavigationView.getMenu().getItem(2), PorterDuff.Mode.CLEAR);
But it still shows up like in the picture below
Edit 3
Fixed the issue using:
bottomNavigationView.setItemIconTintList(null);
I'm not sure if onPrepareOptionsMenu invoked for bottom navigation bar.
You should have to update navigation menu icon from onCreate method of that Activity.
Refer below code,
val menu = navigation.menu
val menuItem = menu.findItem(R.id.navigation_notifications) // find particular menu-item using its ID.
menuItem?.icon = this.bitmap_pic
Solution for Gray icon tint,
add below line.
MenuItemCompat.setIconTintMode(menuItem, PorterDuff.Mode.DST)
I am trying to show a full screen alert dialog like the one on the material design website: Full Screen Material Alert Dialog
I created a
new MaterialAlertDialogBuilder(this)
.setTitle("Title")
.setMessage("Message")
.setPositiveButton("Yes", null)
.show();
which works perfectly. However I want the dialog to appear as full screen with the toolbar and x button, so I can place EditTexts inside the dialog.
I tried using the other constructor MaterialAlertDialogBuilder(context, theme) but I cannot find a theme that will make the dialog appearance full screen. Is there a theme that makes the dialog full screen or do I have to do something else to make it full screen?
try this
MaterialAlertDialogBuilder dialog = new MaterialAlertDialogBuilder(this, android.R.style.Theme_DeviceDefault_NoActionBar_Fullscreen);
I am using following code to hide status bar,
if (Build.VERSION.SDK_INT < 16) {
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
} else {
View decorView = getWindow().getDecorView();
int uiOptions = View.SYSTEM_UI_FLAG_FULLSCREEN;
decorView.setSystemUiVisibility(uiOptions);
}
It works but
when the Activity starts it shows a white background at top for a couple of seconds. Is there any way to avoid that?
Does anybody know how to hide it with animation (Moving upwards) like Whatsapp hides status bar when you click on Status image?
If I show a ProgressDialog or AlertDialog and then dismiss it and come back to Activity then the status bar becomes visible again. How to avoid it so that status bar remains invisible always?
For those who fight with this issue, use the following code:
if (Build.VERSION.SDK_INT < 16) {
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
} else {
View decorView = getWindow().getDecorView();
int uiOptions = View.SYSTEM_UI_FLAG_FULLSCREEN | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN;
decorView.setSystemUiVisibility(uiOptions);
}
Make sure you are finishing the previous activity after starting new activity. If you call finish() before startActivity() it is chance of getting white screen. (OR) If white screen appears in launcher activity it is because of enabling Insta Run in Android Studio. Refer this link about Insta Run.
For Whats App like animation you have to do create your layout with coordinator layout , collapsing toolbar. Using parallax scrolling effect you can hide image as like whats app.
For tutorial refer here link
After calling AlertDialog your activity is Resumes, so you hide the status bar on OnCreate() only if you open any dialogs and back to activity it is called OnResume() in this the super.onResume will called and the activities basic will reset again. So you call that status bar hide method in OnResume() method also.
I am showing a custom dialog in an activity of which the orientation is set to landscape. But the orientation is getting changed to portrait mode from the inital landscape(only the dialog, below activity remains in landscape mode). This is happening without any outside action like tilting the tablet or something.
I could not find any help in fixing the orientation of dialog anywhere.
Any ideas?
Dialog mDialog = new Dialog(MainActivity.this);
mDialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
mDialog.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN);
mDialog.setContentView(R.layout.alert);
mDialog.show();
This is the code used for showing the dialog.
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="300dip"
android:layout_height="300dip"
android:background="#drawable/alert_bg"
android:orientation="vertical" >
------------------------------
---------------------------
</LinearLayout>
This is the xml element parent tag used.
If you are using an Activity as a dialog then you can set
android:screenOrientation="landscape"
in your manifest file.
If you are using custom dialog then you can use
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
before you use setContentView(); method.
Check out this picture:
WhoKnew title and WK? Icon http://puu.sh/5Ejo5.png
See the icon and title there? How do I go about removing that?
I'm not using any of the drag and drop or xml editing at all in eclipse for this project, because I have to dynamically create an arbitrary amount of buttons/text, and whatnot.
Basically, I've been going about it by doing something like this..
public createMainMenu(){
//make layout
LinearLayout layout = new LinearLayout(this);
layout.setOrientation(LinearLayout.VERTICAL);
layout.setBackgroundColor(backgroundColor);
//make/add text to layout
menuText.setText("Who Knew?");
menuText.setId(20001);
menuText.setTextSize(36);
menuText.setTextColor(textColor);
layout.addView(menuText);
//make a scrollview, then add the layout to the scrollview
ScrollView sc = new ScrollView(this);
sc.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT));
sc.setFillViewport(true);
sc.addView(layout);
//set content view to the scrollview
setContentView(sc);
}
Hopefully, I'm on the right track here on how I should be going about this. The app I have is working fine, I just need to get rid of that icon/title bar, if possible. I guess it's not a gamebreaker, but it's a bit annoying.
you can use this in your java class
requestWindowFeature(Window.FEATURE_NO_TITLE);
Add this to your manifest:
android:theme="#android:style/Theme.Light.NoTitleBar"