Issue
I've a problem with an image in an activity. For some reason the ImageView is visible in the Android Studio preview, but not when I build it on device or emulator. In any other activity it's working correctly. I'm not an expert in Android and I can't figure out what is the problem.
<?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:id="@+id/activity_map"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="MapsActivity"
android:backgroundTint="@color/ColoreSfondo">
<ImageView
android:id="@+id/imageView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="@+id/map"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_toLeftOf="@+id/numeroRisultatiMappa"
android:layout_toStartOf="@+id/numeroRisultatiMappa"
android:contentDescription="@string/logoDescription"
app:srcCompat="@drawable/logo" />
<fragment xmlns:map="http://schemas.android.com/apk/res-auto"
android:id="@+id/map"
android:name="com.google.android.gms.maps.SupportMapFragment"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_above="@+id/buttonMapToHome"
android:layout_below="@+id/numeroRisultatiMappa"
tools:context="MapsActivity" />
<Button
android:text="@string/buttonhome"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/buttonMapToHome"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:background="@drawable/my_button_bg"
android:textColor="@android:color/white"
android:textStyle="normal|bold" />
<Button
android:text="@string/toList"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/buttonMapToList"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true"
android:layout_toEndOf="@+id/buttonMapToHome"
android:layout_toRightOf="@+id/buttonMapToHome"
android:background="@drawable/my_button_bg"
android:textColor="@android:color/white"
android:textStyle="normal|bold" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:id="@+id/numeroRisultatiMappa"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true"
android:textAppearance="@style/TextAppearance.AppCompat.Title"
android:textSize="24sp"
android:textAlignment="center"
android:layout_toEndOf="@+id/buttonMapToHome"
android:layout_toRightOf="@+id/buttonMapToHome" />
</RelativeLayout>
Any suggestion?
Solution
Please replace your fragment tag with below code.
<fragment
android:id="@+id/map"
android:name="com.google.android.gms.maps.SupportMapFragment"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_above="@+id/buttonMapToHome"
android:layout_below="@+id/imageView2"
tools:context="MapsActivity"/>
And also in imageview please change app:srcCompat="@drawable/logo" to android:src="@drawable/app_logo"
Answered By - Chirag
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.