글작성 엑티비티에서 키보드 사용시 스크롤로 화면을 올리는것이 되지 않습니다
482
작성한 질문수 4
강의를 따라하면서 게시글을 작성하는 엑티비티를 따라서 완료 하였습니다.
키보드 사용시 화면이 올라가게 하는것을 따라 만들려고 하였으나 올라가지 않습니다.
데이터 바인딩이 아니고 뷰바인딩을 사용하여 layout 으로 감싸지 않았고 문제를 해결해보기위해 인터넷을 뒤지며 xml 을 수정하여 강의와 좀 차이가 있습니다.
xml 을 어떻게 수정해야 스크롤이 작동 할까요?
<?xml version="1.0" encoding="utf-8"?>
<ScrollView
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".board.BoardWriteActivity">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="30dp"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="60dp">
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:text="글쓰기 페이지"
android:textColor="@color/black"
android:textSize="30dp" />
</LinearLayout>
<EditText
android:id="@+id/TitleArea"
android:layout_width="match_parent"
android:layout_height="60dp"
android:layout_margin="20dp"
android:background="#00ff0000"
android:gravity="center"
android:hint="제목을 적어주세요" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0.5dp"
android:layout_margin="20dp"
android:background="#000000" />
<EditText
android:id="@+id/ContentsArea"
android:layout_width="match_parent"
android:layout_height="60dp"
android:layout_margin="20dp"
android:background="#00ff0000"
android:gravity="center"
android:hint="내용을 적어주세요" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0.5dp"
android:layout_margin="20dp"
android:background="#000000" />
<ImageView
android:id="@+id/ImageBtn"
android:layout_width="100dp"
android:layout_height="100dp"
android:layout_gravity="center"
android:layout_marginTop="30dp"
android:src="@drawable/plus" />
<Button
android:id="@+id/WriteButton"
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_marginLeft="20dp"
android:layout_marginTop="40dp"
android:layout_marginRight="20dp"
android:backgroundTint="@color/mainblue"
android:text="입력"
android:textColor="@color/black"
android:textSize="20dp" />
</LinearLayout>
</LinearLayout>
</ScrollView>
답변 2
0
또 문의사항 있으시면 알려주세요 :)
0

이 부분을 수강중이신게 맞으실까요?
여기 보시면, 전체 세로 길이가 깁니다.
예를 들면 전체 디바이스 길이가 1000
내용물 길이가 600
키보드 창 길이가 500
그러니깐 총 내용물 길이가 1100이 되어, 디바이스보다 길게 되어 스크롤이 되는 형태입니다.
그런데, 작성해주신 부분의 내용물이 짧기 때문에, 전체를 스크롤 할 일이 없어서 스크롤이 되지 않는 형태에요~
혹시 이해가 어려우시면 한번 더 문의주세요 :)
0
안녕하세요!
ScrollView안의 영역의 전체 화면보다 작기 때문입니다.
예를 들면 전체 화면이 1000dp 인데, LinearLayout의 크기가 500이면, 전체화면보다 작기 때문에 스크롤이 내려갈 영역이 없겠죠?
아래와 같은 코드로 테스트해보시면 스크롤이 내려가는 것을 보실 수 있습니다.
내용물을 채워서 제가 세로 길이를 늘렸어요
<?xml version="1.0" encoding="utf-8"?>
<ScrollView
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".board.BoardWriteActivity">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="30dp"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="60dp">
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:text="글쓰기 페이지"
android:textColor="@color/black"
android:textSize="30dp" />
</LinearLayout>
<EditText
android:layout_width="match_parent"
android:layout_height="60dp"
android:layout_margin="20dp"
android:background="#00ff0000"
android:gravity="center"
android:hint="제목을 적어주세요" />
<EditText
android:layout_width="match_parent"
android:layout_height="60dp"
android:layout_margin="20dp"
android:background="#00ff0000"
android:gravity="center"
android:hint="제목을 적어주세요" />
<EditText
android:layout_width="match_parent"
android:layout_height="60dp"
android:layout_margin="20dp"
android:background="#00ff0000"
android:gravity="center"
android:hint="제목을 적어주세요" />
<EditText
android:layout_width="match_parent"
android:layout_height="60dp"
android:layout_margin="20dp"
android:background="#00ff0000"
android:gravity="center"
android:hint="제목을 적어주세요" />
<EditText
android:layout_width="match_parent"
android:layout_height="60dp"
android:layout_margin="20dp"
android:background="#00ff0000"
android:gravity="center"
android:hint="제목을 적어주세요" />
<EditText
android:layout_width="match_parent"
android:layout_height="60dp"
android:layout_margin="20dp"
android:background="#00ff0000"
android:gravity="center"
android:hint="제목을 적어주세요" />
<EditText
android:layout_width="match_parent"
android:layout_height="60dp"
android:layout_margin="20dp"
android:background="#00ff0000"
android:gravity="center"
android:hint="제목을 적어주세요" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0.5dp"
android:layout_margin="20dp"
android:background="#000000" />
<EditText
android:id="@+id/ContentsArea"
android:layout_width="match_parent"
android:layout_height="60dp"
android:layout_margin="20dp"
android:background="#00ff0000"
android:gravity="center"
android:hint="내용을 적어주세요" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0.5dp"
android:layout_margin="20dp"
android:background="#000000" />
</LinearLayout>
</LinearLayout>
</ScrollView>
이미지가 기본이미지인지 확인
0
142
1
NavController error 발생
0
154
1
fragment 생성하고 메인에서 불러왔는데 안뜹니다.
0
149
2
67강 댓글
0
113
2
7강 데이터바인딩 에러
0
129
2
Firebase 스토리지 유료화 문제
1
304
2
게시글 이미지가 파이어베이스에 저장되지 않습니다.
0
190
2
AVD 갤러리에 이미지 저장 안되는 문제
0
255
2
이미지 받아오는 방법?
0
211
2
회원탈퇴 기능을 추가하려고 합니다.
0
196
2
상태바 질문 드립니다.
0
119
1
섹션2 인트로 페이지 꾸미기 질문 드립니다.
0
121
1
게시판 글을 길게 쓸경우
0
129
2
로그인 로그아웃
0
185
2
갤럭시 연결시 게시판에 업로드한 사진이 보이지 않아요.
0
220
2
웹뷰 AVD 실행안됨
0
198
1
자막켜기가 안되요 ㅜ.ㅜ
1
195
1
리사이클러뷰, 그리드레이아웃 오류
0
192
2
리사이클러뷰 오류 해결 방법이 궁금합니다.
0
200
1
firebase 스마트폰으로 연결이 안되는데 원인이 있을까요
0
266
2
안드로이드 스튜디오 게시글 이미지 업로드 유무
0
227
1
firebase 설정 오류
0
309
2
홈 화면 커뮤니티
0
180
1
게시판 글 읽기
0
244
2





