Android Dialog实现缩放动画并且是自定义Dialog,4角是圆角

 
 
View inflate = LayoutInflater. from( context).inflate(R.layout. caiming, null); EditText editText = (EditText) inflate.findViewById(R.id. editText); editText.setText( list.get( position).getName()); Button button = (Button) inflate.findViewById(R.id. button); Dialog dialog = new AlertDialog .Builder( context) .setView(inflate) .show(); dialog.getWindow().setBackgroundDrawableResource(R.drawable. dialogyuanjiao); Animation animation = AnimationUtils. loadAnimation( context, R.anim. scale); inflate.setAnimation(animation); animation.start();

动态布局

 
 
<?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:background="@color/white" android:orientation="vertical" android:padding="20dp"> < EditText android:id="@+id/editText" android:layout_width="match_parent" android:layout_height="50dp" android:layout_marginTop="50dp" android:background="@drawable/bgk_yj" android:text="啤酒" /> < Button android:id="@+id/button" android:layout_width="match_parent" android:layout_height="50dp" android:layout_marginTop="30dp" android:background="@drawable/yj" android:text="@string/ConfirmText" android:textColor="@color/white" /> </ LinearLayout>

//4个角圆角设置

 
 
<?xml version="1.0" encoding="utf-8"?> < shape xmlns:android="http://schemas.android.com/apk/res/android"> < corners android:radius="8dp" /> </ shape>

//缩放动画

<?xml version="1.0" encoding="utf-8"?>
<scale xmlns:android="http://schemas.android.com/apk/res/android">
    <scale
        android:duration="1000"
        android:fromXScale="0"
        android:fromYScale="0"
        android:pivotX="50%"
        android:pivotY="50%"
        android:toXScale="100%"
        android:toYScale="100%" />
</scale>

猜你喜欢

转载自blog.csdn.net/yijiaodingqiankun/article/details/80400046