我正在为司机制作一个交通应用程序。我想像这个设计一样显示带有名称的停靠点。
我正在为此使用 RelativeLayout
但在启动应用程序后停止名称也出现在中心。
实际的实现是这样的。
这是我的标记布局。
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#00000000"
android:layout_gravity="center_horizontal"
>
<TextView
android:id="@+id/txtStop"
android:text="test"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/patch"
android:paddingLeft="20dp"
android:paddingRight="20dp"
android:paddingTop="10dp"
android:paddingBottom="10dp"
android:textStyle="bold"
android:textSize="18sp"
android:layout_centerHorizontal="true"
android:layout_toRightOf="@+id/imgMarker" />
<ImageView
android:id="@+id/imgMarker"
android:src="@drawable/icon_marker_stops"
android:layout_width="45dp"
android:layout_height="45dp"
android:layout_below="@+id/txtStop"
android:layout_centerHorizontal="true" />
</RelativeLayout>
最佳答案
试试这段代码:
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:background="#00000000">
<TextView
android:id="@+id/txtStop"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="4dp"
android:background="@drawable/patch"
android:paddingLeft="20dp"
android:paddingTop="10dp"
android:paddingRight="20dp"
android:paddingBottom="10dp"
android:text="test"
android:textSize="18sp"
android:textStyle="bold"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintStart_toEndOf="@+id/imgMarker"
app:layout_constraintTop_toTopOf="parent" />
<ImageView
android:id="@+id/imgMarker"
android:layout_width="45dp"
android:layout_height="45dp"
android:layout_below="@+id/txtStop"
android:layout_marginTop="25dp"
android:src="@drawable/icon_marker_stops"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent" />
关于android - 标记布局未在 map 中正确显示,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53606330/