我想知道是否可以更改状态栏图标颜色(而不是状态栏颜色colorPrimaryDark)
假设我想要这个状态栏:
<item name="colorPrimaryDark">@android:color/white</item>
和黑色的图标,这可能吗?
谢谢.
编辑:
M开发人员预览中的新功能:windowLightStatusBar.在主题中翻转它会告诉系统使用深色前景,对浅色状态栏很有用.请注意,M预览似乎有一个错误,通知图标保持白色,而系统状态图标正确地变为半透明黑色.
来自:Roman Nurik的 Google+ 帖子

android android-styles android-5.0-lollipop android-statusbar
所以现在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
所以,我刚刚将我的代码库更新为Lollipop,而且我遇到了Action Bar的问题.我正在使用AppCompat和ActionBarActivity,并为自定义视图充气.似乎自定义视图不再占据屏幕的整个宽度,在左侧留下一条细条
过去的样子
它看起来现在的样子
这是我用来设置Action Bar的代码.有人有主意吗?
final ActionBar actionBar = getSupportActionBar();
if(actionBar != null) {
actionBar.setDisplayHomeAsUpEnabled(false);
actionBar.setDisplayShowHomeEnabled(false);
actionBar.setDisplayShowTitleEnabled(false);
actionBar.setDisplayShowCustomEnabled(true);
actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_STANDARD);
actionBar.setCustomView(R.layout.action_bar_content_search_custom_view);
actionBar.setBackgroundDrawable(null);
// actionBar.setStackedBackgroundDrawable(null);
TextView title = (TextView) actionBar.getCustomView().findViewById(R.id.action_bar_title);
title.setText(R.string.youtube);
ImageView back = (ImageView) actionBar.getCustomView().findViewById(R.id.action_bar_back);
back.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
finish();
}
});
}
Run Code Online (Sandbox Code Playgroud)
编辑
取出自定义视图并更改背景现在占用整个宽度.问题是,我们如何让CustomView占用ActionBar的整个宽度?
android android-appcompat android-actionbar android-5.0-lollipop
在新的棒棒糖更新中,我注意到,使用原生Google应用,状态栏的颜色会更改,以匹配您正在运行的应用上的操作栏.我看到它也在Twitter应用程序上,所以我猜测它不仅仅是Google可以做到的.
如果有可能,有谁知道如何做到这一点?
触摸布局时,如何在简单的线性/相对布局中产生涟漪效应?
我已经尝试将布局的背景设置为:
<?xml version="1.0" encoding="utf-8"?>
<ripple xmlns:android="http://schemas.android.com/apk/res/android"
android:color="?android:colorControlHighlight" >
<item android:drawable="@android:color/white"/>
</ripple>
Run Code Online (Sandbox Code Playgroud)
然而,我只看到纯白色背景,并且在触摸布局时没有涟漪效应.我究竟做错了什么?
编辑:
作为参考,这是我的布局xml文件:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="250dp"
android:layout_height="250dp"
android:background="@drawable/test"
android:clickable="true">
</RelativeLayout>
Run Code Online (Sandbox Code Playgroud) 我正在尝试使用新的RecyclerView,每当我尝试运行它时,我的应用程序立即崩溃.它为我提供了尝试访问方法的NullPointerException android.support.v7.widget.RecyclerView.我看过其他帖子,看到大多数人都没有,compile 'com.android.support:recyclerview-v7:+'但我尝试了,但根本没用.目前还不确定该做什么,任何帮助都将不胜感激.这里的错误日志:(我会张贴一张图片,但我还没有10个代表)
java.lang.NullPointerException: Attempt to invoke virtual method 'void android.support.v7.widget.RecyclerView$LayoutManager.onMeasure(android.support.v7.widget.RecyclerView$Recycler, android.support.v7.widget.RecyclerView$State, int, int)' on a null object reference
at android.support.v7.widget.RecyclerView.onMeasure(RecyclerView.java:1764)
at android.view.View.measure(View.java:17430)
at android.widget.RelativeLayout.measureChildHorizontal(RelativeLayout.java:727)
at android.widget.RelativeLayout.onMeasure(RelativeLayout.java:463)
at android.view.View.measure(View.java:17430)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5463)
at android.widget.FrameLayout.onMeasure(FrameLayout.java:430)
at android.view.View.measure(View.java:17430)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5463)
at android.widget.FrameLayout.onMeasure(FrameLayout.java:430)
at android.view.View.measure(View.java:17430)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5463)
at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1436)
at android.widget.LinearLayout.measureVertical(LinearLayout.java:722)
at android.widget.LinearLayout.onMeasure(LinearLayout.java:613)
at android.view.View.measure(View.java:17430)
at android.support.v4.widget.DrawerLayout.onMeasure(DrawerLayout.java:851)
at android.view.View.measure(View.java:17430)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5463)
at android.widget.FrameLayout.onMeasure(FrameLayout.java:430)
at android.view.View.measure(View.java:17430)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5463)
at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1436)
at android.widget.LinearLayout.measureVertical(LinearLayout.java:722)
at android.widget.LinearLayout.onMeasure(LinearLayout.java:613)
at android.view.View.measure(View.java:17430)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5463)
at android.widget.FrameLayout.onMeasure(FrameLayout.java:430)
at android.view.View.measure(View.java:17430) …Run Code Online (Sandbox Code Playgroud) java android android-layout android-5.0-lollipop android-recyclerview
我想在我的项目中使用新的Design TabLayout.我希望布局适应每个屏幕尺寸和方向,但可以在一个方向上正确看到.
我正在处理重力和模式设置我的tabLayout为:
tabLayout.setTabGravity(TabLayout.GRAVITY_CENTER);
tabLayout.setTabMode(TabLayout.MODE_SCROLLABLE);
Run Code Online (Sandbox Code Playgroud)
所以我希望如果没有空间,tabLayout是可滚动的,但是如果有空间,它就会居中.
从指南:
public static final int GRAVITY_CENTER Gravity用于布置TabLayout中心的选项卡.
public static final int GRAVITY_FILL Gravity用于尽可能多地填充TabLayout.此选项仅在与MODE_FIXED一起使用时生效.
public static final int MODE_FIXED固定选项卡同时显示所有选项卡,最适用于受益于选项卡之间快速枢轴的内容.选项卡的最大数量受视图宽度的限制.固定标签的宽度相等,基于最宽的标签标签.
public static final int MODE_SCROLLABLE可滚动选项卡在任何给定时刻显示选项卡的子集,并且可以包含更长的选项卡标签和更多数量的选项卡.当用户不需要直接比较标签标签时,它们最适合用于浏览触摸界面中的上下文.
所以GRAVITY_FILL只与MODE_FIXED兼容但是,at没有为GRAVITY_CENTER指定任何内容,我希望它与MODE_SCROLLABLE兼容,但这是我使用GRAVITY_CENTER和MODE_SCROLLABLE

