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

LinearLayout 위쪽 뷰와 붙이는법(초짜)

0 추천

안녕하세요 안드로이드를 공부한지 얼마되지않은 학생입니다.


<LinearLayout 
    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"
    android:orientation="vertical"
    tools:context="com.example.taewung.newbook11.MainActivity">

    (  <LinearLayout
    android:layout_marginTop="20dp"
    android:layout_marginRight="20dp"
    android:layout_marginLeft="20dp"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:orientation="horizontal"
    android:background="@drawable/shape_title">

    <ImageView
        android:padding="5dp"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:src="@drawable/star_bling"
        android:layout_gravity="left"
        android:adjustViewBounds="true"
        android:maxHeight="150dp"
        android:maxWidth="150dp"/>
    <LinearLayout
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:orientation="vertical"
        android:layout_weight="2">
        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Starry Night"/>
        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Goh"/>
    </LinearLayout>
</LinearLayout>   ) *2

</LinearLayout>

 

이렇게했을때 위쪽 뷰와 아래쪽뷰가 붙어있어야하지않나요...?

marginbottom 설정하지 않았는데 왜 둘이 떨어져있나요?

익명사용자 님이 2017년 7월 19일 질문

1개의 답변

0 추천
위쪽 뷰와 아래쪽 뷰를 무엇을 말씀하시는 지 모르겠습니다.

()*2 의 뷰를 말씀하시는 거라면, 아래 위치할 뷰 또한 margintop이 설정되어있기에 간격이 있고, 이미지 뷰에 padding이 설정되어있어 이미지 내의 이미지가 충분히 크면 두 layout간 사이 간격이 생길겁니다.
익명사용자 님이 2017년 7월 21일 답변
감사합니다!!! marginTop 부분을 생각 못하고 있었네요
...