Android 消隐图像
好的,很简单: 我应该得到这个: 但出于某种神奇的原因,我得到了这个: 测试代码:Android 消隐图像,android,android-activity,android-imageview,Android,Android Activity,Android Imageview,好的,很简单: 我应该得到这个: 但出于某种神奇的原因,我得到了这个: 测试代码: <?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" android:orientation="ve
<?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"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="match_parent" android:paddingTop="100dp">
<ImageView
android:id="@+id/imageView"
android:layout_width="match_parent"
android:layout_height="100dp"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_alignParentTop="true"
app:srcCompat="@drawable/ic_dislike" />
<ImageButton
android:id="@+id/imageButton"
android:layout_width="match_parent"
android:layout_height="100dp"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_below="@+id/imageView"
android:layout_marginTop="20dp"
app:srcCompat="@mipmap/ic_launcher" />
</RelativeLayout>
尝试删除布局中ImageButton此行中的“+”:
android:layout_below="@+id/imageView"
因为“+”应该只在“android:id”参数上使用,以便为视图分配id
有了这个额外的“+”布局,下面的_应该无法正确定位图像下方的按钮
另一种可能是尝试将所有“app:srcCompat”替换为“android:src”,因为您没有使用任何矢量绘图工具。尝试删除布局中ImageButton此行中的“+”:
android:layout_below="@+id/imageView"
因为“+”应该只在“android:id”参数上使用,以便为视图分配id
有了这个额外的“+”布局,下面的_应该无法正确定位图像下方的按钮
另一种可能是尝试将所有“app:srcCompat”替换为“android:src”,因为您没有使用任何矢量绘图功能。确保build.gradle文件中有
vectorDrawables.useSupportLibrary=true
android {
defaultConfig {
vectorDrawables.useSupportLibrary = true
}
}
确保build.gradle文件中有
vectorDrawables.useSupportLibrary=true
android {
defaultConfig {
vectorDrawables.useSupportLibrary = true
}
}
不,这似乎管用。我忘了提,它只发生在那一项活动中不,似乎不起作用。我忘了提,它只发生在那一个活动中。竖起大拇指,感谢你的注意!!!(我不知道为什么它会这样自动完成)但无论如何,它并没有解决这个问题;(………(我还没有用“测试代码”测试过它,只有一个真实代码)所以,试着用“android:src”替换所有的“app:srcCompat”,因为你没有使用任何矢量绘图工具。耶,这就是问题所在!!谢谢你的帮助。(你应该编辑“Awnser”并添加这个“补丁”)注意到了!!(我不知道为什么它会这样自动完成)但无论如何,它并没有解决问题;(……(我没有用“测试代码”测试它,只有真实代码)所以,试着用“android:src”替换所有的“app:srcCompat”,因为你没有使用任何vector drawables。耶,这就是问题所在!!谢谢你的帮助。(虽然,你应该编辑“Awnser”并添加这个“补丁”)