Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ImageView displaying in layout but not on actual device

I have an ImageView that I want to display matching the full width of the device, I realized that like this:

<ImageView     android:id="@+id/home_bar_newvault"     android:layout_width="wrap_content"     android:layout_height="40dp"     android:scaleType="centerCrop"     android:layout_alignParentBottom="true"     android:src="@drawable/home_bar" /> 

The home_bar is a PNG image file with the following dimensions: 2399x254. When I choose to view the Graphical Layout of the UI it displays the imageview correctly at the bottom of the activity. However, when I start the application on my device it won't display the Imageview at all.

like image 909
Tim Kranen Avatar asked Aug 15 '13 10:08

Tim Kranen


People also ask

How do I make an ImageView accessible?

You can do this by adding the contentDescription attribute to your XML layout. It can also be done programmatically by calling the setContentDescription method in your Java file. Either method provides TalkBack with all the necessary information to describe the ImageView to users.


1 Answers

I had the same issue, it is only showing in Design tab for Android Studio 2.2.

What I did to make it work is to change the automatic key assigned (populated via Drag/Drop ImageView) from app:srcCompat="@drawable/logo" to android:src="@drawable/logo" in Text tab to make it appear on both the emulator and the device e.g

<ImageView     android:layout_width="wrap_content"     android:layout_height="wrap_content"     android:src="@drawable/logo"     android:layout_alignParentTop="true"     android:layout_centerHorizontal="true"     android:layout_marginTop="75dp"     android:id="@+id/logoImageView"     android:scaleType="fitXY"     android:scaleX="1.5"     android:scaleY="1.5" /> 
like image 158
Woppi Avatar answered Sep 28 '22 11:09

Woppi