Android 在自定义复合视图中';文本输入布局';未显示扩展提示

Android 在自定义复合视图中';文本输入布局';未显示扩展提示,android,android-layout,android-custom-view,android-textinputlayout,android-compound-view,Android,Android Layout,Android Custom View,Android Textinputlayout,Android Compound View,我已经创建了一个自定义复合视图。它包含一个imageview、一个TextInputLayout和一个EditText。问题是,当我从xml设置属性时,它会设置所有值,如提示、图标等,但行不会更改,并且不会显示TextInputLayout的扩展提示 当我像这样设置线条时 'textInputLayout.getEditText().setLines(行)“它可以工作,但是 使用'etInput.setLines(lines);'它不起作用 扩展提示无效 小部件: public class In

我已经创建了一个自定义复合视图。它包含一个imageview、一个TextInputLayout和一个EditText。问题是,当我从xml设置属性时,它会设置所有值,如提示、图标等,但行不会更改,并且不会显示TextInputLayout的扩展提示

  • 当我像这样设置线条时 'textInputLayout.getEditText().setLines(行)“它可以工作,但是 使用'etInput.setLines(lines);'它不起作用

  • 扩展提示无效

  • 小部件:

    public class InputLayoutWidget extends LinearLayout {
    
        private Context mContext;
        private TextInputLayout textInputLayout;
        private TextInputEditText etInput;
        private ImageView ivIcon;
    
        private String hint;
        private int inputType;
        private int lines;
        private boolean singleLine, isPasswordInput;
        private Drawable iconDrawable;
    
        public InputLayoutWidget(Context context) {
            super(context);
            initializeView(context, null, 0);
        }
    
        public InputLayoutWidget(Context context, AttributeSet attrs) {
            super(context, attrs);
            initializeView(context, attrs, 0);
        }
    
        public InputLayoutWidget(Context context, AttributeSet attrs, int defStyleAttr) {
            super(context, attrs, defStyleAttr);
            initializeView(context, attrs, defStyleAttr);
        }
    
        private void initializeView(Context context, AttributeSet attrs, int defStyleAttr) {
            mContext = context;
            TypedArray array = context.obtainStyledAttributes(attrs, R.styleable.InputLayoutWidget, defStyleAttr, 0);
    
            try {
                hint = array.getString(R.styleable.InputLayoutWidget_android_hint);
                lines = array.getInteger(R.styleable.InputLayoutWidget_android_lines, 1);
                singleLine = array.getBoolean(R.styleable.InputLayoutWidget_android_singleLine, false);
                isPasswordInput = array.getBoolean(R.styleable.InputLayoutWidget_isPassword, false);
                inputType = array.getInteger(R.styleable.InputLayoutWidget_android_inputType, InputType.TYPE_CLASS_TEXT);
                iconDrawable = array.getDrawable(R.styleable.InputLayoutWidget_iconDrawable);
            } finally {
                array.recycle();
            }
    
            setOrientation(HORIZONTAL);
    
            LayoutInflater inflater = LayoutInflater.from(context);
            inflater.inflate(R.layout.custom_input_field, this, true);
    
            AppLogger.d("usm_input_layout", "init");
    
        }
    
        @Override
        protected void onFinishInflate() {
            super.onFinishInflate();
            AppLogger.d("usm_input_layout", "onFinishInflate");
            initComponents();
            setValues();
            addTextListener();
            //  invalidate();
        }
    
    
        private void initComponents() {
    
            textInputLayout = this.findViewById(R.id.textInputLayout);
            etInput = this.findViewById(R.id.et_input);
            ivIcon = this.findViewById(R.id.iv_icon);
    
            //etInput = textInputLayout.getEditText();
    
        }
    
        private void setValues() {
            etInput.setHint(hint);
            etInput.setSingleLine(singleLine);
            etInput.setLines(singleLine ? 1 : lines);
            etInput.setInputType(inputType);
            ivIcon.setImageDrawable(iconDrawable);
    
            //if(textInputLayout.getEditText()!=null)
            //textInputLayout.getEditText().setLines(singleLine ? 1 : lines);
        }
    
    
        public EditText getEditText() {
            return etInput;
        }
    
    }
    
    布局:

    <?xml version="1.0" encoding="utf-8"?>
    <merge 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">
    
        <ImageView
            android:id="@+id/iv_icon"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginEnd="@dimen/et_icon_margin_end"
            android:layout_marginTop="@dimen/et_icon_margin_top"
            android:contentDescription="@string/icon" />
    
        <android.support.design.widget.TextInputLayout
            android:id="@+id/textInputLayout"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            app:errorEnabled="true">
    
            <android.support.design.widget.TextInputEditText
                android:id="@+id/et_input"
                style="@style/TextInputEditStyle"
                android:layout_width="match_parent"
                android:layout_height="wrap_content" />
        </android.support.design.widget.TextInputLayout>
    </merge>
    
    
    
    我认为您不能为
    TextInputLayout
    设置行,您只能为其子级设置行,就像普通
    EditText
    一样。其他属性正在处理它。。。为什么TextInputLayout不显示扩展的提示标签?