0

如何使布局“几乎全屏”?我的意思是我不想要那个图标和应用程序名称(“测试”)。我只想显示带有电池和信号状态的顶部区域,并且能够在屏幕的其余部分绘制我想要的任何内容

图片来自 Eclipse“图形布局”3.2 英寸 HVGA 滑块 (ADP1) - 纵向

布局

我试图让我的布局填充父项并删除其他所有内容,但该图标和文本仍然存在

布局xml

 <?xml version="1.0" encoding="utf-8"?>
 <RelativeLayout
     xmlns:android="http://schemas.android.com/apk/res/android"
     android:layout_width="match_parent"
     android:layout_height="match_parent"
     android:background="#131325" 
     >    
 </RelativeLayout>

清单 xml

 <?xml version="1.0" encoding="utf-8"?>
 <manifest xmlns:android="http://schemas.android.com/apk/res/android"
     package="myTests.homeSpace"
     android:versionCode="1"
     android:versionName="1.0" >

     <uses-sdk android:minSdkVersion="15" />
     <application
         android:icon="@drawable/ic_launcher"
         android:label="@string/app_name" >
         <activity
             android:name=".TestsActivity"
             android:label="@string/app_name" >
             <intent-filter>
                 <action android:name="android.intent.action.MAIN" />

                 <category android:name="android.intent.category.LAUNCHER" />
             </intent-filter>
         </activity>

         <activity
             android:name=".screen1" >
             <intent-filter>
                 <action android:name="android.intent.action.MAIN" />
                 <category android:name="android.intent.category.LAUNCHER" />
             </intent-filter>
         </activity>
     </application>
 </manifest>

谢谢

4

2 回答 2

2

要删除图像和标题,您必须在Theme您的AndroidManifest.xml-

<?xml version="1.0" encoding="utf-8"?>
 <manifest xmlns:android="http://schemas.android.com/apk/res/android"
     package="myTests.homeSpace"
     android:versionCode="1"
     android:versionName="1.0" >

     <uses-sdk android:minSdkVersion="15" />
     <application
         android:icon="@drawable/ic_launcher" android:theme="@android:style/Theme.NoTitleBar"
         android:label="@string/app_name" >
         <activity
             android:name=".TestsActivity" android:theme="@android:style/Theme.NoTitleBar"
             android:label="@string/app_name" >
             <intent-filter>
                 <action android:name="android.intent.action.MAIN" />

                 <category android:name="android.intent.category.LAUNCHER" />
             </intent-filter>
         </activity>

         <activity
             android:name=".screen1" android:theme="@android:style/Theme.NoTitleBar">
             <intent-filter>
                 <action android:name="android.intent.action.MAIN" />
                 <category android:name="android.intent.category.LAUNCHER" />
             </intent-filter>
         </activity>
     </application>
 </manifest>

看看Theme_NoTitleBar您也可以使用以下代码以编程方式执行此操作。

@Override
public void onCreate(Bundle savedInstanceState)
{
    super.onCreate(savedInstanceState);
    requestWindowFeature(Window.FEATURE_NO_TITLE);
    setContentView(R.layout.main);
}

你必须requestWindowFeature(Window.FEATURE_NO_TITLE);在调用setContentView(R.layout.main);唯一之前使用。如果您想将它用于所有活动,那么您必须在setContentView(R.layout.main);方法之前给每个活动。

于 2012-06-26T10:35:33.803 回答
0

或者在java中

@Override
protected void onCreate(Bundle savedInstanceState)
{
    super.onCreate(savedInstanceState);

    requestWindowFeature(Window.FEATURE_NO_TITLE);//<-----------
于 2012-06-26T10:40:01.653 回答