我很抱歉标题不清楚,只是因为我没有这个名字的名字。无论如何,这是应用程序主屏幕的图片:
我想删除顶部的蓝色条/标题/行(它显示时间和电池..)如果我不能删除它比至少修改它通过将其颜色更改为黑色的东西更适合背景布局。谢谢你,诺姆
顶部的蓝色栏称为“状态栏”。您可以通过设置android:colorPrimaryDark
(或colorPrimaryDark
,如果您使用的是AppCompat主题)来控制它的颜色。
如果您从Android Studio模板启动项目,那么您应该有一个定义了styles.xml
的AppTheme
文件。其中一条线应如下所示:
<item name="colorPrimaryDark">@color/primaryDark</item>
您可以在此处直接更改值,例如@android:color/black
,或者进入定义colors.xml
的primaryDark
,然后将其更改为黑色。
如果要完全隐藏状态栏,请参阅Lino's answer。
是的,您可以通过编程方式隐藏状态栏。以下是Android 4.1及更高版本的步骤:
View decorView = getWindow().getDecorView();
// Hide the status bar.
int uiOptions = View.SYSTEM_UI_FLAG_FULLSCREEN;
decorView.setSystemUiVisibility(uiOptions);
// Remember that you should never show the action bar if the
// status bar is hidden, so hide that too if necessary.
ActionBar actionBar = getActionBar();
actionBar.hide();
有关更多详细信息(以及较低的Android版本),请参阅:https://developer.android.com/training/system-ui/status.html
那条蓝线叫做StatusBar
。
有两种方法可以做到这一点
如果你想以编程方式做到这一点:
public class MainActivity extends Activity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
setContentView(R.layout.main_activity);
}
}
或者在你的AndroidManifest.xml文件中:
<activity android:name=".MainActivity"
android:label="@string/app_name"
android:theme="@android:style/Theme.NoTitleBar.Fullscreen"/>
在3.0.1中使用AppCompatActivity通过添加清单解决了这个问题:
application android:theme="@style/AppTheme.NoActionBar"