[英]Android Layout : On Top it takes too much of space
在我的布局中
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent" android:layout_height="fill_parent"
android:id="@+id/user_pswd_new_root" android:scrollbars="vertical"
android:soundEffectsEnabled="true">
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/ScrollViewLogin" android:layout_width="fill_parent" android:layout_height="wrap_content" android:scrollbarStyle="outsideInset" android:scrollbars="vertical|horizontal" android:visibility="visible">
<RelativeLayout android:layout_width="fill_parent" android:id="@+id/relativeLayout1" android:layout_height="fill_parent">
<ImageView android:background="@drawable/logo_login" android:layout_height="wrap_content" android:id="@+id/imageView1"
android:layout_width="wrap_content" android:layout_alignParentTop="true" android:layout_centerHorizontal="true"
android:padding="0dp" android:layout_margin="0dp"/>
...............
</RelativeLayout>
</ScrollView>
</RelativeLayout>
使用上面的代码,我在Dialog中进行设置,并且可以正确显示事物,但是图像上方有很多不需要的空间,这不必要地增加了对话框的高度。 查看结果:
知道为什么顶部空间会被占用。 以及我如何摆脱它。 我要去哪里错了?
它是Dialog
的标题,它为空,因为您没有指定标题(但视图仍然存在)。 您必须删除它,例如:
class MyDialog extends Dialog {
@Override
protected void onCreate(Bundle savedInstanceState) {
// make sure to call requestWindowFeature before setContentView
requestWindowFeature(Window.FEATURE_NO_TITLE);
setContentView(R.layout.my_dialog_layout);
// other initialization code
}
// ...
}
但这取决于您使用的是简单Dialog
还是AlertDialog
。 如果这对您不起作用,请发布您的对话框创建代码(Java),然后我将更新答案以显示如何删除案件标题。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.