我已经将我的statusBar颜色设置为Lollipop的透明颜色,仅在我的主题中使用以下行:
<item name="android:statusBarColor">@android:color/transparent</item>
Run Code Online (Sandbox Code Playgroud)
现在我需要在它背后绘制,但我不能得到它背后的任何视图.我知道如何使用windowTranslucentStatus属性,但不想使用此属性,因为它将忽略statusBar设置为透明的颜色.
我正在努力理解这个概念,fitsSystemWindows因为它取决于它做不同的事情.根据官方文件,它是一个
布尔内部属性,用于根据系统窗口(如状态栏)调整视图布局.如果为true,则调整此视图的填充以为系统窗口留出空间.
现在,检查View.java类我可以看到,当设置true为时,窗口插入(状态栏,导航栏...)将应用于视图填充,这根据上面引用的文档工作.这是代码的相关部分:
private boolean fitSystemWindowsInt(Rect insets) {
if ((mViewFlags & FITS_SYSTEM_WINDOWS) == FITS_SYSTEM_WINDOWS) {
mUserPaddingStart = UNDEFINED_PADDING;
mUserPaddingEnd = UNDEFINED_PADDING;
Rect localInsets = sThreadLocal.get();
if (localInsets == null) {
localInsets = new Rect();
sThreadLocal.set(localInsets);
}
boolean res = computeFitSystemWindows(insets, localInsets);
mUserPaddingLeftInitial = localInsets.left;
mUserPaddingRightInitial = localInsets.right;
internalSetPadding(localInsets.left, localInsets.top,
localInsets.right, localInsets.bottom);
return res;
}
return false;
}
Run Code Online (Sandbox Code Playgroud)
随着新材料设计的出现,有一些新的类广泛使用这个标志,这就是混乱的来源.在许多来源中fitsSystemWindows被提到作为设置在系统栏后面放置视图的标志.看到这里.
在文档ViewCompat.java的setFitsSystemWindows说:
设置此视图是否应考虑系统屏幕装饰,例如状态栏和插入其内容; 也就是说,控制是否执行{@link View#fitSystemWindows(Rect)}的默认实现.有关详细信息,请参阅该方法.
据此, …
所以现在Android 5.0发布了,我想知道如何实现动画操作栏图标.
这个库在这里实现它很好但是因为appcompat v7库有它如何实现它?
该库在themes.xml中引用它
<item name="drawerArrowStyle">@style/Widget.AppCompat.DrawerArrowToggle</item>
Run Code Online (Sandbox Code Playgroud)
在这种风格下
<style name="Base.V7.Theme.AppCompat" parent="Platform.AppCompat">
Run Code Online (Sandbox Code Playgroud)
UPDATE
我使用v7 DrawerToggle实现了这个功能.但是我无法设计它.请帮忙
我在v7 styles_base.xml中找到了它的样式
<style name="Base.Widget.AppCompat.DrawerArrowToggle" parent="">
<item name="color">?android:attr/textColorSecondary</item>
<item name="thickness">2dp</item>
<item name="barSize">18dp</item>
<item name="gapBetweenBars">3dp</item>
<item name="topBottomBarArrowSize">11.31dp</item>
<item name="middleBarArrowSize">16dp</item>
<item name="drawableSize">24dp</item>
<item name="spinBars">true</item>
</style>
Run Code Online (Sandbox Code Playgroud)
我把它添加到我的样式中并且没有用.也添加到我的attr.xml
<declare-styleable name="DrawerArrowToggle">
<!-- The drawing color for the bars -->
<attr name="color" format="color"/>
<!-- Whether bars should rotate or not during transition -->
<attr name="spinBars" format="boolean"/>
<!-- The total size of the drawable -->
<attr name="drawableSize" format="dimension"/>
<!-- The max gap …Run Code Online (Sandbox Code Playgroud) android android-appcompat android-actionbar drawertoggle android-5.0-lollipop
我正在开发Android项目,我正在实现导航抽屉.我正在阅读新的材料设计规范和材料设计清单.
规范说滑出窗格应该浮动在其他所有内容之上,包括状态栏,并且在状态栏上是半透明的.
我的导航面板位于状态栏上,但没有任何透明度.我按照Google开发者博客网站上的建议点击了这篇SO帖子中的代码,上面的链接如何使用DrawerLayout显示在ActionBar /工具栏上和状态栏下?.
下面是我的XML布局
<android.support.v4.widget.DrawerLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/my_drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<android.support.v7.widget.Toolbar
android:id="@+id/my_awesome_toolbar"
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:minHeight="?attr/actionBarSize"
android:background="@color/appPrimaryColour" />
</LinearLayout>
<LinearLayout android:id="@+id/linearLayout"
android:layout_width="304dp"
android:layout_height="match_parent"
android:layout_gravity="left|start"
android:fitsSystemWindows="true"
android:background="#ffffff">
<ListView android:id="@+id/left_drawer"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:choiceMode="singleChoice"></ListView>
</LinearLayout>
</android.support.v4.widget.DrawerLayout>
Run Code Online (Sandbox Code Playgroud)
以下是我的应用主题
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
<item name="colorPrimary">@color/appPrimaryColour</item>
<item name="colorPrimaryDark">@color/appPrimaryColourDark</item>
<item name="colorAccent">@color/appPrimaryColour</item>
<item name="windowActionBar">false</item>
<item name="windowActionModeOverlay">true</item>
</style>
Run Code Online (Sandbox Code Playgroud)
以下是我的应用程序v21主题
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
<item name="colorPrimary">@color/appPrimaryColour</item>
<item name="colorPrimaryDark">@color/appPrimaryColourDark</item>
<item name="colorAccent">@color/appPrimaryColour</item>
<item name="windowActionBar">false</item>
<item name="windowActionModeOverlay">true</item>
<item name="android:windowDrawsSystemBarBackgrounds">true</item>
<item name="android:statusBarColor">@android:color/transparent</item>
</style>
Run Code Online (Sandbox Code Playgroud)
下面是我的onCreate方法 …
android navigation-drawer material-design android-5.0-lollipop
问题摘要:如何在Chrome应用程序中进行ProgressBar集成ActionBar?
详细信息:请查看Chrome的此屏幕截图:

我想像这样创建一个Action Bar.在Action Bar的下方,有一个ProgressBar根据页面加载填充.我从很多应用程序中看过这个例子,比如Feedly,但是我无法创建自己的实现.我尝试使用Android自己的API来创建它:
@Override
protected void onCreate(Bundle savedInstanceState) {
//Request Permission to display the Progress Bar...
this.requestWindowFeature(Window.FEATURE_PROGRESS);
this.setWindowContentView(R.layout.activity_main)
super.onCreate(savedInstanceState);
this.setProgressBarIndeterminate(true);
}
Run Code Online (Sandbox Code Playgroud)
但是这段代码只会导致ProgressBar显示在 Action Bar上,如下所示:

那么,如何让我的ProgressBar出现在Action Bar下,就像Chrome应用程序一样?
android drawerlayout material-design android-design-library navigationview
我看到Android推出了新的导航抽屉图标,抽屉图标和后退箭头图标.我们如何在Kitkat支持的应用程序中使用它.查看Google最新版的报亭应用,它具有最新的导航抽屉图标和动画.我们怎样才能实现呢?
我已经尝试将minSDK设置为19并将complileSDK设置为21,但它使用的是旧式图标.这是自我实施的吗?
如何使抽屉布局位于操作栏/工具栏下方?我正在使用v7:21 app compat库和新的ToolBar视图.
我看到的例子看起来像
<android.support.v4.widget.DrawerLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/my_drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent">
<!-- drawer view -->
<LinearLayout
android:layout_width="304dp"
android:layout_height="match_parent"
android:layout_gravity="left|start">
<!-- drawer content -->
</LinearLayout>
<!-- normal content view -->
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<!-- The toolbar -->
<android.support.v7.widget.Toolbar
android:id="@+id/my_awesome_toolbar"
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:minHeight="?attr/actionBarSize"
android:background="?attr/colorPrimary" />
<!-- The rest of content view -->
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)
但随后工具栏将被抽屉隐藏,这使得动画汉堡图标(如v7.ActionBarDrawerToggle)无用,因为它在抽屉下方不可见,但我确实想使用新的ToolBar视图来更好地支持Material主题.
那么如何实现呢?是否可以将DrawerLayout作为非顶级视图?
android toolbar android-support-library navigation-drawer drawerlayout
我正在尝试创建一个Nav Drawer,就像Material spec中的那个(就像新gmail应用程序中的那个).请注意导航抽屉的内容如何在状态栏后面绘制:

