mapActivity 上的 ImageView
ImageView on mapActivity
我制作了一个带有学习地图的小应用程序。
在地图上,我添加了一个带有实际位置升级的 textView。
在遇到一些问题后,我使用了这样的布局:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<fragment xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:map="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/map"
android:name="com.google.android.gms.maps.SupportMapFragment"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MapsActivity" />
<TextView
android:id="@+id/txt_location"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:text="TextView"
android:textSize="30sp"
android:textAlignment="center"
android:textColor="@drawable/common_google_signin_btn_icon_light"/>
<ImageView
android:id="@+id/imageView4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="@+id/txt_location"
android:layout_centerHorizontal="true"
app:srcCompat="@drawable/ic_action_name" />
</RelativeLayout>
现在我要添加一个 imageView 来显示 gps 状态(聚焦、启用、禁用)。
我在 textView 下添加了 imageView,但我什么也没看到。
经过一些尝试,我问为什么。
ps:
如果我将 imageVIew 放在 LinearLayout 中(在地图之前),我会在地图上看到 linearLaout(黑色为 es。),但我仍然看不到图像,但最终,如果设置了背景,则只能看到背景。
添加线性布局不是我的目标,但这样我也看不到图像。
我通过 -> 新图像资产 -> 启动器图标(仅限旧版)剪贴画(android 徽标)-> mo 效果创建了图像。
比我在 imageView 中通过引用添加它。
已解决!
不知道是不是平时,
但是从设计 window 添加 ImageView,它会像我发布的那样对 Imageview 进行编码。
四处搜索我发现了类似的情况,我发现在 MapFragment 上显示图像的正确方法是更改 ImageVIew 的默认代码:
来自:
app:srcCompat="@drawable/img_name" />
至
android:src="@drawable/img_name" />
不知道是不是我插入新的ImageView做错了,
但希望这可以帮助像我一样做的人。
我制作了一个带有学习地图的小应用程序。 在地图上,我添加了一个带有实际位置升级的 textView。 在遇到一些问题后,我使用了这样的布局:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<fragment xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:map="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/map"
android:name="com.google.android.gms.maps.SupportMapFragment"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MapsActivity" />
<TextView
android:id="@+id/txt_location"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:text="TextView"
android:textSize="30sp"
android:textAlignment="center"
android:textColor="@drawable/common_google_signin_btn_icon_light"/>
<ImageView
android:id="@+id/imageView4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="@+id/txt_location"
android:layout_centerHorizontal="true"
app:srcCompat="@drawable/ic_action_name" />
</RelativeLayout>
现在我要添加一个 imageView 来显示 gps 状态(聚焦、启用、禁用)。 我在 textView 下添加了 imageView,但我什么也没看到。 经过一些尝试,我问为什么。
ps: 如果我将 imageVIew 放在 LinearLayout 中(在地图之前),我会在地图上看到 linearLaout(黑色为 es。),但我仍然看不到图像,但最终,如果设置了背景,则只能看到背景。 添加线性布局不是我的目标,但这样我也看不到图像。
我通过 -> 新图像资产 -> 启动器图标(仅限旧版)剪贴画(android 徽标)-> mo 效果创建了图像。 比我在 imageView 中通过引用添加它。
已解决!
不知道是不是平时, 但是从设计 window 添加 ImageView,它会像我发布的那样对 Imageview 进行编码。 四处搜索我发现了类似的情况,我发现在 MapFragment 上显示图像的正确方法是更改 ImageVIew 的默认代码:
来自:
app:srcCompat="@drawable/img_name" />
至
android:src="@drawable/img_name" />
不知道是不是我插入新的ImageView做错了, 但希望这可以帮助像我一样做的人。