[英]Android Layout : On Top it takes too much of space
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. 使用上面的代码,我在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 ?
我要去哪里错了?
It's the title of the Dialog
, which is empty because you didn't specify a title (but the view is still there). 它是
Dialog
的标题,它为空,因为您没有指定标题(但视图仍然存在)。 You have to remove it, for example like this: 您必须删除它,例如:
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
}
// ...
}
But that depends on whether you are using a simple Dialog
or an AlertDialog
. 但这取决于您使用的是简单
Dialog
还是AlertDialog
。 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. 如果这对您不起作用,请发布您的对话框创建代码(Java),然后我将更新答案以显示如何删除案件标题。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.