Ben
Ben

Reputation: 59

ImageView (logo) not showing in 2nd Activity

In android Studio I have 2 activities. 1st is a login screen with my logo. the 2nd is details, with my logo. in the studio everything looks ok, but when testing on my phone, it displays everything except for my imageView (logo). I have tried, different images, different positions. I have even cut and paste the layout code from my main activity (which works fine). Nothing works.

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout 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:gravity="center_horizontal"
    android:orientation="vertical"
    android:paddingBottom="@dimen/activity_vertical_margin"
    android:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:paddingTop="@dimen/activity_vertical_margin"
    tools:context=".MainActivity"
    android:weightSum="1">

        <!-- Login progress -->




    <TextView
                android:id="@+id/longitude"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_centerHorizontal="true" />

    <ImageView
        android:id="@+id/imageView4"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        app:srcCompat="@drawable/ic_action_name"
        android:layout_weight="0.42" />

    <TextView
                android:id="@+id/latitude"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_below="@id/longitude"
                android:layout_centerHorizontal="true"/>

    <TextView
        android:id="@+id/driver"
        android:layout_width="32dp"
        android:layout_height="wrap_content"
        android:layout_alignLeft="@+id/location"
        android:layout_alignStart="@+id/location"
        android:layout_below="@+id/latitude"
        android:layout_marginTop="66dp"
        android:layout_weight="0.02" />

</LinearLayout>

Upvotes: 1

Views: 151

Answers (1)

Joy Hard
Joy Hard

Reputation: 319

Use

android:src="@drawable/ic_action_name"

It will set your drawable as the content of this ImageView.

Upvotes: 2

Related Questions