Android 布局:在顶部占用太多空间
在我的布局中
<?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>
,使用上面的代码,我在一个对话框中进行设置,并且内容正确显示,但是图像上方有很多不需要的空间,这不必要地增加了对话框的高度。查看结果:
知道为什么顶部空间被占用。以及我该如何摆脱它。我哪里出错了?
In my layout
<?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>
With the above code, I set in a Dialog and things are shown proeprly, but there is lot of unwanted space above the image which unnecessarily increases the height of the dialog. See the results :
Any idea why the top space is occupied. And how do I get rid of it. Where am I going wrong ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
它是
Dialog
的标题,它是空的,因为您没有指定标题(但视图仍然存在)。您必须删除它,例如像这样:但这取决于您使用的是简单的
Dialog
还是AlertDialog
。如果这对您不起作用,请发布您的对话框创建代码(Java),我将更新我的答案以展示如何删除您案例中的标题。It's the title of the
Dialog
, which is empty because you didn't specify a title (but the view is still there). You have to remove it, for example like this:But that depends on whether you are using a simple
Dialog
or anAlertDialog
. If this doesn't work for you, post your dialog-creation code (Java) and I'll update my answer to show how to remove the title in your case.