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

问题描述 投票:-1回答:1

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了很多,但没有找到解决方案。

android android-edittext android-animation android-framelayout
1个回答
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();

            } 
        }
    });
© www.soinside.com 2019 - 2024. All rights reserved.