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

프리뷰와 실제 구동 모습이 다릅니다

0 추천

안녕하세요

리스트뷰 연습중인데 어떤 문제인지 모르겠습니다.

도시명 아래 '번호'는 textview로 gravity = end 값을 주었고 우측 프리뷰의 모습처럼 나와야하는데

실제 실행결과를 보면 도시명 우측라인에 맞춰 표시되고 있습니다.

layout_width도 match_parent로 했는데 어떤 수정이 필요할까요..

 

 

 

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="wrap_content">

    <ImageView
        android:id="@+id/weather_image"
        android:layout_width="100dp"
        android:layout_height="100dp"
        android:src="@mipmap/ic_launcher"/>

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="vertical"
        android:padding="8dp">

        <TextView
            android:id="@+id/city_text"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            tools:text="도시명"
            android:textSize="25dp"/>

        <TextView
            android:id="@+id/temp_text"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:gravity="end"
            tools:text="번호"/>

    </LinearLayout>


</LinearLayout>
카쇼페아 (180 포인트) 님이 2020년 6월 15일 질문

2개의 답변

0 추천
이유는 저도 잘 모르지만 match_parent가 안먹을때는 RelativeLayout으로 한번 감싸주면 해결되는 상황이 많습니다.

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="wrap_content">

<LinearLayout
    android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="horizontal">

    <ImageView
        android:id="@+id/weather_image"
        android:layout_width="100dp"
        android:layout_height="100dp"
        android:src="@mipmap/ic_launcher"/>

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="vertical"
        android:padding="8dp">

        <TextView
            android:id="@+id/city_text"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            tools:text="도시명"
            android:textSize="25dp"/>

        <TextView
            android:id="@+id/temp_text"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:gravity="end"
            tools:text="번호"/>

    </LinearLayout>
</LinearLayout>

</RelativeLayout>
버닝 (4,880 포인트) 님이 2020년 6월 15일 답변
오 한방에 해결됐습니다..!!! 감사합니다!!!
0 추천
논리적으로 두번째 LinearLayout의 android:layout_height="match_parent" 값이 맞지 않습니다.

첫번째 LinearLayout의 height가 고정값을 가지거나,

두번째 LinearLayout의 height가 고정값이거나 wrap_contents 이어야 합니다.
디자이너정 (42,810 포인트) 님이 2020년 6월 15일 답변
...