简体   繁体   中英

EditText focused after animation

Im trying to focus a EditText after a animation. The Animation makes the EditText the fullwidth of the device allowing you to type more. I have tried RequestFocus(), and setFocusableInTouchMode(true) and neither have worked for me and am wondering how I go about doing this.

Code used

 w_SearchBar.setOnTouchListener(new View.OnTouchListener() {
       @Override
       public boolean onTouch(View view, MotionEvent motionEvent) {
           w_SearchBarFullScreen.setVisibility(View.VISIBLE);
           SearchBarExpand = AnimationUtils.loadAnimation(MainActivity.this,R.anim.web_search_expand);
           w_SearchBarFullScreen.startAnimation(SearchBarExpand);
           w_Toolbar.startAnimation(FadeOut);

           if(w_SearchBarFullScreen.getVisibility()==View.VISIBLE){
               w_SearchBarFullScreen.requestFocus();

           }

           return false;
       }
   });

Eventually I will change the w_searchbar to a label and once touched/clicked it will continue on with this code. But for now if it isnt possible then i will have to use the w_searchbar

Add android:focusable="true" to edit text, i hope this will solve your problem

<EditText
        android:id="@+id/edit_text"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:focusable="true"
        android:gravity="top"
        />

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM