Ad
Can You Make An Alert Dialog Take 100% Of The Width On Screen?
I am trying to make my alert dialog (not custom dialog), take up 100% of the width on screen from end to end ,but even if I set it to match parent width, it still takes up like 90% of the width with some gaps on left and right(also i m trying to set the gravity to bottom and still theres some space from bottom too) . not sure if I do need a custom dialog to do this or is there any way an alert dialog can take up the entire screen width without being custom? Any ideas? Here's my code for reference:
AlertDialog.Builder builder = new AlertDialog.Builder(getMyActivity());
AlertDialog dialog = builder.create();
dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
dialog.getWindow().setLayout(MATCH_PARENT, WRAP_CONTENT);
dialog.getWindow().getAttributes().windowAnimations = R.style.DialogAnimation;
WindowManager.LayoutParams wmlp = dialog.getWindow().getAttributes();
dialog.getWindow().setGravity(Gravity.BOTTOM);
wmlp.gravity = Gravity.BOTTOM ;
dialog.show();
Ad
Answer
Try Below code
AlertDialog.Builder alertDialog = new AlertDialog.Builder(this,android.R.style.Theme_Black_NoTitleBar_Fullscreen);
or add custom theme in your style.xml
<style name="DialogTheme" parent="android:Theme.Dialog">
<item name="android:layout_width">match_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>
while inflating your dialogue set this theme
dialog = new Dialog(this, R.style.DialogTheme);
Ad
source: stackoverflow.com
Related Questions
- → should I choose reactjs+f7 or f7+vue.js?
- → Phonegap Android write to sd card
- → Local reference jquery script in nanohttpd (Android)
- → Click to navigate on mobile devices
- → How to allow api access to android or ios app only(laravel)?
- → Access the Camera and CameraRoll on Android using React Native?
- → React native change listening port
- → What is the default unit of style in React Native?
- → Google play market autocomplete icon
- → Warning: Each child in an array or iterator should have a unique "key" prop. Check the render method of `ListView`
- → Using Laravel with Genymotion
- → react native using like web-based ajax function
- → react native pdf View
Ad