【问题标题】:EditText focused after animationEditText 在动画之后聚焦
【发布时间】:2018-01-31 03:55:05
【问题描述】:

我试图在动画之后聚焦 EditText。动画使 EditText 成为设备的全宽,允许您输入更多内容。我已经尝试过 RequestFocus() 和 setFocusableInTouchMode(true),但都没有为我工作,我想知道我是如何做到这一点的。

使用的代码

 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;
       }
   });

最终我会将 w_searchbar 更改为标签,一旦触摸/单击它将继续使用此代码。但是现在,如果不可能,那么我将不得不使用 w_searchbar

【问题讨论】:

    标签: java android animation android-edittext focus


    【解决方案1】:

    添加android:focusable="true"编辑文字,希望能解决你的问题

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

    【讨论】:

    • 它不起作用,显示新的 EditText 但没有聚焦
    猜你喜欢
    • 2015-01-07
    • 2014-02-26
    • 2019-10-23
    • 2012-01-09
    • 2016-08-14
    • 1970-01-01
    • 2018-07-10
    • 1970-01-01
    • 2021-10-24
    相关资源
    最近更新 更多