Java 图像视图(徽标)未显示在第二个活动中
在android Studio中,我有两项活动。第一个是带有我的徽标的登录屏幕。第二个是细节,带有我的标志。在studio中,一切看起来都正常,但在我的手机上测试时,它会显示除我的imageView(徽标)之外的所有内容。我试过,不同的图像,不同的位置。我甚至从我的主要活动中剪切并粘贴了布局代码(效果很好)。什么都不管用Java 图像视图(徽标)未显示在第二个活动中,java,android,android-studio,imageview,Java,Android,Android Studio,Imageview,在android Studio中,我有两项活动。第一个是带有我的徽标的登录屏幕。第二个是细节,带有我的标志。在studio中,一切看起来都正常,但在我的手机上测试时,它会显示除我的imageView(徽标)之外的所有内容。我试过,不同的图像,不同的位置。我甚至从我的主要活动中剪切并粘贴了布局代码(效果很好)。什么都不管用 <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://sche
<?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>
使用
它会将您的drawable设置为此ImageView的内容。尝试使用background代替app:srcCompat,或者仅使用实际有效的android:srcCompat。。。有意思。。属性不提供src选项。但是非常感谢如果想知道它们之间的区别,请查看链接:
android:src="@drawable/ic_action_name"