改变FragmentDialog弹出框大小
版权声明:本文为博主原创文章,未经博主允许不得转载。
一个很常见的支付弹出框,大概效果是这样的:
初看之下,这不就是一个普通的弹出框么,于是决定用Android官推的DialogFragment实现这种弹出框,然而,实践是检验真理唯一标准,开撸之后才发现暗藏杀招呀。如果中规中矩的一步步写下去(继承DialogFragment,重写onCreateView方法),则出来的效果:
额,貌似好尴尬呀!说好的圆角呢,说好的正方形背景呢。。。明明在xml中设置背景了呀,不管用?!
<com.zhy.autolayout.AutoLinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:orientation="vertical"
android:background="@drawable/rec_cirwhite"
tools:context=".DialogFragmentInput">
<TextView
android:id="@+id/tv_result_pay"
android:layout_width="match_parent"
android:layou

本文介绍了如何解决使用DialogFragment时遇到的背景圆角和尺寸不符问题。通过在onCreateView方法中添加代码实现圆角效果,并重写onStart方法来调整弹出框大小,最终达到预期的支付弹出框样式。
最低0.47元/天 解锁文章
5133

被折叠的 条评论
为什么被折叠?



