Android--自定義dialog解決margin失效問題

全屏dialog的margin

<?xml version="1.0" encoding="utf-8"?>
<inset xmlns:android="http://schemas.android.com/apk/res/android"
    android:drawable="@drawable/dialogbackground"
    android:insetTop="50dp"/>     <--相當於設置頂部margin
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
    <!-- 圓角 -->
    <corners android:radius="18dp"/>
    <!-- 填充顏色 -->
    <solid android:color="@color/background"/>
</shape>

如果是自定義dialog,寬高設置在show()方法之前設置

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章