Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

QMUIRoundButton设置为paddingStart/paddingEnd无法获取值 #1148

Open
4 tasks done
krisez opened this issue Sep 8, 2022 · 1 comment
Open
4 tasks done

QMUIRoundButton设置为paddingStart/paddingEnd无法获取值 #1148

krisez opened this issue Sep 8, 2022 · 1 comment

Comments

@krisez
Copy link

krisez commented Sep 8, 2022

运行环境

  • 设备型号:redmi k50 pro、小米6、vivo nex3s
  • 设备系统版本: Android12、Android12、Android10
  • Gradle 版本:如 7.5
  • QMUI Android 版本:2.1.0

具体问题描述

在target>30
QMUIRoundButton的paddingStart获取不了值,其父类QMUIAlphaButton、AppCompatButton、Button就能获取paddingStart的值

val btn1 = view.findViewById<QMUIRoundButton>(R.id.btn_11)
        val btn2 = view.findViewById<QMUIRoundButton>(R.id.btn_22)
        Log.d("Krisez", "onCreateView: ${btn1.paddingLeft}")
        Log.d("Krisez", "onCreateView: ${btn1.paddingStart}")
        Log.d("Krisez", "onCreateView: ${btn2.paddingLeft}")
        Log.d("Krisez", "onCreateView: ${btn2.paddingRight}")

问题截图

image

异常日志(堆栈)

@krisez
Copy link
Author

krisez commented Sep 9, 2022

    <style name="QMUI.RoundButton" parent="@style/Button.Compat">
        <item name="android:layout_width">wrap_content</item>
        <item name="android:layout_height">wrap_content</item>
        <!--<item name="android:padding">0dp</item>--><!-- 不用 android:padding,而用各个方向分别指定 padding,方便子类覆盖 -->
        <item name="android:paddingLeft">0dp</item>
        <item name="android:paddingRight">0dp</item>
        <item name="android:paddingTop">0dp</item>
        <item name="android:paddingBottom">0dp</item>
        <item name="android:minWidth">0dp</item>
        <item name="android:minHeight">0dp</item>
        <item name="android:singleLine">true</item>
        <item name="android:gravity">center</item>
        <item name="android:ellipsize">end</item>
        <item name="qmui_isRadiusAdjustBounds">true</item>
        <item name="qmui_backgroundColor">?attr/qmui_skin_support_round_btn_bg_color</item>
        <item name="qmui_borderWidth">?attr/qmui_round_btn_border_width</item>
        <item name="qmui_borderColor">?attr/qmui_skin_support_round_btn_border_color</item>
        <item name="android:textColor">?attr/qmui_skin_support_round_btn_text_color</item>
    </style>

经反复尝试,将该style里的paddingL/R删去即可正常使用start/end

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant