In my application I need to show a sheet dialog sliding from top of the whole screen. Now I have a problem, my sheet dialog is showing but under status bar.
Actually view of top sheet dialog
My target is to make a background of status bar the same as sheet dialog (purple) and normally have a clock, battery status etc.
My code:
final Dialog dialog = new Dialog(MainAccountView.this);
dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
dialog.setContentView(R.layout.sheet_short_settings);
dialog.show();
dialog.getWindow().clearFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
dialog.getWindow().setLayout(ViewGroup.LayoutParams.MATCH_PARENT,
ViewGroup.LayoutParams.WRAP_CONTENT);
dialog.getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
dialog.getWindow().getAttributes().windowAnimations =
R.style.TopSheet_DialogAnimation;
dialog.getWindow().setGravity(Gravity.TOP);
I tried on few devices so problem is on the code. XML layout for sheet_short_settings starting on the top of whole screen. When I turn on a "Show system UI" the status bar have a background of my layout, but have the dark transparent color.
Thanks in advance
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 have set the background color of system bottomNavigation using:
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP){
getWindow().setNavigationBarColor(getResources().getColor(R.color.navcolor));
}
Which is working properly !!!
But the problem is when i open a custom bottomsheet, the background color of bottomNavigation gets changed to black.
Code to show bottomsheet:
BottomSheetDialog dialog = new BottomSheetDialog(MainActivity.this);
dialog.setContentView(R.layout.sortfilterbottomsheet);
dialog.setCanceledOnTouchOutside(true);
dialog.show();
BottomNavigation when bottomsheet is closed:
BottomNavigation when bottomsheet is opened:
Can somebody help ?
So finally I got my answer.
We need to write:
<item name="android:navigationBarColor" tools:targetApi="21">#color/navcolor</item>
in themes.xml file
It will change the background color of system bottom naivgation.
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 want to create wallpaper app.
i want user click image show whole image and visible set wallpaper button.
like this pictures
after licked like this
The problem is to show set wallpaper button when image clicked and show whole image.
Thank you!
to display all image display activity use recyclerview with GridLayoutManagerlike this
private GridLayoutManager lLayout;
lLayout = new GridLayoutManager(MainActivity.this, 2);
recyclerview.setLayoutManager(lLayout);
check this link for how to use recyclerview with GridLayoutManager
for display image create a new activity and pass the image when user select image from recyclerview to that activity and display
Ask me in case of any query
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"