Skip to content

3_modify ui(自定义部分样式)

水牛 edited this page Nov 18, 2017 · 5 revisions

for every type

  • set widthPercent or heightPercent of the dialog window:
//default is wrapcontent ,is full fill the screen ,it will automatically change to 0.8-0.9f.

setWidthPercent(@FloatRange(from = 0f,to = 1.0f)float widthPercent)
setHeightPercent(@FloatRange(from = 0f,to = 1.0f) float heightPercent)
  • disable the white and shadow background: mostly used in custom view dialog
//default is true
setHasShadow(boolean useTheShadowBg)
 or:
.setBgRes(R.drawable.leak_canary_icon)
  • disable the dimlayer(half transparent layer) behind
setTransparentBehind(boolean transparentBehind)

dialog with 1-3 buttons

setthe button text,change text size and color. the layout contains 3 buttons,if you set a button text as "",it will hide. at least 1 button will show

setBtnText(CharSequence positiveTxt)
setBtnText(CharSequence positiveTxt, @Nullable CharSequence negtiveText) 
setBtnText(CharSequence btn1Text, @Nullable CharSequence btn2Text, @Nullable CharSequence btn3Text)

setBtnSize(int sizeInSp)
setBtnColor(@ColorRes int btn1Color, @ColorRes int btn2Color, @ColorRes int btn3Color) 

dialog with title or msg

the text content has forced to set in top api,the color or size can be changed or use the default

setTitleColor(@ColorRes int colorRes)
setMsgColor(@ColorRes int colorRes)

setTitleSize(int sizeInSp)
setMsgSize(int sizeInSp)

dialog that has a list in it

setListItemColor(@ColorRes int lvItemTxtColor, Map<Integer, Integer> colorOfPosition)

setLvItemSize(int sizeInSp)

ios input dialog,modify the input/edittext

  • show 1 or 2 edittext: if hint2 and secondTxt is empty ,then the second edittext will hide.
buildNormalInput( CharSequence title, CharSequence hint1, CharSequence hint2, CharSequence firstTxt, CharSequence secondTxt, MyDialogListener listener) 
  • edittext style:
setInputSize(int sizeInSp)//text size 
seInputColor(@ColorRes int colorRes)
setInput2HideAsPassword(boolean input2HideAsPassword)//

  • callback for validate input in MyDialogListener:
public boolean onInputValid(CharSequence input1, CharSequence input2, EditText editText1,EditText editText2){
        return true;
    }
Clone this wiki locally