Android 带换行符的多行文本视图
我正在尝试为Google Maps pin创建一个自定义infocontents模板,当使用以下代码包装多行Android 带换行符的多行文本视图,android,xamarin,xamarin.android,xamarin.forms,google-maps-android-api-2,Android,Xamarin,Xamarin.android,Xamarin.forms,Google Maps Android Api 2,我正在尝试为Google Maps pin创建一个自定义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:l
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>
结果:
如图所示,第一个换行后的文本丢失。如果没有包裹线,或者最后一行是包裹线,那么所有的线都会完美地显示出来(见下图)。有人知道如何让它正常工作吗
建议解决了这个问题。我添加了一个RelativeLayout作为LinearLayout的父级,现在所有文本都正确显示了(工作代码见下文)
尝试使用
RelativeLayout
作为父项。
<?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>