java My XML文件不显示任何内容
我不明白为什么显示屏上什么也没出现。我可以看到按钮和ImageView(Zauber),但除此之外什么都看不到。。有人能帮我吗
<FrameLayout xmlns:安卓="http://schemas.安卓.com/apk/res/安卓"
xmlns:app="http://schemas.安卓.com/apk/res-auto"
安卓:orientation="vertical"
安卓:layout_width="fill_parent"
安卓:layout_height="fill_parent"
安卓:background="@color/halbtransparent">
<ImageView
安卓:layout_width="wrap_content"
安卓:layout_height="wrap_content"
app:srcCompat="@drawable/dialoghintergrund"
安卓:id="@+id/willdialog"
安卓:layout_margin="20dp" />
<ImageView
安卓:scaleType="fitXY"
安卓:id="@+id/zauberer"
安卓:layout_marginTop="40dp"
安卓:layout_marginLeft="50dp"
安卓:layout_marginStart="50dp"
app:srcCompat="@drawable/zaubererdialoghg"
安卓:layout_height="55dp"
安卓:layout_width="43dp" />
<ImageButton
安卓:id="@+id/btn_verstanden"
安卓:scaleType="fitXY"
安卓:layout_width="130dp"
安卓:layout_marginTop="410dp"
安卓:layout_gravity="center_horizontal"
安卓:background="#00000000"
安卓:layout_height="50dp"
app:srcCompat="@drawable/btn_verstanden"/>
# 1 楼答案
几点建议:
fill_parent
不推荐使用match_parent
用
android:src
代替app:srcCompat
您使用的是静态Dp值
android:layout_marginTop="410dp"
,它将根据像素密度在不同的设备中变化使用
layout_weight
、weightSum
、adJustViewBounds
、Gravity
来对齐视图mdpi
、hdpi
、xhdpi
等文件夹中使用不同大小drawable
的最佳实践李>试试这个:
# 2 楼答案
在
Activity
或Android Studio中没有显示任何内容?你关闭了Framelayout
标签了吗?尝试使用Relativelayout
。确保你的setContentView
中有Activity
# 3 楼答案
之所以会出现这种情况,是因为FrameLayout中的子布局相互重叠,并且底部写入的子布局被绘制在其他布局之上。使用“方向”设置为“垂直”的LinearLayout来解决问题