상세 컨텐츠

본문 제목

안드로이드[Android] EditText 자동 포커스 제거

스마트기기개발관련/안드로이드 개발

by AlrepondTech 2016. 7. 8. 17:20

본문

반응형

 

 

 

 

=================================

=================================

=================================

 

 

 

 

 

출처: http://gogorchg.tistory.com/entry/Android-EditText-%EC%9E%90%EB%8F%99-%ED%8F%AC%EC%BB%A4%EC%8A%A4-%EC%A0%9C%EA%B1%B0

 

 

화면이 실행 되면 초반에 EditText에 자동 포커스가 되죠.

 

이부분을 제거하고 싶으실 경우 아래와 같이 해보세요.

 

 

<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:focusable="true"
android:focusableInTouchMode="true"
android:gravity="center_vertical"
android:orientation="vertical"
>
<android.support.design.widget.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp">

<android.support.v7.widget.AppCompatEditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textColor="@color/_121212"
android:textSize="@dimen/_15sp"
/>
</android.support.design.widget.TextInputLayout>
</LinearLayout>

아래 두줄을 EditText 에 넣는게 아니라 그걸 감싸고 있는 LinearLayout에 넣어주세요.

그럼 포커스가 LinearLayout으로 가게 됩니다.

 

android:focusable="true"
android:focusableInTouchMode="true"

 

참고하세요.

 

http://stackoverflow.com/questions/1555109/stop-edittext-from-gaining-focus-at-activity-startup

 

 

 

=================================

=================================

=================================

 

 

반응형


관련글 더보기

댓글 영역