마스터Q&A 안드로이드는 안드로이드 개발자들의 질문과 답변을 위한 지식 커뮤니티 사이트입니다. 안드로이드펍에서 운영하고 있습니다. [사용법, 운영진]

constraintlayout에서 margin주기 질문좀 드립니다.

0 추천

<LinearLayout
        android:id="@+id/linear2"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="horizontal"
        app:layout_constraintTop_toBottomOf="@id/line2"
        android:layout_margin="10dp"
        android:gravity="right">
        <RatingBar
            android:id="@+id/stars"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="center_vertical"
            android:numStars="5"
            android:rating="4.0"
            android:stepSize="0.1"
            style="@style/Widget.AppCompat.RatingBar.Small" />
        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="8.2 (1,142명 참여)"
            android:textSize="20dp"/>
    </LinearLayout>

    <View
        android:id="@+id/line3"
        android:layout_width="match_parent"
        android:layout_height="10dp"
        app:layout_constraintTop_toBottomOf="@id/linear2"
        android:background="@drawable/linearlayout_horizontal_line"/>

<사진 부분 코드>

<layer-list xmlns:android="http://schemas.android.com/apk/res/android">

    <!-- 음수(-)값을 주면 테두리가 없어짐 -->
    <!-- 해당 값만큼 여백을 준다는 뜻 -->
    <item
        android:bottom="-10dp"
        android:top="0dp"
        android:left="-10dp"
        android:right="-10dp">
        <shape android:shape="rectangle">
            <stroke
                android:width="10dp"
                android:color="@color/lightgray"/>
        </shape>
    </item>
</layer-list>

+) 혹시나 해서 회색 수평선(View 태그) 이 어떻게 되어있는지 올려드립니다. drawable에 짜여있습니다!

 

---------

사진에서 파란색 부분(마우스 올려놓은부분인데 캡쳐에는 마우스 커서가 안나와있네요) 과

그 위 별점 및 참여인원 부분(Linearlayout)의 코드입니다.

질문 드릴것은 Linearlayout을 보시면 margin을 10dp 준상태인데 위와 좌우에는 margin이 적영된것이

보이는데 아래 회색 수평선(View 태그)에는 margin이 적용되어있지 않고 Linearlayout과 딱 붙어있는데요.

이게 어찌된 일일까요..?

codeslave (3,940 포인트) 님이 2020년 9월 14일 질문

답변 달기

· 글에 소스 코드 보기 좋게 넣는 법
· 질문에 대해 추가적인 질문이나 의견이 있으면 답변이 아니라 댓글로 달아주시기 바랍니다.
표시할 이름 (옵션):
개인정보: 당신의 이메일은 이 알림을 보내는데만 사용됩니다.
스팸 차단 검사:
스팸 검사를 다시 받지 않으려면 로그인하거나 혹은 가입 하세요.
...