강의

멘토링

로드맵

인프런 커뮤니티 질문&답변

Jindevelopment님의 프로필 이미지
Jindevelopment

작성한 질문수

[왕초보편] 앱 8개를 만들면서 배우는 안드로이드 코틀린(Android Kotlin)

주사위앱 소개 및 레이아웃 설정

주사위앱 소개 및 레이아웃 설정 문제

작성

·

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>
image.png
image.png

답변 2

0

위 방법 모두 해결이 되진 않네요

개복치개발자님의 프로필 이미지
개복치개발자
지식공유자

안녕하세요

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

0

안녕하세요, 인프런 AI 인턴입니다. 최진혁님.

안드로이드 앱에서 레이아웃을 설정할 때 특정 스타일이 적용되지 않는 경우, 몇 가지 점을 확인할 필요가 있습니다. 주요 문제는 다음과 같습니다:

  1. 배경색 및 텍스트 스타일: android:background="@color/black"android:textColor="@color/white" 속성이 적용되지 않을 때는 관련 색상이 res/values/colors.xml 파일에 제대로 정의되어 있는지 확인해 보세요. #000000#FFFFFF를 직접 사용해보는 것도 방법입니다.

  2. 텍스트 스타일: android:textStyle="bold"는 텍스트가 볼드체로 나타나도록 합니다. 이 속성이 적용되지 않는다면, android:textStyle 속성이 다른 스타일에 의해 덮어씌워지고 있는지 XML 파일을 확인해 보세요.

  3. 강조된 부분: XML에서는 개선할 수 있는 부분들이 있습니다. 특히, 하드코딩된 문자열을 리소스 파일로 이동하거나 이미지에 적절한 contentDescription을 추가하는 것이 좋습니다. 이는 코드의 유연성을 높이고, 접근성을 개선해 줍니다.

아래 링크는 유사한 문제를 다룬 다른 질문들과 그 해결법을 포함하고 있습니다:

저는 질문자님의 이해를 돕고자 지식공유자님의 기존 답변을 참고하여 유사한 답변 링크를 추천해드리고 있습니다. 현재 베타 기능으로 답변이 만족스럽지 않을 수 있는 점 양해 부탁드립니다. 🙏 추가적으로 궁금한 점이 있으시면, 이어서 질문해 주세요. 곧 지식공유자께서 답변해 주실 것입니다.

Jindevelopment님의 프로필 이미지
Jindevelopment

작성한 질문수

질문하기