我想知道是否可以更改状态栏图标颜色(而不是状态栏颜色colorPrimaryDark
)
假设我想要这个状态栏:
<item name="colorPrimaryDark">@android:color/white</item>
和黑色的图标,这可能吗?
谢谢.
编辑:
M开发人员预览中的新功能:windowLightStatusBar.在主题中翻转它会告诉系统使用深色前景,对浅色状态栏很有用.请注意,M预览似乎有一个错误,通知图标保持白色,而系统状态图标正确地变为半透明黑色.
来自:Roman Nurik的 Google+ 帖子
android android-styles android-5.0-lollipop android-statusbar
我提到了这个链接.在如果上的EditText用户点击(为前要:)在那个时候键盘会被弹出,并在同一时间,用户可以可以滚动查看所有剩余的视图(例如:撰写,主题,发送按钮),那个屏幕.同样在我的应用程序中,我有一个活动,我有一些小部件或视图.假设用户点击我的Activity中的Edittext然后键盘弹出,我可以滚动查看剩余的视图.但是如果我android:theme="@android:style/Theme.NoTitleBar.Fullscreen"
在清单中给出这个属性我无法滚动查看剩余的视图但是如果android:theme="@android:style/Theme.NoTitleBar"
在清单中给出这样的属性我可以滚动查看剩余视图但是在该屏幕中有状态栏,这里我想要全屏和即使弹出键盘,我也可以滚动查看剩余的视图..?我必须为此做些什么改变..?
我已经对这个主题做了一些研究,我找不到一个完整的解决方案,所以,一步一步,经过一些反复试验,我终于找到了如何实现这些结果:透明或有色Actionbar
和Statusbar
.请看下面的答案.
android android-appcompat android-actionbar android-toolbar android-statusbar
但我还没有找到改变状态文本颜色的方法.如果我将colorPrimaryDark设置为白色,我无法看到图标既不是状态栏的文本也不是因为它们的颜色也是白色.
有没有办法改变状态栏文字颜色?
提前致谢
我需要制作透明的状态栏.我正在使用getWindow().addFlags(WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS)
,它是我想要的状态栏.但它也影响导航栏:它变得透明,getWindow().setNavigationBarColor(Color.BLACK)
什么都不做.
有办法只制作透明状态栏而不是导航栏吗?
我想让我的活动全屏显示状态栏,就像这张图片一样:
我在manifest
内部activity
标记中使用了此代码:
'android:theme="@style/Theme.AppCompat.Light.NoActionBar"'
Run Code Online (Sandbox Code Playgroud)
但我的观点并不是从状态栏开始的,它看起来像这样:
我怎样才能让自己activity
看起来像第一个?
android android-theme android-activity android-fullscreen android-statusbar
在Android M中,我们可以使状态栏图标变暗.为此,我们可以在主题的xml中指定属性:
<item name="android:windowLightStatusBar">true</item>
Run Code Online (Sandbox Code Playgroud)
或者我们使用以下代码在运行时设置它:
View someView = findViewById(R.id.some_view);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
someView.setSystemUiVisibility(someView.getSystemUiVisibility() | View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR);
}
Run Code Online (Sandbox Code Playgroud)
它实际上工作正常.但问题是如何在运行时将状态栏模式正确设置为黑暗?
我已经尝试过那些变种:
// Makes status bar mode dark, but also hides it along with all navigation views.
someView.setSystemUiVisibility(someView.getSystemUiVisibility() | ~View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR);
// Does nothing
someView.setSystemUiVisibility(someView.getSystemUiVisibility() & ~View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR);
// Also does nothing
someView.setSystemUiVisibility(someView.getSystemUiVisibility() ^ View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR);
Run Code Online (Sandbox Code Playgroud)
那么如何才能以正确的方式完成?
user-interface android android-statusbar android-6.0-marshmallow
编辑2016年2月1日:应该通过应用Android团队提供的代码解决错误:https://stackoverflow.com/a/35132144/3397345,请参阅下面接受的答案.
2016年2月27日编辑:在v23.1.1中仍未解决错误.到目前为止提供的解决方案不提供透明状态栏(这是此布局的目的)或太复杂.此处提供的新错误屏幕记录:https://www.youtube.com/watch?v = 76IxhlUx8MQ
编辑2015年7月23日:支持设计库v22.2.1没有修复:-(这也发生在工具栏上快速返回MainActivity!
编辑28/07/2015:链接的问题:在片段交易期间,CoordinatorLayout状态栏填充消失
从示例存储库https://github.com/chrisbanes/cheesesquare我已经在Detail Activity上实现了ViewPager.它有效,但StatusBar从第2页消失,如图所示只在Lollipop设备中,任何想法?我使用,android:fitsSystemWindows="true"
但它只在第一页上工作:-(
activity_detail_viewpager.xml 如果我把这里放在fitsSystemWindows,StatusBar不再透明了,但是它有效(状态栏填充不会丢失).但我希望它透明!
<android.support.design.widget.CoordinatorLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/main_content"
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.v4.view.ViewPager
android:id="@+id/viewpager"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:overScrollMode="ifContentScrolls"/>
</android.support.design.widget.CoordinatorLayout>
Run Code Online (Sandbox Code Playgroud)
activity_detail_fragment.xml
<CoordinatorLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/main_content"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true">
<android.support.design.widget.AppBarLayout
android:id="@+id/appbar"
android:layout_width="match_parent"
android:layout_height="@dimen/detail_backdrop_height"
android:fitsSystemWindows="true"
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar">
<android.support.design.widget.CollapsingToolbarLayout
android:id="@+id/collapsing_toolbar"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
app:layout_scrollFlags="scroll|exitUntilCollapsed"
app:contentScrim="?attr/colorPrimary"
app:expandedTitleMarginStart="48dp"
app:expandedTitleMarginEnd="64dp">
<ImageView
android:id="@+id/back_item"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scaleType="centerCrop"
android:fitsSystemWindows="true"
app:layout_collapseMode="parallax" />
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
app:popupTheme="@style/ThemeOverlay.AppCompat.Light"
app:layout_collapseMode="pin" />
</android.support.design.widget.CollapsingToolbarLayout>
</android.support.design.widget.AppBarLayout> …
Run Code Online (Sandbox Code Playgroud) android android-viewpager android-5.0-lollipop android-statusbar android-support-design
我想整合这样的东西:
我这样做了,但我似乎无法将imageview放在工具栏下面.没有工具栏,我可以在状态栏下进行,但是将这两者结合起来是不可能的.
这是我的布局:
<?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:orientation="vertical"
android:fitsSystemWindows="true"
tools:context="com.project.android.PhotoActivity">
<android.support.v7.widget.Toolbar
android:id="@+id/photo_tl"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="#59000000"
tools:ignore="UnusedAttribute" />
<ImageView
android:id="@+id/photo_image"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:adjustViewBounds="true"
android:scaleType="fitStart" />
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)
在我的活动中,我做了以下事情:
getWindow().getDecorView().setSystemUiVisibility(
View.SYSTEM_UI_FLAG_LAYOUT_STABLE
| View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN);
Run Code Online (Sandbox Code Playgroud)
我还声明了一个styles-v21.xml文件:
<style name="Project.Photo" parent="Project.Light">
<item name="android:windowDrawsSystemBarBackgrounds">true</item>
<item name="android:statusBarColor">#59000000</item>
</style>
Run Code Online (Sandbox Code Playgroud)
并将其设置为PhotoActivity的默认样式.我已经尝试将工具栏放在FrameLayout中,但这样做我的工具栏只是隐藏,如下所示:
提前致谢.
得到了修复,但工具栏与状态栏重叠.反正有没有修复填充?如果我使用android:fitsSystemWindows ="true",状态栏不再是半透明的.
android android-layout material-design android-toolbar android-statusbar
android android-theme android-styles android-5.0-lollipop android-statusbar
android ×10