2

Google지도 핀용 맞춤 infocontents 템플릿을 만들려고하고 있는데 여러 줄 바꿈이 포함 된 텍스트가 포함 된 여러 줄을 배치 할 때 이상한 동작으로 실행됩니다. 다음 코드를 사용 :줄 바꿈이 포함 된 여러 줄의 TextView

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:paddingBottom="4dp" 
    android:paddingTop="4dp" 
    android:orientation="vertical"> 
    <ImageView 
     android:id="@+id/OfficeImage" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_gravity="top|center_horizontal" 
     android:scaleType="centerInside" 
     android:adjustViewBounds="true" 
     android:maxWidth="175dp"/> 
    <TextView 
     android:layout_marginTop="10dp" 
     android:id="@+id/InfoWindowTitle" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:text="Sunshine Coast" 
     android:textColor="@android:color/black" 
     android:textStyle="bold"/> 
    <TextView 
     android:id="@+id/InfoWindowSubtitle" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:singleLine="false" 
     android:textSize="10dp" 
     android:text="Level 3, 2 Emporio Place\n2 Maroochy Blvd, Maroochydore QLD 4558\nPo Box 5800, Maroochydore BC QLD 4558" 
     android:maxLines="10" 
     android:textColor="@android:color/black"/> 
</LinearLayout> 

결과 : 제 래핑 라인 이후의 텍스트가없는 화상에 나타낸 바와 같이

Result

. 래핑 된 줄이 없거나 마지막 줄이 줄 바꿈 된 줄이면 모든 줄이 완벽하게 표시됩니다 (아래 이미지 참조). 누구든지 제대로 작동하도록하는 방법을 알고 있습니까?

Expected Result

+1

부모로 'RelativeLayout'을 사용해보세요. –

답변

1

Muhammad Babar's 제안은 문제를 해결합니다. RelativeLayout을 LinearLayout의 부모로 추가하고 이제는 모든 텍스트가 올바르게 표시됩니다 (아래 작업 코드 참조).

<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content"> 
    <LinearLayout 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:paddingBottom="4dp" 
    android:paddingTop="4dp" 
    android:orientation="vertical"> 
    <ImageView 
     android:id="@+id/OfficeImage" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_gravity="top|center_horizontal" 
     android:scaleType="centerInside" 
     android:adjustViewBounds="true" 
     android:maxWidth="175dp"/> 
    <TextView 
      android:layout_marginTop="10dp" 
      android:id="@+id/InfoWindowTitle" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:text="Sunshine Coast" 
      android:textColor="@android:color/black" 
      android:textStyle="bold"/> 
    <TextView 
     android:id="@+id/InfoWindowSubtitle" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:textSize="10dp" 
     android:text="Level 3, 2 Emporio Place\n2 Maroochy Blvd, Maroochydore QLD 4558\nPo Box 5800, Maroochydore BC QLD 4558" 
     android:maxLines="10" 
     android:textColor="@android:color/black"/> 
    </LinearLayout> 
</RelativeLayout> 
관련 문제