xuexiangjys / XUI

💍A simple and elegant Android native UI framework, free your hands! (一个简洁而优雅的Android原生UI框架,解放你的双手!)
https://xuexiangjys.github.io/XUI/
Apache License 2.0
4.88k stars 838 forks source link

ValidatorEditText用于BaseDialog中时,错误提示位置显示不对、错误提示被BaseDialog遮挡 #186

Open luckywur opened 3 months ago

luckywur commented 3 months ago

问题描述(必填)

ValidatorEditText用于BaseDialog中时,错误提示位置显示不对、错误提示被BaseDialog遮挡,app中的MaterialDialog.Builder自定义对话框同样存在这个问题

使用的XUI版本(必填)

1.2.1

如何重现(必填)

使用BaseDialog,自定义组件(组件中使用ValidatorEditText),ValidatorEditText错误提示位置不正确,同时被BaseDialog遮挡

期望的效果

提示位置正确并能正常显示

截图

image

设备信息

luckywur commented 3 months ago

dialog定义

float width = getContext().getResources().getDimension(R.dimen.dp_300);
float height = getContext().getResources().getDimension(R.dimen.dp_200);

baseDialog = new BaseDialog(getContext(), R.layout.table_area_edit_dialog)
        .setIsSyncSystemUiVisibility(true)
        .setDialogSize(Float.valueOf(width).intValue(), Float.valueOf(height).intValue());

布局定义

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:background="@drawable/dialog_normal_background"
    android:orientation="vertical">

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:background="@drawable/dialog_title_background"
        android:gravity="center_vertical"
        android:paddingStart="@dimen/dp_14"
        android:paddingEnd="@dimen/dp_5">

        <TextView
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:text="区域信息"
            android:textColor="#fff"
            android:textSize="@dimen/sp_12" />

        <ImageButton
            android:id="@+id/areaEditDialogClose"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="center_vertical"
            android:layout_marginTop="@dimen/dp_5"
            android:layout_marginBottom="@dimen/dp_5"
            android:src="@mipmap/close" />
    </LinearLayout>

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginTop="@dimen/dp_20"
        android:layout_marginBottom="@dimen/dp_5"
        android:paddingLeft="@dimen/dp_20"
        android:paddingRight="@dimen/dp_20">

        <TextView
            android:layout_width="@dimen/dp_60"
            android:layout_height="wrap_content"
            android:layout_gravity="center_vertical"
            android:text="上级区域"
            android:textColor="@color/line_title"
            android:textSize="@dimen/sp_11" />

        <TextView
            android:id="@+id/parentCode"
            style="@style/EditText.Normal"
            android:layout_width="match_parent"
            android:background="@drawable/param_set_frame_edit_background"
            android:singleLine="true"
            android:textColor="#fff"
            android:textSize="@dimen/sp_11" />
    </LinearLayout>

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginTop="@dimen/dp_5"
        android:layout_marginBottom="@dimen/dp_5"
        android:paddingLeft="@dimen/dp_20"
        android:paddingRight="@dimen/dp_20">

        <TextView
            android:layout_width="@dimen/dp_60"
            android:layout_height="wrap_content"
            android:layout_gravity="center_vertical"
            android:text="区域名称"
            android:textColor="@color/line_title"
            android:textSize="@dimen/sp_11" />

        <com.xuexiang.xui.widget.edittext.ValidatorEditText
            android:id="@+id/areaName"
            style="@style/EditText.Normal"
            android:layout_width="match_parent"
            android:background="@drawable/param_set_frame_edit_background"
            android:focusableInTouchMode="true"
            android:inputType="numberDecimal"
            android:singleLine="true"
            android:textColor="#fff"
            android:textSize="@dimen/sp_11"
            app:vet_errorMessage="@string/text_regexp_msg"
            app:vet_regexp="@string/text_regexp"
            app:vet_tipPosition="top" />
    </LinearLayout>

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginTop="@dimen/dp_5"
        android:layout_marginBottom="@dimen/dp_10"
        android:paddingLeft="@dimen/dp_20"
        android:paddingRight="@dimen/dp_20">

        <TextView
            android:layout_width="@dimen/dp_60"
            android:layout_height="wrap_content"
            android:layout_gravity="center_vertical"
            android:text="区域编码"
            android:textColor="@color/line_title"
            android:textSize="@dimen/sp_11" />

        <com.xuexiang.xui.widget.edittext.ValidatorEditText
            android:id="@+id/areaCode"
            style="@style/EditText.Normal"
            android:layout_width="match_parent"
            android:background="@drawable/param_set_frame_edit_background"
            android:focusableInTouchMode="true"
            android:inputType="numberDecimal"
            android:singleLine="true"
            android:textColor="#fff"
            android:textSize="@dimen/sp_11"
            app:vet_errorMessage="@string/text_regexp_msg"
            app:vet_regexp="@string/text_regexp"
            app:vet_tipPosition="top" />
    </LinearLayout>

    <com.google.android.flexbox.FlexboxLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginTop="@dimen/dp_2_5"
        android:layout_marginBottom="@dimen/dp_2_5"
        app:justifyContent="space_around">

        <com.xuexiang.xui.widget.alpha.XUIAlphaLinearLayout
            android:id="@+id/cancelButton"
            android:layout_width="@dimen/dp_70"
            android:layout_height="@dimen/dp_25"
            android:background="@mipmap/rectangle9"
            android:gravity="center|center_vertical">

            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="取消"
                android:textAlignment="center"
                android:textColor="#fff"
                android:textSize="@dimen/sp_11" />
        </com.xuexiang.xui.widget.alpha.XUIAlphaLinearLayout>

        <com.xuexiang.xui.widget.alpha.XUIAlphaLinearLayout
            android:id="@+id/saveButton"
            android:layout_width="@dimen/dp_70"
            android:layout_height="@dimen/dp_25"
            android:background="@mipmap/rectangle_blue"
            android:gravity="center|center_vertical">

            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="确定"
                android:textAlignment="center"
                android:textColor="#fff"
                android:textSize="@dimen/sp_11" />
        </com.xuexiang.xui.widget.alpha.XUIAlphaLinearLayout>
    </com.google.android.flexbox.FlexboxLayout>
</LinearLayout>