"프롤로그에서 콘텐츠가 허용되지 않습니다." 오류
156
작성자 없음
0 asked
선생님, 강의 잘 듣고 있습니다. 그런데 영탁 등등의 노래 리사이클러뷰 앱을 만들 때, 다음까지는 잘 됩니다.
그런데 이후 <TextView> 부분에 background를 첨가하거나 텍스트를 바꾸기만 해도 계속 위의 제목에서 보인 오류가 뜨고, 이후 다른 fragment에서도 마찬가지 오류가 뜹니다.
왜 그런 것이며, 어떻게 해결해야 할지요? 현재 최신 버전이 Otter를 사용하고 있습니다.
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout
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=".Singer1Fragment">
<TextView
android:text="영탁 노래 리스트"
android:textColor="@color/black"
android:gravity="center"
android:layout_margin="10dp"
android:textSize="30sp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_constraintTop_toTopOf="parent" />
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/singRV"
android:layout_marginTop="50dp"
android:layout_marginBottom="80dp"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
<!-- TODO: Update blank fragment layout -->
<LinearLayout
android:layout_width="match_parent"
android:layout_height="80dp"
app:layout_constraintBottom_toBottomOf="parent">
<ImageView
android:id="@+id/image1"
android:scaleType="fitXY"
android:layout_weight="1"
android:src="@drawable/photo1"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
<ImageView
android:id="@+id/image2"
android:scaleType="fitXY"
android:layout_weight="1"
android:src="@drawable/photo2"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
<ImageView
android:id="@+id/image3"
android:scaleType="fitXY"
android:layout_weight="1"
android:src="@drawable/photo3"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
</LinearLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
Answer 3
1
확인해봤습니다.
ConstraintLayout에서 제약조건(수평/수직) 모두 제약조건이 있어야합니다
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_constraintTop_toTopOf="parent" />
layout_constraintTop_toTopOf 수직 조건이 있지만 수평 관련된 조건이 없습니다.
아래와 같이 변경해보시겠어요?
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout
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=".Singer1Fragment">
<!-- 제목 TextView: ID 추가 및 좌우 제약 조건 추가 -->
<TextView
android:id="@+id/titleText"
android:text="영탁 노래 리스트"
android:textColor="@color/black"
android:gravity="center"
android:layout_margin="10dp"
android:textSize="30sp"
android:layout_width="0dp"
android:background="@color/black"
android:layout_height="wrap_content"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent" />
<!-- RecyclerView: 제약 조건 추가 -->
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/singRV"
android:layout_width="0dp"
android:layout_height="0dp"
app:layout_constraintTop_toBottomOf="@id/titleText"
app:layout_constraintBottom_toTopOf="@id/bottomLayout"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"/>
<!-- LinearLayout: ID 추가 및 좌우 제약 조건 추가 -->
<LinearLayout
android:id="@+id/bottomLayout"
android:layout_width="0dp"
android:layout_height="80dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent">
<ImageView
android:id="@+id/image1"
android:scaleType="fitXY"
android:layout_weight="1"
android:src="@drawable/photo1"
android:layout_width="0dp"
android:layout_height="match_parent"/>
<ImageView
android:id="@+id/image2"
android:scaleType="fitXY"
android:layout_weight="1"
android:src="@drawable/photo2"
android:layout_width="0dp"
android:layout_height="match_parent"/>
<ImageView
android:id="@+id/image3"
android:scaleType="fitXY"
android:layout_weight="1"
android:src="@drawable/photo3"
android:layout_width="0dp"
android:layout_height="match_parent"/>
</LinearLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
0
안녕하세요~
Activity와 fragment를 포함한 모든 코드를 공유해주시면 저도 살펴보겠습니다!
압축파일 형태로 구글 드라이브같은 곳에 업로드 후 다운받을 수 있는 링크를 공유주셔도 되고
코드 전체를 복사 붙여넣기 해주셔도 좋습니다!
0
안녕하세요, 인프런 AI 인턴입니다. Sam님, 질문 주셔서 감사합니다.
강의를 수강하시면서 XML 레이아웃에서 “프롤로그에서 콘텐츠가 허용되지 않습니다.“라는 오류를 만난 것을 말씀해 주셨습니다. 이 오류는 일반적으로 XML 파일에서 잘못된 형식이나 구성 요소가 올바르지 않게 중첩되어있는 경우 발생할 수 있습니다.
우선, 아래 몇 가지 주요 원인을 점검해 보시기 바랍니다:
LinearLayout 내부 요소:
LinearLayout에 자식 요소를 배치할 때, 자식 요소의layout_width또는layout_height를 “match_parent”로 설정하지 말고 “wrap_content”로 설정하거나 배치 크기를 조정할 필요가 있을 수 있습니다. “match_parent”가 내부 뷰에 사용되면 뷰가LinearLayout의 크기 전부를 차지하려 할 수 있어 이상 작동할 수 있습니다.Constraint Layout:
ConstraintLayout을 사용할 때는 각 뷰의 제약 조건을 명확히 정의해야 합니다. 특히LinearLayout처럼 배치할 경우, 상하좌우 제약 조건이 정확히 설정되었는지 확인하세요.앱 컴파일러 업데이트: Otter나 최신 안드로이드 버전 일부에서는 레이아웃의 불일치를 엄격하게 확인하기 때문에 문제를 일으킬 수 있습니다. 이 경우, Android Studio에서 제공하는 “Invalidate Caches / Restart” 기능을 사용해 보고, 앱 SDK와 빌드 툴을 최신 버전으로 업데이트해 보는 것도 좋은 방법입니다.
관련된 질문과 유사한 문제를 해결한 게시물을 이곳에서 찾아보실 수 있습니다. 게시물에서는 SDK 버전 업데이트 문제에 관한 대화와 해결 방법이 언급된 바 있으니 참고하시기 바랍니다.
저는 질문자님의 이해를 돕고자 지식공유자님의 기존 답변을 참고하여 유사한 답변 링크를 추천해드리고 있습니다.
현재 베타 기능으로 답변이 만족스럽지 않을 수 있는 점 양해 부탁드립니다. 🙏
추가적으로 궁금한 점이 있으시면, 이어서 질문해 주세요. 곧 지식공유자께서 답변해 주실 것입니다.
주사위앱 소개 및 레이아웃 설정 문제
0
59
2
안드로이드 에뮬레이터가 실행이 안 되요...ㅠ
0
105
2
30 강 소스 좀 올려 주십시요
0
80
2
onBackPressed 함수가 동영상 하고 다르게 동작합니다.
0
89
2
ListView 초기 실행 안됩니다.
0
94
2
코딩을 완료하고난후 앱 실행시 자동 종료
0
71
2
datavinding에서 오류가 납니다.
0
51
1
안드로이드 스튜디오 버전 차이로 초기 empyt activity 선택하면 안됩니다.
0
108
2
context의 구별에 대하여
0
69
2
"프롤로그에서 ..." 오류 관련해 직전 질문에 대한 추가 질문입니다.
0
67
2
해결완료
1
186
2
databinding 설정후 run하면 에러(해결)
0
222
2
databinding 설정 이후 실행시 에러
0
268
4
안드로이드 입문하는 사람입니다.
0
70
1
Firebase uid
0
75
3
activity_main 화면 다름
0
114
2
강의화면과 다른데 맞게진행되는것인가요...????
0
105
2
파이어베이스 질문
0
74
2
ActivityMainBinding에 오류가 납니다
0
134
2
선생님 onBackPressed 작동이 안되는거 같습니다
0
118
2
>app>res>layout 이 존재하지 않습니다.
0
119
2
안드로이드 스튜디오 미어캣 버전 사용 한글 깨짐
0
747
2
안드로이드 스튜디오 오류 발생 시 대처 방법은 요?
0
289
2
[Twice앱]안드로이드 스튜디오 '미어캣'으로 강의들어도 되나요?
1
156
2