使用Chris Banes从这个问题的答案,我能够成功地使我的应用程序中的导航抽屉在状态栏后面绘制; 这工作正常.什么是无效的是绘制状态栏后面的导航抽屉的内容.我希望抽屉中的蓝色图像显示在状态栏后面,但该区域使用状态栏的颜色绘制,如此屏幕截图所示.

那么,如何在状态栏后面的区域中绘制导航抽屉?我在下面发布了我项目的相关部分.
包含导航抽屉的基本布局:
<android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/nav_drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:fitsSystemWindows="true">
<!-- Framelayout to display Fragments -->
<FrameLayout
android:id="@+id/content"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_above="@+id/warning_container" />
<FrameLayout
android:id="@+id/navigation_drawer_fragment_container"
android:layout_width="300dp"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
android:layout_gravity="start">
<fragment
android:id="@+id/navigation_drawer_fragment"
android:name="com.thebluealliance.androidclient.fragments.NavigationDrawerFragment"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:layout="@layout/fragment_navigation_drawer" />
</FrameLayout>
</android.support.v4.widget.DrawerLayout>
Run Code Online (Sandbox Code Playgroud)
我活动的主题
<style name="AppThemeNoActionBar" parent="AppTheme">
<item name="windowActionBar">false</item>
<item name="android:windowNoTitle">true</item>
<item name="android:windowDrawsSystemBarBackgrounds">true</item>
<item name="android:statusBarColor">@android:color/transparent</item>
</style>
Run Code Online (Sandbox Code Playgroud)
在onCreate()我的活动中,我做了以下事情:
mDrawerLayout.setStatusBarBackground(R.color.primary_dark);
Run Code Online (Sandbox Code Playgroud) 对于特定的客户需求,我需要允许我的应用程序的用户(不会在Market中发布)单击ActionBar标题来执行某些操作.
我一直在寻找Android源代码,但我无法找到actionBar TextView标题的ID.
是否有正确的方法来处理此类点击?
android ×10
drawerlayout ×2
android-ui ×1
drawertoggle ×1
onclick ×1
textview ×1
title ×1
toolbar ×1