Advertisement
Guest User

Untitled

a guest
Feb 27th, 2017
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.32 KB | None | 0 0
  1. <ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
  2. xmlns:tools="http://schemas.android.com/tools"
  3. android:layout_width="match_parent"
  4. android:layout_height="match_parent">
  5.  
  6. <LinearLayout
  7. android:layout_width="match_parent"
  8. android:layout_height="wrap_content"
  9. android:descendantFocusability="beforeDescendants"
  10. android:focusableInTouchMode="true"
  11. android:orientation="vertical">
  12.  
  13. <TextView
  14. android:layout_width="match_parent"
  15. android:layout_height="wrap_content"/>
  16.  
  17. <android.support.design.widget.TextInputLayout
  18. android:layout_width="match_parent"
  19. android:layout_height="wrap_content"
  20. android:layout_marginBottom="@dimen/small"
  21. android:layout_marginEnd="@dimen/small"
  22. android:layout_marginStart="@dimen/small"
  23. android:layout_marginTop="@dimen/small">
  24.  
  25. <android.support.design.widget.TextInputEditText
  26. android:layout_width="match_parent"
  27. android:layout_height="wrap_content"
  28. android:inputType="textPassword"/>
  29.  
  30. </android.support.design.widget.TextInputLayout>
  31.  
  32. <android.support.design.widget.TextInputLayout
  33. android:layout_width="match_parent"
  34. android:layout_height="wrap_content"
  35. android:layout_marginBottom="@dimen/small"
  36. android:layout_marginEnd="@dimen/small"
  37. android:layout_marginStart="@dimen/small">
  38.  
  39. <android.support.design.widget.TextInputEditText
  40. android:layout_width="match_parent"
  41. android:layout_height="wrap_content"
  42. android:inputType="textPassword"/>
  43.  
  44. </android.support.design.widget.TextInputLayout>
  45.  
  46. <android.support.design.widget.TextInputLayout
  47. android:layout_width="match_parent"
  48. android:layout_height="wrap_content"
  49. android:layout_marginBottom="@dimen/small"
  50. android:layout_marginEnd="@dimen/small"
  51. android:layout_marginStart="@dimen/small">
  52.  
  53. <android.support.design.widget.TextInputEditText
  54. android:layout_width="match_parent"
  55. android:layout_height="wrap_content"
  56. android:imeOptions="actionDone"
  57. android:inputType="textPassword" />
  58.  
  59. </android.support.design.widget.TextInputLayout>
  60.  
  61. <Button
  62. android:layout_width="match_parent"
  63. android:layout_height="wrap_content"
  64. android:layout_marginBottom="@dimen/small" />
  65.  
  66. <FrameLayout
  67. android:layout_width="match_parent"
  68. android:layout_height="wrap_content">
  69.  
  70. <LinearLayout
  71. android:layout_width="match_parent"
  72. android:layout_height="wrap_content"
  73. android:orientation="vertical">
  74.  
  75. <TextView
  76. android:layout_width="match_parent"
  77. android:layout_height="wrap_content"
  78. android:layout_marginEnd="@dimen/small"
  79. android:layout_marginStart="@dimen/small"
  80. android:layout_marginTop="@dimen/small" />
  81.  
  82. <Button
  83. style="@style/Button.Small"
  84. android:layout_width="match_parent"
  85. android:layout_height="wrap_content"
  86. android:layout_marginTop="@dimen/small" />
  87.  
  88. </LinearLayout>
  89.  
  90. <LinearLayout
  91. android:layout_width="match_parent"
  92. android:layout_height="wrap_content"
  93. android:orientation="vertical">
  94.  
  95. <android.support.design.widget.TextInputLayout
  96. android:layout_width="match_parent"
  97. android:layout_height="wrap_content"
  98. android:layout_marginBottom="@dimen/small"
  99. android:layout_marginEnd="@dimen/small"
  100. android:layout_marginStart="@dimen/small">
  101.  
  102. <android.support.design.widget.TextInputEditText
  103. android:layout_width="match_parent"
  104. android:layout_height="wrap_content"
  105. android:imeOptions="actionDone"
  106. android:inputType="text" />
  107.  
  108. </android.support.design.widget.TextInputLayout>
  109.  
  110. <android.support.design.widget.TextInputLayout
  111. android:layout_width="match_parent"
  112. android:layout_height="wrap_content"
  113. android:layout_marginBottom="@dimen/small"
  114. android:layout_marginEnd="@dimen/small"
  115. android:layout_marginStart="@dimen/small">
  116.  
  117. <android.support.design.widget.TextInputEditText
  118. android:layout_width="match_parent"
  119. android:layout_height="wrap_content"
  120. android:imeOptions="actionDone"
  121. android:inputType="text" />
  122.  
  123. </android.support.design.widget.TextInputLayout>
  124.  
  125. </LinearLayout>
  126.  
  127. </FrameLayout>
  128.  
  129. </LinearLayout>
  130.  
  131. /**
  132. * Clear the edit text focus if the touch is outside its limits
  133. *
  134. * @param context the activity context
  135. * @param editText the edit text
  136. * @param event the motion event
  137. */
  138. public static void clearEditTextFocusOnMontionEvent(@NonNull Context context, @NonNull EditText editText, @NonNull MotionEvent event) {
  139. if (event.getAction() == MotionEvent.ACTION_DOWN) {
  140. Rect outRect = new Rect();
  141. editText.getGlobalVisibleRect(outRect);
  142. if (!outRect.contains((int) event.getRawX(), (int) event.getRawY())) {
  143. editText.clearFocus();
  144. hideKeyboard(context, editText);
  145. }
  146. }
  147. }
  148.  
  149. if (actionId == EditorInfo.IME_ACTION_DONE) {
  150. WindowsHelper.hideKeyboard(context, view);
  151. view.clearFocus();
  152. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement