3

I am showing a AlertDialog which is showing some list data but the title of Dialog and data are not showing in Same alignment there is some extra padding given from left to AlertDialog's title and Dialog looks like this :

enter image description here

Code :

 AlertDialog.Builder builder = new AlertDialog.Builder(this);
    builder.setTitle("Search on the basis of :");
    builder.setCancelable(false);
    final ArrayAdapter<String> arrayAdapter = new ArrayAdapter<>(OrdersActivity.this, android.R.layout.select_dialog_item);
    arrayAdapter.add("Order Name");
    arrayAdapter.add("Order Date");
    builder.setAdapter(arrayAdapter, new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int which) {
            String strName = arrayAdapter.getItem(which);
            adapter.searchType(strName);
        }
    });
    builder.show();

Can anyone tell me How to remove that extra padding from dialog title ?

Kapil Rajput
  • 11,429
  • 9
  • 50
  • 65

2 Answers2

-1

Use this for the setting up the reduce the padding of alertdialogbox setPadding(0, 0, 0, 0);

Dipak
  • 1
  • 4
-1

Try this:

Change your line:

AlertDialog.Builder builder = new AlertDialog.Builder(this);

to

AlertDialog.Builder builder = new AlertDialog.Builder(this, R.style.DialogTheme);

and add in your styles.xml with parent corresponding to your theme version.

<style name="DialogTheme" parent="Theme.AppCompat.Light.Dialog">
    <!-- Customize your theme here. -->
    <item name="android:windowBackground">@null</item>
    <item name="android:windowNoTitle">true</item>
    <item name="android:windowIsFloating">false</item>
</style>