1

我有很長的形式(LinearLayout作爲根),它由EditTexts和TextView組成。 現在我正面臨的問題是:點擊編輯文本後,如果我點擊textviews然後編輯文本的焦點不清除。因此,由於焦點,屏幕滾動到該編輯文本。AppCompatEditText焦點問題

我已經嘗試解決方案 - android:focusableInTouchMode =「true」在父佈局但沒有運氣。

enter image description here

我附上顯示問題的圖像。我點擊了諮詢醫生領域,這是一個TextView,但重點是直到電子郵件編輯文本。

請幫我解決一些問題。謝謝。

+0

把textview放在觸摸模式下的可調焦 –

+0

@JaydeepPatel試過了。不工作 –

+0

https://stackoverflow.com/a/28939113/3467204是你想要的嗎? – WannaBeGeek

回答

0

點擊編輯文本後,如果我點擊textviews然後編輯文本的焦點不清除。因此,由於焦點,屏幕滾動到該編輯文本。

包裹內的FrameLayout您的EditText如下圖所示

<FrameLayout 

     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:descendantFocusability="beforeDescendants" 
     android:focusable="true" 
     android:focusableInTouchMode="true"> 

     <EditText 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content"/> 
    </FrameLayout> 
+0

但隨機方式中有多個editext和texview(如表單)。如果我將每個editText包裝在框架佈局中,都會使佈局變得糟糕。說啥? –

+0

是的,您需要分別包裝每個EditText。 – Darish

0

公共靜態無效hideSoftKeyboard(查看視圖)

{

InputMethodManager imm = InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE); 
imm.hideSoftInputFromWindow(view.getApplicationWindowToken(), 0); 

}

//調用此在textview上單擊方法