我想从我的应用程序中删除标题栏,但使用以下代码时,标题栏不会隐藏,实际上它变得透明并且内容向下推送:无法隐藏标题栏,变得透明
@Override
public void onCreate(Bundle savedInstanceState) {
requestWindowFeature(Window.FEATURE_NO_TITLE);
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
所以,我有一个标题栏曾经是(通知栏和应用程序之间)的差距。 我到处搜索,但还没有找到类似的东西。
编辑:
我曾经尝试都被seretum和harism(如下图所示)给出的解决方案,但我仍然无法找到的问题,这是我的XML代码的一部分:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#fff">
<ImageView android:id="@+id/title"
android:src="@drawable/main"
android:layout_width="480dp"
android:layout_height="155dp"
android:layout_centerHorizontal="true"
android:layout_alignParentTop="true"
android:adjustViewBounds="true"/>
不知何故,ImageView的不对齐到顶部相对布局的...
最后编辑时间。解决方案:
因此,我用xml修饰并发现,当您将一个自定义维度设置为一个小部件,因此使用Realtuve Layout;无论标题栏是否存在,小工具都将始终处于其下。所以,这里是解决(你需要把该对象在布局中):
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#fff">
<LinearLayout android:id="@+id/title"
android:layout_centerHorizontal="true"
android:layout_alignParentTop="true"
android:layout_width="wrap_content"
android:maxHeight="155dp"
android:maxWidth="480dp"
android:layout_height="wrap_content">
<ImageView android:src="@drawable/main"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:adjustViewBounds="true"/>
此外,我有一个RelativeLayout并使用ImageView在父级的顶部。 ImageView是被推下的。缺口填充了布局背景颜色,这就是我知道它的透明度。 – CodeKrieger 2011-04-03 21:28:48
您到目前为止提供的两种解决方案都是正确的。你的布局还有其他问题,或者正在使用一些干扰的主题,或者其他的东西。使用'hierarchyviewer'(或DDMS中的Hierarchy View透视图)可以更好地处理发生的事情。 – CommonsWare 2011-04-03 23:44:13
我编辑帖子以显示xml代码。我仍然无法解决这个问题! – CodeKrieger 2011-04-04 16:38:05