因此它在两个方向都使用SCROLLABLE,但它没有使用GRAVITY_CENTER.
这就是我对景观的期望; 但要拥有这个,我需要设置MODE_FIXED,所以我得到的是肖像:

如果tabLayout适合屏幕,为什么GRAVITY_CENTER不能用于SCROLLABLE?有没有办法动态设置重力和模式(并看看我期待什么)?
非常感谢你!
编辑:这是我的TabLayout的布局:
<android.support.design.widget.TabLayout
android:id="@+id/sliding_tabs"
android:layout_width="match_parent"
android:background="@color/orange_pager"
android:layout_height="wrap_content" />
Run Code Online (Sandbox Code Playgroud) 尝试使用支持库中的新RecyclerView.我使用SDK管理器下载了支持库的20更新.
我已经将jar文件添加到libs文件夹中 - 并添加到构建路径 - 使用RecyclerView没有运气.
根据Android Developer的API尝试使用gradle依赖- 不确定这是否适合查看 - 此页面更多与AndroidTV相关:
com.android.support:recyclerview-v7:20.0.+
Run Code Online (Sandbox Code Playgroud)
无法同步项目.
有任何想法吗?
我已经看到了一些SO问题,他们提供了一些可能的方法来实现我想要的.例如:
colorControlHighlight在styles.xml中使用属性.
这是我的styles-v21.xml:
<style name="SelectableItemBackground">
<item name="android:colorControlHighlight">#5677FC</item>
<item name="android:background">?attr/selectableItemBackground</item>
</style>
Run Code Online (Sandbox Code Playgroud)
我的小部件:
<TextView
android:id="@+id/tv_take_photo_as_bt"
android:layout_width="280dp"
android:layout_height="48dp"
android:text="@string/act_take_photo"
style="@style/SelectableItemBackground"/>
Run Code Online (Sandbox Code Playgroud)
它不起作用.我还尝试添加parent="Theme.AppCompat到"SelectableItemBackground"样式,或者更改为colorControlHighlight(no android: prefix)"或更改为?android:attr/selectableItemBackground,既没有用.
backgroundTint在布局中使用属性.
所以我加入android:backgroundTint="#5677FC"我的TextView.还是没用.然后我试着改变android:backgroundTintMode,src_in并且src_atop,他们永远不会有所作为.
那么,当我?attr/selectableItemBackground用作背景时,如何改变波纹颜色.我只关注棒棒糖及以上.先感谢您!
android android-appcompat android-layout material-design android-5.0-lollipop
当我尝试为来电创建自定义屏幕时,我正在尝试以编程方式接听来电.我使用以下代码但它在Android 5.0中不起作用.
// Simulate a press of the headset button to pick up the call
Intent buttonDown = new Intent(Intent.ACTION_MEDIA_BUTTON);
buttonDown.putExtra(Intent.EXTRA_KEY_EVENT, new KeyEvent(KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_HEADSETHOOK));
context.sendOrderedBroadcast(buttonDown, "android.permission.CALL_PRIVILEGED");
// froyo and beyond trigger on buttonUp instead of buttonDown
Intent buttonUp = new Intent(Intent.ACTION_MEDIA_BUTTON);
buttonUp.putExtra(Intent.EXTRA_KEY_EVENT, new KeyEvent(KeyEvent.ACTION_UP, KeyEvent.KEYCODE_HEADSETHOOK));
context.sendOrderedBroadcast(buttonUp, "android.permission.CALL_PRIVILEGED");
Run Code Online (Sandbox Code Playgroud)