网上看了很多例子,基本上都是很片面的,参考网上的例子,整合了Dialog和Button样式 ,很简单的,小白轻喷!
1.定义圆角Dialog
<shape xmlns:android="
http://schemas.android.com/apk/res/android" >
<corners android:radius="20dp" />
<stroke android:width="1dp" />
<gradient
android:centerColor="@color/white"
android:endColor="@color/white"
android:startColor="@color/white" />
</shape>
<corners android:radius="20dp" />
<stroke android:width="1dp" />
<gradient
android:centerColor="@color/white"
android:endColor="@color/white"
android:startColor="@color/white" />
</shape>
2.定义圆角Button
<selector xmlns:android="
http://schemas.android.com/apk/res/android">
<item android:drawable="@drawable/dialog_button_right_style" android:state_selected="true"/>
<item android:drawable="@drawable/dialog_button_right_style" android:state_focused="true"/>
<item android:drawable="@drawable/dialog_button_right_style" android:state_pressed="true"/>
<item android:drawable="@drawable/dialog_button_right_style" android:state_checked="true"/>
<item android:drawable="@color/invisible_color"/>
</selector>
<item android:drawable="@drawable/dialog_button_right_style" android:state_focused="true"/>
<item android:drawable="@drawable/dialog_button_right_style" android:state_pressed="true"/>
<item android:drawable="@drawable/dialog_button_right_style" android:state_checked="true"/>
<item android:drawable="@color/invisible_color"/>
</selector>
<shape xmlns:android="
http://schemas.android.com/apk/res/android" >
<corners android:bottomLeftRadius="20dp" />
<stroke android:width="1dp" />
<gradient
android:centerColor="@color/dialog_button_white"
android:endColor="@color/dialog_button_white"
android:startColor="@color/dialog_button_white" />
</shape>
<corners android:bottomLeftRadius="20dp" />
<stroke android:width="1dp" />
<gradient
android:centerColor="@color/dialog_button_white"
android:endColor="@color/dialog_button_white"
android:startColor="@color/dialog_button_white" />
</shape>
2.定义style
<style name="Corner_dialog" parent="@android:style/Theme.Dialog">
<item name="android:colorBackgroundCacheHint">@null</item>
<item name="android:windowFrame">@null</item><!--边框-->
<item name="android:windowIsFloating">true</item>
<!--是否浮现在activity之上-->
<item name="android:windowIsTranslucent">true</item>
<!--半透明-->
<item name="android:windowNoTitle">true</item>
<!--无标题-->
<item name="android:background">@drawable/my_dialog</item>
<!--dialog背景样式-->
<item name="android:windowBackground">@color/invisible_color</item>
<!-- 背景透明 -->
<item name="android:backgroundDimEnabled">true</item>
<!--模糊-->
<item name="android:backgroundDimAmount">0.6</item>
<!--界面灰度值-->
</style>
最后在代码中引用就好了