2014-02-11 65 views
0

我正在为学校项目制作Android应用程序(API 19),并且应用程序主体的顶部被标题遮住。在this picture你可以看到我正在尝试做什么。完全消除标题也可能是可取的(这里:android:theme =“@ android:style/Theme.Black.NoTitleBar”似乎没有任何效果)。标题与Android应用程序的主应用程序主体重叠

这里是我的代码:

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:tools="http://schemas.android.com/tools" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:layout_gravity="center" 
    android:background="#707070" 
    android:orientation="vertical" 
    android:theme="@android:style/Theme.Black.NoTitleBar" 
    tools:context=".FullscreenActivity" > 

    <!-- this is here only to display the first line correctly (zero container)--> 
    <LinearLayout 
     android:layout_width="match_parent" 
     android:gravity="right" 
     android:layout_height="50dp" > 

      <!--some functionality was necessary to avoid warnings--> 
     <TextClock 
      android:id="@+id/textClock1" 
      android:layout_gravity="right|center_vertical" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:text="@string/textClock" /> 
    </LinearLayout> 

    <!-- this is the first container --> 
    <LinearLayout 
     android:layout_width="match_parent" 
     android:layout_height="40dp" > 

     <!-- this is the heart rate interval progress bar --> 
     <ProgressBar 
      android:id="@+id/progressBar1" 
      style="?android:attr/progressBarStyleHorizontal" 
      android:layout_width="0dp" 
      android:layout_height="match_parent" 
      android:layout_weight="1.06" /> 

     <!-- this is a blue heart icon --> 
     <ImageButton 
      android:contentDescription="@string/heartIcon" 
      android:id="@+id/imageButton1" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:src="@drawable/button_heart_blue" /> 
    </LinearLayout> 


    <!-- code omitted --> 


</LinearLayout> 

我不愉快的“解决方案”,我想出了。有没有更清晰的方法来编写这个功能?

我将不胜感激任何帮助!谢谢!

+0

你有没有检查我的回答 – kId

+0

是的,它的工作!谢谢! – GiannisKuopio

回答

0

请勿在乌尔XML布局属性在乌拉圭回合项目的manifest文件

android:theme="@android:style/Theme.Black.NoTitleBar" 

application tag添加此像这样

<application 
     android:allowBackup="true" 
     android:icon="@drawable/ic_launcher" 
     android:label="@string/app_name" 
     android:theme="@android:style/Theme.Black.NoTitleBar" 
     android:largeHeap="true"> 

,使乌拉圭回合的应用程序全屏

activity标签ü要全屏显示这样

<activity android:name="your_activity_name"  android:theme="@android:style/Theme.Black.NoTitleBar"></activity> 

或U可以在Java代码中做

requestWindowFeature(Window.FEATURE_NO_TITLE);//for removing tittle bar 
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);//for removing notification bar if u want to remove it 
+0

我显示你3种不同的方式如何隐藏tittle酒吧你可以使用其中任何一个干杯:)如果你想隐藏tittle酒吧通过你的应用程序然后去第一个解决方案 – kId

+0

它的工作原理。我将代码放在AndroidManifest.xml文件的'activity'标记中,就像你所建议的那样。标题现在消失了。但是这个解决方案将从应用程序的所有屏幕上删除标题,而不仅仅是特定的.xml打算配置的标题。会有其他解决方案吗? – GiannisKuopio

0

您可以删除标题栏在您的活动代码调用:

activity.requestWindowFeature(Window.FEATURE_NO_TITLE); 
0

诚如其活动通过kaushik,为了完全删除所有应用程序窗口中的标题,我们必须像这样编辑AndroidManifest.xml文件:

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

    <uses-sdk 
     android:minSdkVersion="18" 
     android:targetSdkVersion="18" /> 

    <application 
     android:allowBackup="true" 
     android:icon="@drawable/ic_launcher" 
     android:label="@string/app_name" 
     android:theme="@style/AppTheme" > 

     <activity 
      android:name="com.example.myapp.FullscreenActivity" 
      android:configChanges="orientation|keyboardHidden|screenSize" 
      android:label="@string/app_name" 
      android:theme="@android:style/Theme.Black.NoTitleBar" > 
      <!-- android:theme="@style/FullscreenTheme" --> 
      <!-- this was replaced in order to get rid of the title --> 
      <intent-filter> 
       <action android:name="android.intent.action.MAIN" /> 

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

</manifest>