我正在为学校项目制作一个Android应用程序(API 19),并且该应用程序正文的顶部受到标题的阻碍。在this picture中,您可以看到我想要做的事情。完全取消标题也是可取的(这: android:theme =“@ android:style / Theme.Black.NoTitleBar” 似乎没有任何效果。)< / p>
这是我的代码:
<?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 :(得分:0)
您可以删除活动代码中的标题栏:
activity.requestWindowFeature(Window.FEATURE_NO_TITLE);
答案 1 :(得分:0)
不要在ur 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>
或者你可以在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
答案 2 :(得分: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>