android - 标记布局未在 map 中正确显示

标签 android android-layout android-relativelayout

我正在为司机制作一个交通应用程序。我想像这个设计一样显示带有名称的停靠点。

Design

我正在为此使用 RelativeLayout 但在启动应用程序后停止名称也出现在中心。 enter image description here

实际的实现是这样的。

这是我的标记布局。

<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/

相关文章:

android - 如何使用 webview 播放 flash 来管理 z-order

android - 8.9 英寸平板电脑上没有静态尺寸且没有低分辨率图像的 LinearLayout

android - 以编程方式相对布局

androidrelativelayout 两行,右边一列

android - 如何将数据变量传递给包含的布局?

android - 如何增加android中字符串某些部分的字体大小?

java - Android 将两个按钮对齐在同一行

java - gradle 同步时出错

java - relativelayout无法转换为textview

使用 ScrollView 返回 Fragment 时的 Android 共享元素转换