标签: android-5.0-lollipop

升级到支持库v21后,PreferenceActivity中没有ActionBar

在我升级到支持库v21之后,我的ActionBar PreferenceActivity就消失了.

我是否错过了我的主题中的一些属性来再次激活它?黑色ActionBar我遇到了类似的麻烦.

我还尝试通过添加Toolbar到根布局来添加它有点hackish ,但是这没有按预期工作.

android preferenceactivity android-support-library android-5.0-lollipop

83
推荐指数
4
解决办法
4万
查看次数

导航抽屉半透明状态栏无法正常工作

我正在开发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

81
推荐指数
6
解决办法
9万
查看次数

应用Material Design Touch Ripple到ImageButton?

我有一个图像按钮,点击它时没有响应触摸动画,因为它是一个静态图像,而不像棒棒糖上的常规按钮带有内置的连锁效果.我想将材料设计波纹触摸效果添加到图像中,但似乎无法找到实现它的方法.我可以在图像上设置一个滤色器,但这不是涟漪效应.我正在尝试做的一个例子就是当你在Google Play音乐中保存一个专辑封面图像并且阴影波纹在图像上移动时.

xml android imagebutton material-design android-5.0-lollipop

81
推荐指数
4
解决办法
4万
查看次数

改变在棒棒糖的通知象背景

我正在通过通知设计模式,并没有找到任何谈论通知图标背景.您可能已经注意到,自定义通知只有浅灰色背景.但是环聊等应用或简单的USB调试通知都会为其通知图标背景提供自定义颜色.

有没有可能将那种灰色变成其他东西?(以编程方式显示特定圆圈的颜色)

见图

android android-notifications android-5.0-lollipop

77
推荐指数
2
解决办法
5万
查看次数

Android如何从Material Design文档实现底部工作表

你如何实现底部表格规定? http://www.google.com/design/spec/components/bottom-sheets.html

Google云端硬盘的新更新通过按下浮动操作按钮显示了这一点 - >

在此输入图像描述

当然,规格从来没有说过任何关于圆角的内容,无论是否可行,只是不确定如何去做.目前使用AppCompat库并将目标设置为21.

谢谢

android material-design floating-action-button android-5.0-lollipop

75
推荐指数
6
解决办法
7万
查看次数

更新到最新的appcompat和支持库后出现DexIndexOverflowException问题

我通过以下设置使用gradle:

compileSdkVersion 21
ANDROID_BUILD_MIN_SDK_VERSION=14
ANDROID_BUILD_TARGET_SDK_VERSION=21
ANDROID_BUILD_TOOLS_VERSION=21.0.2
ANDROID_BUILD_SDK_VERSION=21
Run Code Online (Sandbox Code Playgroud)

我的gradle文件中还有以下设置:

compile 'com.android.support:support-annotations:21.0.0'
compile 'com.android.support:appcompat-v7:21.0.0'
compile 'com.android.support:support-v4:21.0.0'
Run Code Online (Sandbox Code Playgroud)

我总是得到错误UNEXPECTED TOP LEVEL EXCEPTION.
但是,当我做21.0.020.0.0它工作正常...但我不能够访问任何的Android API的21个选项.我在这里做错了吗?如何在没有此异常的情况下编译它?我没有其他等级项目以外的其他地方的支持罐(facebook等).

这是完整的堆栈跟踪:

UNEXPECTED TOP-LEVEL EXCEPTION:
com.android.dex.DexIndexOverflowException: method ID not in [0, 0xffff]: 65536
    at com.android.dx.merge.DexMerger$6.updateIndex(DexMerger.java:502)
    at com.android.dx.merge.DexMerger$IdMerger.mergeSorted(DexMerger.java:283)
    at com.android.dx.merge.DexMerger.mergeMethodIds(DexMerger.java:491)
    at com.android.dx.merge.DexMerger.mergeDexes(DexMerger.java:168)
    at com.android.dx.merge.DexMerger.merge(DexMerger.java:189)
    at com.android.dx.command.dexer.Main.mergeLibraryDexBuffers(Main.java:454)
    at com.android.dx.command.dexer.Main.runMonoDex(Main.java:302)
    at com.android.dx.command.dexer.Main.run(Main.java:245)
    at com.android.dx.command.dexer.Main.main(Main.java:214)
    at com.android.dx.command.Main.main(Main.java:106)
Run Code Online (Sandbox Code Playgroud)

android gradle android-support-library build.gradle android-5.0-lollipop

73
推荐指数
2
解决办法
4万
查看次数

Lollipop AppCompat-v7 21 - 属性"主题"已经定义

我想升级我的项目以支持Android Lollipop和API 21,因此我将依赖项的AppCompat版本更改为21.0.0,将目标SDK更改为21.

但是现在,当我尝试将项目与gradle文件同步时,它给了我102 errors以前不存在的内容:

1错误"Attribute 'theme' has already defined"- 由我的colors.XML文件给出,

还有另外101个错误"no resources found that matches the given name..."- 其中大多数是物质错误- 由...给出"build/intermediates/exploded-aar/com.android.support/appcompat-v7/21.0.0/res/values-v11/values.XML".

