Android 自定义dialog 布局设置的宽高无效问题

本文介绍了在Android开发中遇到自定义Dialog布局设置宽高无效的问题,通过添加额外代码调整以及使用自定义style实现了适配不同分辨率设备的需求。详细步骤包括在dialog.show()后添加调整宽高的代码以及创建自定义style文件来解决问题。
摘要由CSDN通过智能技术生成

参考:Android 自定义dialog 设置宽度的问题_onlySound的博客-CSDN博客_android dialog宽度

自定义dialog的布局文件dialog_del_fav:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:background="@drawable/bg_del_fav"
    android:paddingStart="23mm"
    android:paddingEnd="23mm"
    android:paddingBottom="13mm">

    <TextView
        android:id="@+id/del_fav_title"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_centerHorizontal="true"
        android:layout_marginTop="25mm"
        android:text="确认取消收藏吗?"
        android:textColor="#fff0f0f0"
        android:textSize="18mm" />
    <TextView
        android:id="@+id/tv_tv_del_fav_cancle"
        android:layout_width="80mm"
        android:layout_height="32mm"
        android:layout_below="@id/del_fav_title"
        android:layout_marginTop="25mm"
        android:background="@drawable/bg_del_fav_slt"
        android:clickable="t
  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值