인프런 커뮤니티 질문&답변
주사위앱 소개 및 레이아웃 설정 문제
작성
·
35
0
Bold체 및 검은색 배경 설정과 흰색 글꼴 적용이 되지 않습니다.
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
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:id="@+id/main"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:background="#008000"
tools:context=".MainActivity">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="200dp"
android:layout_marginTop="100dp">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textSize="30sp"
android:textColor="@color/black"
android:gravity="center"
android:layout_margin="20dp"
android:textStyle="bold"
android:text="인생은 주사위 한방에 가는거 아니겠습니까?"/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="200dp"
android:weightSum="2">
<ImageView
android:src="@drawable/dice_1"
android:layout_width="120dp"
android:layout_height="120dp"
android:layout_weight="1"/>
<ImageView
android:src="@drawable/dice_2"
android:layout_width="120dp"
android:layout_height="120dp"
android:layout_weight="1"/>
</LinearLayout>
<Button
android:text="인생 고고"
android:layout_width="match_parent"
android:layout_height="50dp"
android:background="@color/black"
android:textColor="@color/white"
android:layout_margin="50dp"/>
</LinearLayout>


답변 2
0
0
안녕하세요, 인프런 AI 인턴입니다. 최진혁님.
안드로이드 앱에서 레이아웃을 설정할 때 특정 스타일이 적용되지 않는 경우, 몇 가지 점을 확인할 필요가 있습니다. 주요 문제는 다음과 같습니다:
배경색 및 텍스트 스타일:
android:background="@color/black"와android:textColor="@color/white"속성이 적용되지 않을 때는 관련 색상이res/values/colors.xml파일에 제대로 정의되어 있는지 확인해 보세요.#000000과#FFFFFF를 직접 사용해보는 것도 방법입니다.텍스트 스타일:
android:textStyle="bold"는 텍스트가 볼드체로 나타나도록 합니다. 이 속성이 적용되지 않는다면,android:textStyle속성이 다른 스타일에 의해 덮어씌워지고 있는지 XML 파일을 확인해 보세요.강조된 부분: XML에서는 개선할 수 있는 부분들이 있습니다. 특히, 하드코딩된 문자열을 리소스 파일로 이동하거나 이미지에 적절한
contentDescription을 추가하는 것이 좋습니다. 이는 코드의 유연성을 높이고, 접근성을 개선해 줍니다.
아래 링크는 유사한 문제를 다룬 다른 질문들과 그 해결법을 포함하고 있습니다:
주사위앱 관련해서 질문 있습니다!: 레이아웃에서 레이아웃이 어긋나거나 텍스트 혹은 이미지의 위치가 예상과 다를 때 해결방안을 제시합니다.
글씨가 잘려서 뜹니다.: LinearLayout과 TextView가 포함된 레이아웃에서의 텍스트 표시 문제를 해결하는 방법을 다룹니다.
저는 질문자님의 이해를 돕고자 지식공유자님의 기존 답변을 참고하여 유사한 답변 링크를 추천해드리고 있습니다. 현재 베타 기능으로 답변이 만족스럽지 않을 수 있는 점 양해 부탁드립니다. 🙏 추가적으로 궁금한 점이 있으시면, 이어서 질문해 주세요. 곧 지식공유자께서 답변해 주실 것입니다.






안녕하세요
저도 테스트를 위해 전체 프로젝트를 github나 구글 드라이브에 올려놓으신 후, 링크를 공유해주시면 살펴보겠습니다!