我不明白为什么显示屏上没有任何显示。我可以看到按钮和 ImageView (zauberer),但除此之外什么都没有..有人可以帮助我吗?
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@color/halbtransparent">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:srcCompat="@drawable/dialoghintergrund"
android:id="@+id/willdialog"
android:layout_margin="20dp" />
<ImageView
android:scaleType="fitXY"
android:id="@+id/zauberer"
android:layout_marginTop="40dp"
android:layout_marginLeft="50dp"
android:layout_marginStart="50dp"
app:srcCompat="@drawable/zaubererdialoghg"
android:layout_height="55dp"
android:layout_width="43dp" />
<ImageButton
android:id="@+id/btn_verstanden"
android:scaleType="fitXY"
android:layout_width="130dp"
android:layout_marginTop="410dp"
android:layout_gravity="center_horizontal"
android:background="#00000000"
android:layout_height="50dp"
app:srcCompat="@drawable/btn_verstanden"/>
最佳答案
一些建议:
fill_parent
已弃用使用match_parent
使用
android:src
而不是app:srcCompat
您正在使用静态 Dp 值
android:layout_marginTop="410dp"
根据像素密度在不同设备中会有所不同。
使用layout_weight
, weightSum
, adJustViewBounds
, Gravity
调整您的观点..
- 使用不同尺寸的最佳实践
drawable
您的mdpi
中的图像,hdpi
,xhdpi
等文件夹。
试试这个:
<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:background="@color/colorPrimary"
android:orientation="vertical">
<ImageView
android:id="@+id/willdialog"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="20dp"
android:src="@mipmap/ic_launcher" />
<ImageView
android:id="@+id/zauberer"
android:layout_width="43dp"
android:layout_height="55dp"
android:layout_marginLeft="50dp"
android:layout_marginStart="50dp"
android:layout_marginTop="40dp"
android:scaleType="fitXY"
android:src="@mipmap/ic_launcher" />
<ImageButton
android:id="@+id/btn_verstanden"
android:layout_width="130dp"
android:layout_height="50dp"
android:layout_gravity="center_horizontal"
android:layout_marginTop="100dp"
android:background="#00000000"
android:scaleType="fitXY"
android:src="@mipmap/ic_launcher" />
</LinearLayout>
关于java - 我的 XML 文件不显示任何内容,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42898083/