已经更新了Android SDK软件中的所有SDK工具,使用Android Studio 0.8.9 Beta.

有人可以帮忙吗?谢谢.

android android-5.0-lollipop

69
推荐指数
2
解决办法
2万
查看次数

Android 5.0(L)Service Intent必须在Google Analytics中明确

我的代码工作在<5但在Android 5.0中我遇到了一个我不太明白的问题.

10-23 10:18:18.945: E/AndroidRuntime(8987): java.lang.IllegalArgumentException: Service Intent must be explicit: Intent { act=com.google.android.gms.analytics.service.START (has extras) }
Run Code Online (Sandbox Code Playgroud)

即使是现在,我的代码也适用于4.4.4及以下版本.那么我需要做什么?我将在下面发布相关代码.此外,在我的谷歌搜索期间,我发现这篇关于java.lang.IllegalArgumentException的帖子:服务意图必须是关于Android 5.0的显式,但我不明白它的含义.

表现

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="xxxxx.android.phone.xxxxx"
    android:versionCode="3"
    android:versionName="v1.2.4065" >

    <uses-sdk android:minSdkVersion="12"
        android:targetSdkVersion="21" />

    <!-- Required for Google Analytics -->
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />

    <!-- For push notifications (GCM) -->
    <permission android:name="xxxxx.android.phone.xxxxx.permission.C2D_MESSAGE" android:protectionLevel="signature" />
    <uses-permission android:name="xxxxx.android.phone.xxxxx.permission.C2D_MESSAGE" />
    <!-- App receives GCM messages. -->
    <uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />
    <!-- GCM connects to Google Services. -->
    <uses-permission android:name="android.permission.INTERNET" /> 
    <!-- GCM requires a Google account. --> …
Run Code Online (Sandbox Code Playgroud)

illegalargumentexception android-5.0-lollipop

68
推荐指数
5
解决办法
5万
查看次数

Android中的灵活空间

使用本教程实现灵活空间模式(具有折叠工具栏的模式).

我正在尝试实现与Lollipop Contacts活动类似的效果,该活动在进入活动时开始查看图像标题的唯一部分:

在此输入图像描述

然后,用户可以向下滚动图像下方的布局,以便显示更多内容,直到达到最大值:

在此输入图像描述

在我的应用程序中,我无法使其工作.

结果是,当进入活动时,图像标题以其最大尺寸(AppBarLayout的大小)呈现,就像上面的布局一样,并且与Lollipop Contacts活动不同,它只显示图像的一部分.

这是设置AppBarLayout高度的代码(我希望屏幕宽度为最大高度):

int widthPx = getResources().getDisplayMetrics().widthPixels;
AppBarLayout appbar = (AppBarLayout)findViewById(R.id.appbar);
appbar.setLayoutParams(new CoordinatorLayout.LayoutParams(CoordinatorLayout.LayoutParams.MATCH_PARENT, widthPx));
Run Code Online (Sandbox Code Playgroud)

这是设置RecyclerView的代码.尝试使用scrollToPosition,认为它会提升RecyclerView的视图,但它根本没有效果:

mRecyclerView = (RecyclerView) findViewById(R.id.activity_profile_bottom_recyclerview);

    mRecyclerView.setHasFixedSize(true);

    // use a linear layout manager
    mLayoutManager = new LinearLayoutManager(this);

    mRecyclerView.setLayoutManager(mLayoutManager);

    // specify an adapter (see also next example)
    if(mAdapter == null){
        mAdapter = new ProfileAdapter(this, user, inEditMode);
        mRecyclerView.setAdapter(mAdapter);
    }

    mRecyclerView.scrollToPosition(mAdapter.getItemCount() - 1); // itemCount is 4
Run Code Online (Sandbox Code Playgroud)

这是布局xml:

<android.support.v4.widget.DrawerLayout 
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/activity_profile"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true">

<android.support.design.widget.CoordinatorLayout
    android:layout_width="match_parent" …
Run Code Online (Sandbox Code Playgroud)

java android android-layout material-design android-5.0-lollipop

66
推荐指数
1
解决办法
3380
查看次数

Android 5.0 android:提升适用于View,但不适用于Button?

在SDK Manager的Android 5.0示例中,有ElevationBasic示例.它显示了两个View对象:圆形和方形.圆圈android:elevation设置为30dp:

<?xml version="1.0" encoding="utf-8"?>
<!--
 Copyright 2014 The Android Open Source Project

 Licensed under the Apache License, Version 2.0 (the "License");
 you may not use this file except in compliance with the License.
 You may obtain a copy of the License at

     http://www.apache.org/licenses/LICENSE-2.0

 Unless required by applicable law or agreed to in writing, software
 distributed under the License is distributed on an "AS IS" BASIS,
 WITHOUT WARRANTIES OR CONDITIONS OF …
Run Code Online (Sandbox Code Playgroud)

android android-5.0-lollipop

65
推荐指数
4
解决办法
4万
查看次数