Android support library added TextInputLayout adding several features like floating label and password toggle visisbilty
My problem is How to customize passwordVisisbilityDrawable so my own icons for visible and hidden state will be displayed.
Also when I enable passwordToggleVisibility, height will increase.
for change drawable, create a selector like below
password_toggle_drawable.xml
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="#drawable/ic_password_visible" android:state_checked="true"/>
<item android:drawable="#drawable/ic_password_hidden"/>
</selector>
then assign to TextInputLayout like below:
<android.support.design.widget.TextInputLayout
android:id="#+id/PasswordLayout"
xmlns:android="http://schemas.android.com/apk/res/android"
app:passwordToggleEnabled="true"
**app:passwordToggleDrawable="#drawable/password_toggle_drawable"**
xmlns:app="http://schemas.android.com/apk/res-auto">
<android.support.design.widget.CommonTextInputEditText
android:id="#+id/PasswordEditText"
android:padding="0dp"
android:gravity="center"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="textPassword"/>
</android.support.design.widget.TextInputLayout>
for height, I used below code after inflating:
CheckableImageButton text_input_password_toggle = (CheckableImageButton) PasswordLayout().findViewById(android.support.design.R.id.text_input_password_toggle);
text_input_password_toggle.setMinimumHeight(0);
PasswordEditText().setMinHeight(0);
PasswordEditText().setMinimumHeight(0);
Related
I have a bottomnavigation view that sets an icon depending on the state if it's checked or not.
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<item
android:id="#+id/icon_tree"
android:title="Tree"
android:icon="#drawable/bottomnav_icon_home">
</item>
</menu>
bottomnav_icon_home:
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="#drawable/icon_home_black" android:state_checked="false"/>
<item android:drawable="#drawable/icon_home_green" android:state_checked="true"/>
</selector>
How ever bottomnavigation is automatically highlighting the icon when android:state_checked is true.
How do I completely disable bottomnavigation's icon selection highlight?
I've tried setting app:itemIconTint="#drawable/bottom_navigation_selector" to #null however that doesn't work
<com.google.android.material.bottomnavigation.BottomNavigationView
android:id="#+id/bottom_navigation"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:menu="#menu/bottom_navigation_menu"
android:background="#color/colorWhite"
app:itemTextColor="#drawable/bottom_navigation_selector"
app:itemIconSize="28dp"
app:itemIconTint="#drawable/bottom_navigation_selector"
app:labelVisibilityMode="labeled"/>
bottom_navigation_selector:
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_checked="true"
android:color="#color/forestGreen" />
<item android:color="#color/colorBlack" />
</selector>
If i understood you right, android by default sets a tint on your bottom navigation icons on selection and you would like it to be removed right.
I know how to do that in your java class not xml though.
You'll need to set setItemIconTintList method of your BottomNavigationView to null. So in wherever you set the layout write code as :
BottomNavigationView btmNav = findViewById(R.id.bottom_navigation);
btmNav.setItemIconTintList(null);
Let us know if this works for you.
try to add this line in the dimens.xml
<dimen name="design_bottom_navigation_active_text_size" tools:override="true">#dimen/design_bottom_navigation_text_size</dimen>
You can create custom style.
There are two steps.
1- Create custom bottom_navigation_bar_icon_color.xml in drawable folder. This is the selector showed the icon highlighted or default. So you can highlight all icons or show them as default. Choose one of the following when creating your bottom_navigation_bar_icon_color.xml
Icons highlighted: <item android:alpha="1.0" android:color="?attr/colorOnPrimary" android:state_checked="true"/>
Icons default: <item android:alpha="0.6" android:color="?attr/colorOnPrimary"/>
bottom_navigation_bar_icon_color.xml
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:alpha="0.6" android:color="?attr/colorOnPrimary"/>
</selector>
2- Add following custom style to themes.xml or styles.xml. bottom_navigation_bar_icon_color used in itemIconTint and itemTextColor
<style name="BottomNavigationThemeCustom">
<item name="enforceTextAppearance">true</item>
<item name="enforceMaterialTheme">true</item>
<item name="android:background">?attr/colorPrimary</item>
<item name="itemIconTint">#drawable/bottom_navigation_bar_icon_color</item>
<item name="itemRippleColor">#color/mtrl_navigation_bar_colored_ripple_color</item>
<item name="itemTextAppearanceInactive">?attr/textAppearanceCaption</item>
<item name="itemTextAppearanceActive">?attr/textAppearanceCaption</item>
<item name="itemTextColor">#drawable/bottom_navigation_bar_icon_color</item>
</style>
3- Use your new style for bottomNavigationBar
<com.google.android.material.bottomnavigation.BottomNavigationView
android:id="#+id/bottomNavigation"
style="#style/BottomNavigationThemeCustom"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:visibility="visible"
app:labelVisibilityMode="unlabeled"
app:menu="#menu/bottom_menu" />
4- If you want to hide the bottomNavigationBar on Scroll add following attribute to bottomNavigationBar
app:layout_behavior="com.google.android.material.behavior.HideBottomViewOnScrollBehavior"
You consider create your own implementation of bottomNavigation?
When I implement the Google BottomNavigationView, I got a lot of issues, so I create a new one like this:
<LinearLayout android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_alignParentBottom="true">
<View android:layout_width="match_parent"
android:layout_height="1dp"
android:background="#color/grayBottomNavigationDelimiter"/>
<RadioGroup android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#color/colorNavigationBar"
android:orientation="horizontal">
<android.support.v7.widget.AppCompatRadioButton
android:id="#+id/homeButton"
android:drawableTop="#drawable/ic_home_black_24dp"
android:text="#string/navigation_home_text"
style="#style/RadioButtonStyle"/>
...
So, can see this is easier than imagine, did you?
To add it through XML: For the attribute IconItemTint and ItemTextColor, simply use the same color that you've used for icons by default. In that case, the highlight color and default color will be the same. Will give you the required ripple effect on selecting but highlight wont be visible.
For my black color icon, I've used this:
app:itemIconTint="#color/black"
app:itemTextColor="#000000"
My entire bottom nav looks like this:
<com.google.android.material.bottomnavigation.BottomNavigationView
android:id="#+id/bottomNavigationView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?android:attr/windowBackground"
app:itemIconTint="#color/black"
app:itemTextColor="#000000"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:menu="#menu/bottom_nav_more_options_menu" />
I can't seem to get rid of the black underline from Exposed Dropdown Menu done according to material design guide in my android UI.
The dropdown looks like this:
I have tried setting background to null, transparent or custom shape. app:boxBackgroundMode="none" doesn't work either.
<com.google.android.material.textfield.TextInputLayout
android:id="#+id/spinner_age"
style="#style/Widget.MaterialComponents.TextInputLayout.FilledBox.ExposedDropdownMenu"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#drawable/bg_rounded_button"
android:hint="Age">
<AutoCompleteTextView
android:id="#+id/age_dropdown"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#android:color/transparent"/>
</com.google.android.material.textfield.TextInputLayout>
Ideally the dropdown would look like a button without the underline. How do I get rid of it?
Please change your this line
android:background="#android:color/transparent"
With
android:background="#00000000"
Make background = null
<AutoCompleteTextView
android:id="#+id/age_dropdown"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#null"/>
just add this line to remove the underline
android:inputType="textNoSuggestions"
Just use the standard style #style/Widget.MaterialComponents.TextInputLayout.FilledBox.ExposedDropdownMenu and
You don't need to use a custom background shape, you can just use the
app:boxCornerRadius* attributes to define the rounded shape.
Something like:
<com.google.android.material.textfield.TextInputLayout
style="#style/Widget.MaterialComponents.TextInputLayout.FilledBox.ExposedDropdownMenu"
app:boxCornerRadiusBottomEnd="32dp"
app:boxCornerRadiusTopEnd="32dp"
app:boxCornerRadiusBottomStart="32dp"
app:boxCornerRadiusTopStart="32dp"
app:boxStrokeColor="#color/myselector"
...>
<AutoCompleteTextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#null"
/>
</com.google.android.material.textfield.TextInputLayout>
To change the color of the line under the component, you have to change the app:boxStrokeColor attribute. Just customize the selector as you prefer:
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:alpha="0" android:color="?attr/colorOnSurface" android:state_hovered="true"/>
<item android:alpha="0" android:color="?attr/colorOnSurface" android:state_enabled="false"/>
<item android:alpha="0" android:color="?attr/colorOnSurface"/>
</selector>
This is the result:
Pay attention to this note in doc:
Note: When using a filled text field with an EditText child that is not a TextInputEditText, make sure to set the EditText's android:background to #null. This allows TextInputLayout to set a filled background on the EditText.
Alternative:
With the new version 1.1.0 you can also use the shapeAppearanceOverlay attribute to customize the shape of your component.
Just use:
<com.google.android.material.textfield.TextInputLayout
style="#style/MyFilledBox_ExposedDropdownMenu
...>
<AutoCompleteTextView
android:background="#null"
... />
</com.google.android.material.textfield.TextInputLayout>
and this style:
<!-- Rounded -->
<style name="MyFilledBox_ExposedDropdownMenu" parent="#style/Widget.MaterialComponents.TextInputLayout.FilledBox.ExposedDropdownMenu">
<item name="shapeAppearanceOverlay">#style/ShapeAppearanceOverlay.MyApp.TextInputLayout.Rounded</item>
<item name="boxStrokeColor">#color/myselector</item>
</style>
<style name="ShapeAppearanceOverlay.MyApp.TextInputLayout.Rounded" parent="">
<item name="cornerFamily">rounded</item>
<item name="cornerSize">32dp</item>
</style>
Setting boxStrokeWidth = 0dp would solve it
There appears to be left padding automatically added when using a TextInputLayout to wrap an EditText as you can see in the screenshot below.
There is no padding added to the EditText in the layout XML, but when the view is rendered there appears to be left padding on the EditText. You can see this when comparing the TextView below the TextInputLayout.
How do I disable this left padding from being added?
Thank you!
You can just set the start and end padding on the inner EditText to 0dp.
<com.google.android.material.textfield.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<com.google.android.material.textfield.TextInputEditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingStart="0dp"
android:paddingEnd="0dp" />
</com.google.android.material.textfield.TextInputLayout>
Here's a screenshot with Show Layout Bounds turned on so you can see that the hints go all the way to the edge of the view.
With the TextInputLayout included in the Material Components Library you can use a custom style to reduce the padding.
Just use something like:
<com.google.android.material.textfield.TextInputLayout
....
android:hint="Hint text"
style="#style/My.TextInputLayout.FilledBox.Padding" >
Then you can define a custom style for the EditText using the materialThemeOverlay attribute:
<style name="My.TextInputLayout.FilledBox.Padding" parent="Widget.MaterialComponents.TextInputLayout.FilledBox">
<item name="materialThemeOverlay">#style/MyThemeOverlayFilledPadding</item>
</style>
<style name="MyThemeOverlayFilledPadding">
<item name="editTextStyle">#style/MyTextInputEditText_filledBox_padding</item>
</style>
<style name="MyTextInputEditText_filledBox_padding" parent="#style/Widget.MaterialComponents.TextInputEditText.FilledBox">
<!-- left and right padding -->
<item name="android:paddingStart" ns2:ignore="NewApi">2dp</item>
<item name="android:paddingEnd" ns2:ignore="NewApi">2dp</item>
<item name="android:paddingLeft">2dp</item>
<item name="android:paddingRight">2dp</item>
<!-- top and bottom padding -->
<item name="android:paddingTop">28dp</item>
<item name="android:paddingBottom">12dp</item>
</style>
Here the final result:
Note: it requires at least the version 1.1.0 of the Material Components library.
Make the padding 0dp like this
<com.google.android.material.textfield.TextInputLayout
style="#style/UserTextLayout"
android:layout_height="50dp"
app:boxBackgroundMode="none">
<com.google.android.material.textfield.TextInputEditText
android:id="#+id/emailEditText1"
style="#style/UserEditText"
android:layout_width="match_parent"
android:hint="MATRIC NUMBER"
android:inputType="number"
android:maxLines="1"
android:padding="0dp"
android:text="20181766" />
</com.google.android.material.textfield.TextInputLayout>
Here is the result
I managed to remove that left space by making a copy of the original theme of the edittext background
res/drawable/my_edit_text_material.xml
<?xml version="1.0" encoding="utf-8"?>
<inset xmlns:android="http://schemas.android.com/apk/res/android"
android:insetLeft="#dimen/abc_edit_text_inset_horizontal_material"
android:insetRight="#dimen/abc_edit_text_inset_horizontal_material"
android:insetTop="#dimen/abc_edit_text_inset_top_material"
android:insetBottom="#dimen/abc_edit_text_inset_bottom_material">
<selector>
<item android:state_enabled="false" android:drawable="#drawable/abc_textfield_default_mtrl_alpha"/>
<item android:state_pressed="false" android:state_focused="false" android:drawable="#drawable/abc_textfield_default_mtrl_alpha"/>
<item android:drawable="#drawable/abc_textfield_activated_mtrl_alpha"/>
</selector>
</inset>
res/drawable-v21/my_edit_text_material.xml
<?xml version="1.0" encoding="utf-8"?>
<inset xmlns:android="http://schemas.android.com/apk/res/android"
android:insetTop="#dimen/abc_edit_text_inset_top_material"
android:insetBottom="#dimen/abc_edit_text_inset_bottom_material">
<selector>
<item android:state_enabled="false">
<nine-patch android:src="#drawable/abc_textfield_default_mtrl_alpha"
android:tint="?attr/colorControlNormal"
android:alpha="?android:attr/disabledAlpha"/>
</item>
<item android:state_pressed="false" android:state_focused="false">
<nine-patch android:src="#drawable/abc_textfield_default_mtrl_alpha"
android:tint="?attr/colorControlNormal"/>
</item>
<item>
<nine-patch android:src="#drawable/abc_textfield_activated_mtrl_alpha"
android:tint="?attr/colorControlActivated"/>
</item>
</selector>
</inset>
in the two files delete:
android:insetLeft="#dimen/abc_edit_text_inset_horizontal_material"
android:insetRight="#dimen/abc_edit_text_inset_horizontal_material"
Create a new style for your editText and add it as background
/res/values/styles.xml
<resources>
<!-- Other styles . -->
<style name="AppTheme.EditText" parent="Widget.AppCompat.EditText">
<item name="android:background">#drawable/my_edit_text_material</item>
</style>
</resources>
Add the style to your editText
<android.support.design.widget.TextInputLayout
android:id="#+id/input_layout_lastname"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:layout_marginLeft="0dp"
android:layout_marginStart="0dp"
android:textColorHint="#color/Cool_Gray_2_C"
app:layout_constraintEnd_toStartOf="#+id/profile_guideline_end"
app:layout_constraintStart_toStartOf="#+id/profile_guideline_start"
app:layout_constraintTop_toBottomOf="#+id/input_layout_firstname" >
<EditText
style="#style/AppTheme.EditText"
android:id="#+id/txfLastname"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ems="10"
android:hint="#string/last_name"
android:inputType="textPersonName"
android:textColor="#color/Cool_Gray_2_C"
android:textColorHint="#color/Cool_Gray_2_C"
android:textSize="17sp" />
</android.support.design.widget.TextInputLayout>
That is the way I found removing the left and right space.
I hope help, thanks
The horizontal space on the left and right of the EditText default drawable is controlled by the abc_edit_text_inset_horizontal_material dimension. You can confirm that by looking at the abc_edit_text_material.xml drawable file, which represents AppCompat's default EditText background. To remove the space completely you can just set the dimension to 0 by specifing the dimension with exact same name inside your own project's dimens.xml file:
<?xml version="1.0" encoding="utf-8"?>
<resources xmlns:tools="http://schemas.android.com/tools">
<dimen tools:override="true" name="abc_edit_text_inset_horizontal_material">0dp</dimen>
...
</resources>
However, there is a catch. AppCompat library will only use it's own abc_edit_text_material.xml background if the host OS doesn't support material design. So If you're running your app on Android 4, you'll see that side margins disappear after you add the dimension mentioned above. If, however, you launch your app on say Android 10, you'll see that margins are still there. That is because on newer Android versions, compat library will actually prefer background drawable specified inside the OS itself.
So you need to force all of your EditTexts to use abc_edit_text_material.xml background specified inside the AppCompat library. Luckily, you can do that just by adding one line to your syles.xml file:
styles.xml:
<resources xmlns:tools="http://schemas.android.com/tools">
<style name="AppTheme" parent="Theme.AppCompat.DayNight.NoActionBar">
<item name="editTextBackground">#drawable/abc_edit_text_material</item>
...
</style>
...
</resources>
Any Theme.AppCompat.* will do as a parent theme and of course you have to use this theme as your app's theme in order to get any effect.
This solution uses private AppCompat identifiers (Android Studio will complain about this), but I still think this solution is much cleaner than using negative margins.
<com.google.android.material.textfield.TextInputLayout
android:id="#+id/textField_driver_age"
style="#style/Widget.MaterialComponents.TextInputLayout.FilledBox.ExposedDropdownMenu"
android:layout_width="wrap_content"
android:layout_height="0dp"
android:padding="0dp"
android:textColorHint="#color/brown_grey"
app:boxBackgroundColor="#color/white"
app:boxStrokeWidth="0dp"
app:boxStrokeWidthFocused="0dp"
app:endIconMode="none"
app:layout_constraintBottom_toBottomOf="#+id/lable3"
app:layout_constraintStart_toEndOf="#+id/lable3"
app:layout_constraintTop_toTopOf="#+id/lable3">
<AutoCompleteTextView
android:drawablePadding="8dp"
android:drawableEnd="#drawable/ic_email"
android:id="#+id/et_driver_age"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:dropDownHeight="250dp"
android:inputType="none"
android:lines="1"
android:padding="0dp"
android:text="30"
android:textColor="#color/greyish_brown"
android:textSize="12sp" />
I have severalEditTextfields in my layout xml. All of them follow this pattern:
<EditText
style="#style/EditText"
android:id="#+id/email"
android:hint="Email Address"
android:inputType="textEmailAddress"
android:drawableEnd="#drawable/icon1" />
If this field gains focus, I want to set the drawableIcon to icon1 and if it loses focus, I want to set it to icon2.
I know I can do it using setOnFocusChangeListener in my activity.
But I want to ask is it possible to do it using XML only?
It can be easily done using simple selectors once you create a custom drawable.
Check this tutorial where it applies what you want to a Button.
http://www.mkyong.com/android/android-imagebutton-selector-example/
Something like this should work for you:
<EditText
style="#style/EditText"
android:id="#+id/email"
android:hint="Email Address"
android:inputType="textEmailAddress"
android:background ="#drawable/customDrawableIcon" />
res/drawable/customDrawableIcon.xml
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="#drawable/icon1"
android:state_focused="true" />
<item android:drawable="#drawable/icon2"
android:state_focused="false" />
</selector>
I think it is possible, you need to create a selector xml for Edittext in your drawable folder, check this post he gave a good answer for this.
https://stackoverflow.com/a/14543476/1007087
You can use selector and change the state_focused drawable
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android" >
<item android:state_focused="true" android:drawable="#drawable/focusedIcon"/>
<item android:drawable="#drawable/normalicon"/>
</selector>
so now the android:drawableEnd should refer to the previous selector.
Hope this will help.
I have a listview set to use singleChoice. All I want to do is change the default background color to white and the text color to black. I cannot figure out how to do this. Here is my xml layout:
<ListView
android:id="#+id/lvSpeeds"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="#id/llToolbar"
android:layout_below="#id/rgSpeedUnits"
android:textColor="#android:color/black"
android:choiceMode="singleChoice"
android:background="#ffffff"
android:cacheColorHint="#00ffffff"
android:clickable="true"
android:divider="#ff000000"
android:dividerHeight="1dp"
android:focusable="true"
android:scrollingCache="true" />
EDIT: I should have pointed out that I want to change this only using xml layout files and NOT in code. I already know how to do this in code. Using a custom layout other than android.R.layout.simple_list_item_single_choice forces you to implement an adapter, bind, write more code, and so on. From viewing a lot more posts, it does not appear possible to change the text color using only xml. In fact, it doesn't seem possible to change anything on a row as the underlying layout android.R.layout.simple_list_item_single_choice is not accessible.
for a list view Use android selector
like this
and save it with anyname.xml and giveits reference to background of your list
<selector xmlns:android="http://schemas.android.com/apk/res/android" >
<item android:state_pressed="true" android:drawable="#drawable/about_btn_hover"></item>
<item android:drawable="#drawable/about_btn"></item>
</selector>
and for changing text color add color folder in your res directory
create an xml save it textchangecolor.xml
and add the following lines to it
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_pressed="true"
android:color="#color/whiteColor"></item>
<item android:color="#color/bluetxt"></item>
</selector>
and give its refernce to the textcolor
try to this:
insert to this code in adapter in getview mathod:
LinearLayout mRowLayout = (LinearLayout) vi
.findViewById(R.id.list_item_layout);
final TextView title = (TextView) vi
.findViewById(R.id.list_item);
title.setText(Massage[position]);
mRowLayout.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
title.setTextColor(Color.RED);
});
here list_item code:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="#+id/list_item_layout"
android:orientation="vertical" >
<RelativeLayout android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#drawable/row_single"
android:layout_margin="5dp">
<TextView android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:singleLine="true"
android:textColor="#android:color/black"
android:padding="10dp"
android:textSize="16sp"
android:layout_toLeftOf="#+id/arrow"
android:id="#+id/list_item"/>
</RelativeLayout>
</LinearLayout>
The best solution I could find was to use styles.xml and set a theme for my dialogs.
styles.xml
<style name="DialogTheme" parent="AppTheme">
<item name="android:textColor">#color/text</item>
<item name="android:textColorAlertDialogListItem">#color/text</item>
+ other styles
</style>
In Java Built Dialogs:
ContextThemeWrapper theme;
theme = ContextThemeWrapper(view.getContext(), R.style.DialogTheme);
AlertDialog.Builder builder = new AlertDialog.Builder(theme);
In XML built Dialogs:
<myLayout
....
android:theme="#style/DialogTheme" />