图片在设备中不可见但在布局中可见 Android
Image not visible in device but visible in layout Android
我想在我的 android 应用程序中添加一些图像。
这是XML代码-
<?xml version="1.0" encoding="utf-8"?>
<android.widget.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_launcher"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/colorPrimaryDark"
tools:context="com.example.rishabhgambhir.findthelost.Launcher">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:srcCompat="@mipmap/logo21"
android:id="@+id/mainlogo"
android:contentDescription="main logo"
tools:layout_constraintBottom_creator="1"
app:layout_constraintBottom_toTopOf="@+id/imageView2"
tools:layout_constraintLeft_creator="1"
app:layout_constraintLeft_toLeftOf="@+id/imageView2"
android:layout_above="@+id/imageView2"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_marginLeft="84dp"
android:layout_marginStart="84dp"
android:layout_marginBottom="113dp" />
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:srcCompat="@mipmap/transparent_text_effect"
android:id="@+id/imageView2"
tools:layout_constraintRight_creator="1"
tools:layout_constraintBottom_creator="1"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintRight_toRightOf="parent"
android:layout_marginBottom="85dp"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true" />
</android.widget.RelativeLayout>
这里可能有什么问题?
您可以在图像视图中添加一行 xml。
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@mipmap/ic_launcher"
android:id="@+id/mainlogo"
android:contentDescription="main logo"
tools:layout_constraintBottom_creator="1"
app:layout_constraintBottom_toTopOf="@+id/imageView2"
tools:layout_constraintLeft_creator="1"
app:layout_constraintLeft_toLeftOf="@+id/imageView2"
android:layout_above="@+id/imageView2"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_marginLeft="84dp"
android:layout_marginStart="84dp"
android:layout_marginBottom="113dp" />
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@mipmap/ic_launcher"
android:id="@+id/imageView2"
tools:layout_constraintRight_creator="1"
tools:layout_constraintBottom_creator="1"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintRight_toRightOf="parent"
android:layout_marginBottom="85dp"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true" />
我想在我的 android 应用程序中添加一些图像。
这是XML代码-
<?xml version="1.0" encoding="utf-8"?>
<android.widget.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_launcher"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/colorPrimaryDark"
tools:context="com.example.rishabhgambhir.findthelost.Launcher">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:srcCompat="@mipmap/logo21"
android:id="@+id/mainlogo"
android:contentDescription="main logo"
tools:layout_constraintBottom_creator="1"
app:layout_constraintBottom_toTopOf="@+id/imageView2"
tools:layout_constraintLeft_creator="1"
app:layout_constraintLeft_toLeftOf="@+id/imageView2"
android:layout_above="@+id/imageView2"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_marginLeft="84dp"
android:layout_marginStart="84dp"
android:layout_marginBottom="113dp" />
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:srcCompat="@mipmap/transparent_text_effect"
android:id="@+id/imageView2"
tools:layout_constraintRight_creator="1"
tools:layout_constraintBottom_creator="1"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintRight_toRightOf="parent"
android:layout_marginBottom="85dp"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true" />
</android.widget.RelativeLayout>
这里可能有什么问题?
您可以在图像视图中添加一行 xml。
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@mipmap/ic_launcher"
android:id="@+id/mainlogo"
android:contentDescription="main logo"
tools:layout_constraintBottom_creator="1"
app:layout_constraintBottom_toTopOf="@+id/imageView2"
tools:layout_constraintLeft_creator="1"
app:layout_constraintLeft_toLeftOf="@+id/imageView2"
android:layout_above="@+id/imageView2"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_marginLeft="84dp"
android:layout_marginStart="84dp"
android:layout_marginBottom="113dp" />
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@mipmap/ic_launcher"
android:id="@+id/imageView2"
tools:layout_constraintRight_creator="1"
tools:layout_constraintBottom_creator="1"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintRight_toRightOf="parent"
android:layout_marginBottom="85dp"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true" />