如何根据焦点显示前景中的视图?

时间:2018-03-02 12:11:40

标签: android android-edittext android-animation android-framelayout

JAVA代码:

 mEdtTextPickup.setOnFocusChangeListener(new View.OnFocusChangeListener() {
            @Override
            public void onFocusChange(View v, boolean hasFocus) {
                if(hasFocus){
                    mLayoutDrop.invalidate();
                    mEdtTextPickup.bringToFront();
                }
            }
        });
        mEdtTextDrop.setOnFocusChangeListener(new View.OnFocusChangeListener() {
            @Override
            public void onFocusChange(View v, boolean hasFocus) {
                if(hasFocus){
                    mLayoutPickup.invalidate();
                    mEdtTextDrop.bringToFront();
                }
            }
        });

` Two Edit-text with Frame-layout 我在我的应用程序Source和Destination中有两个布局,其中一个布局在FrameLayout中与另一个重叠。(就像附加图像一样)

现在,如何在聚焦时将目标布局置于动画源布局之上。我google了很多,但没有找到解决方案。

1 个答案:

答案 0 :(得分:0)

You can use a focus change listener to identify when the field is focused and then bringToFront to bring the view above the others.

destinationEditText.setOnFocusChangeListener(new OnFocusChangeListener() {
        @Override
        public void onFocusChange(View v, boolean hasFocus) {
            if (hasFocus) {
                edittext.bringToFront();

            } 
        }
    });