标题说明了一切.我试过setExpandedTitleColor
和setCollapsedTitleColor
(开关,并从透明的),没有运气.我也看不到任何内置的方法可以做我正在寻找的东西.
我只想在CollapsingToolbarLayout完全折叠时显示标题,否则,我需要隐藏它.
任何提示?
我不想把我的所有代码放在这里,所以我只是把相关的部分.如果您需要更多,请随时询问.
我正在使用文本到语音(TTS),在它问一个问题之后导致语音监听器......我通过Log输出发现TTS的onInit被调用,但是UtteranceProgressListener没有,我无法弄清楚为什么.任何帮助表示赞赏.
// ---Initialize TTS variables---
// Implement Text to speech feature
tts = new TextToSpeech(this, new ttsInitListener());
// set listener to the TTS engine
tts.setOnUtteranceProgressListener(new ttsUtteranceListener());
if (!tts.isSpeaking()) {
tts.speak("Speak to me", TextToSpeech.QUEUE_FLUSH, null);
}
Run Code Online (Sandbox Code Playgroud)
// --- TEXT TO SPEECH && SPEECH TO TEXT METHODS ---
class ttsInitListener implements OnInitListener {
@Override
public void onInit(int status) {
if (status == TextToSpeech.SUCCESS) {
tts.setLanguage(Locale.getDefault());
} else {
tts = null;
Toast.makeText(mContext, "Failed to initialize TTS engine.",
Toast.LENGTH_SHORT).show();
}
}
} …
Run Code Online (Sandbox Code Playgroud) 当我尝试使用Android studio将应用程序推送到我的设备时,我在AS中获得了以下日志读数,大约80%的时间.有线索吗?
Waiting for device.
Target device: htc-htc_one_m8-FA43NWM07298
Uploading file
local path: /Users/Pete/Development/github/myApp/app/build/outputs/apk/myApp_debug.apk
remote path: /data/local/tmp/com.my.app
Installing com.my.app
DEVICE SHELL COMMAND: pm install -r "/data/local/tmp/com.my.app"
java.lang.UnsatisfiedLinkError: No implementation found for java.lang.String android.os.SystemProperties.native_get(java.lang.String) (tried Java_android_os_SystemProperties_native_1get and Java_android_os_SystemProperties_native_1get__Ljava_lang_String_2)
at android.os.SystemProperties.native_get(Native Method)
at android.os.SystemProperties.get(SystemProperties.java:52)
at com.htc.customization.HtcCustomizationManager.<init>(HtcCustomizationManager.java:65)
at com.htc.customization.HtcCustomizationManager.<clinit>(HtcCustomizationManager.java:60)
at android.os.Environment$UserEnvironment.getCustomizationReader(Environment.java:523)
at android.os.Environment$UserEnvironment.isDynamicSwitchSupported(Environment.java:534)
at android.os.Environment$UserEnvironment.<init>(Environment.java:222)
at android.os.Environment.initForCurrentUser(Environment.java:142)
at android.os.Environment.<clinit>(Environment.java:136)
at android.os.Environment.getLegacyExternalStorageDirectory(Environment.java:726)
at android.os.Debug.<clinit>(Debug.java:96)
at android.ddm.DdmHandleHello.handleHELO(DdmHandleHello.java:164)
at android.ddm.DdmHandleHello.handleChunk(DdmHandleHello.java:91)
at org.apache.harmony.dalvik.ddmc.DdmServer.dispatch(DdmServer.java:171)
java.lang.UnsatisfiedLinkError: android.os.Debug
at android.ddm.DdmHandleHello.handleFEAT(DdmHandleHello.java:176)
at android.ddm.DdmHandleHello.handleChunk(DdmHandleHello.java:93)
at org.apache.harmony.dalvik.ddmc.DdmServer.dispatch(DdmServer.java:171)
java.lang.UnsatisfiedLinkError: android.os.Debug
at android.ddm.DdmHandleProfiling.handleMPRQ(DdmHandleProfiling.java:215)
at android.ddm.DdmHandleProfiling.handleChunk(DdmHandleProfiling.java:106)
at …
Run Code Online (Sandbox Code Playgroud) 我们调整了我们对Oreo的持续通知,并且效果很好.现在,仅在Pie上(在Oreo设备上没有发生),我们得到了标题错误.Pie中的前台服务有什么变化我错过了吗?
这是前台服务的onCreate代码 - >
override fun onCreate() {
super.onCreate()
val notification: Notification = NotificationCompat.Builder(this, packageName)
.setSmallIcon(R.drawable.status_notification_icon)
.setContentTitle(getString(R.string.ongoing_notify_temp_title))
.setContentText(getString(R.string.ongoing_notify_temp_message))
.setGroup(AppConstants.NOTIFICATION_GROUP_ONGOING)
.setColor(ContextCompat.getColor(this, R.color.custom_blue))
.build()
startForeground(ONGOING_NOTIFY_ID, notification)
appSettings = AppSettings(this)
weatherLookUpHelper = WeatherLookUpHelper()
MyRoomDatabase.getInstance().invalidationTracker.addObserver(onChange)
retrieveCurrentLocation()
createAlarmManager()
}
Run Code Online (Sandbox Code Playgroud)
如您所见,我们只是创建通知然后调用startForeground.关于为什么这段代码会产生标题错误的任何想法?
侧注:Fabric Crashlytics显示此崩溃仅发生在运行Pie的像素设备(像素,像素xl,像素2,像素2 xl)上
编辑:我们的清单中有前台权限
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
Run Code Online (Sandbox Code Playgroud) <dialog
我的导航图中有一个带有进入/退出动画的动画,但动画不适用于对话框。我已经在<fragment
节点上测试过它们,它们工作正常。
为了澄清起见,被引用的对话框是一个 DialogFragment
这是限制还是我做错了什么?
这是我的导航图中的相关片段:
<fragment
android:id="@+id/fragment_home"
android:name="com.my.project.fragments.HomeFragment"
android:label="@string/nav_home"
tools:layout="@layout/fragment_home">
<action
android:id="@+id/action_fragment_home_to_fragment_dialog_new_user_welcome"
app:destination="@id/fragment_dialog_new_user_welcome"
app:enterAnim="@anim/nav_fade_enter_anim"
app:exitAnim="@anim/nav_fade_exit_anim"
app:popUpTo="@layout/fragment_home" />
</fragment>
<dialog
android:id="@+id/fragment_dialog_new_user_welcome"
android:name="com.my.project.fragments.NewUserWelcomeDialog"
tools:layout="@layout/fragment_dialog_new_user_welcome">
<action
android:id="@+id/action_fragment_dialog_new_user_welcome_to_activity_discover_detail"
app:destination="@id/fragment_discover_detail"
app:launchSingleTop="true"
app:popUpTo="@id/fragment_home" />
</dialog>
Run Code Online (Sandbox Code Playgroud)
这是输入动画:
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
<alpha
android:duration="1000"
android:fromAlpha="0.0"
android:toAlpha="1.0" />
</set>
Run Code Online (Sandbox Code Playgroud)
这是退出动画:
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
<alpha
android:duration="500"
android:fromAlpha="1.0"
android:toAlpha="0.0" />
</set>
Run Code Online (Sandbox Code Playgroud) 对于下面的布局,当我在viewpager中的页面上滚动内容时...如果我将手指放在屏幕上并慢慢向上滚动,则标签布局不会折叠到工具栏中但是如果我将内容放入它确实如此.有什么想法吗?
activity_home.xml
<layout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
tools:context=".newnav.home.HomeActivity">
<android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
tools:context=".newnav.NavigationActivity">
<!-- Check whether do we need this surface view still? -->
<SurfaceView
android:id="@+id/surfaceView"
android:layout_width="0dp"
android:layout_height="0dp" />
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<com.my.package.view.MyToolBar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:background="@color/primary_color" />
<FrameLayout
android:id="@+id/fragment_container"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@id/toolbar" />
<com.my.package.view.SomeCustomView
android:id="@+id/breaking_news_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true" />
</RelativeLayout>
<com.my.package.navigation.NavigationLayout
android:id="@+id/navigation_layout"
android:layout_width="320dp"
android:layout_height="match_parent"
android:layout_gravity="start"
android:background="@android:color/white"
android:fitsSystemWindows="true" />
</android.support.v4.widget.DrawerLayout>
</layout>
Run Code Online (Sandbox Code Playgroud)
fragment_home.xml(父布局有工具栏):
<?xml version="1.0" encoding="utf-8"?>
<layout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<android.support.design.widget.CoordinatorLayout
android:id="@+id/coordinatorLayout"
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.design.widget.AppBarLayout
android:id="@+id/appBarLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/white" …
Run Code Online (Sandbox Code Playgroud) android android-coordinatorlayout android-appbarlayout android-tablayout
我将要离开,并且将有很长一段时间没有互联网连接.我目前使用IntelliJ与android SDK进行开发.当我尝试创建一个没有互联网连接的项目时,它给了我一个gradle http错误.
我做了一些搜索并从groovy的网站下载了1.8压缩文件,但无法使用intellij来使用它(压缩或解压缩).
我无法找到一个很好的指导来完成这项工作,所以我看到这里是否有人可以指点我.非常感谢提前
这是一个简单的问题.创建具有间隔的Firebase作业调度程序作业意味着作业将在大约这么长时间内开始.有没有办法,除了破坏和重建工作,简单地重置计时器?
我正在尝试更改对话框中的文本颜色,最常见的是AlertDialog.我在这些页面上尝试了所有解决方案:
AlertDialog样式 - 如何更改标题,消息等的样式(颜色)
如何更改AlertDialog标题的颜色以及其下方的线条颜色
大多数解决方案的工作低于5.0但高于它,它们似乎没有任何影响.我应该为5.0+更改哪些不同的属性?
我的应用程序的父主题是"Theme.AppCompat.Light.NoActionBar"
尝试初始化共享首选项单例类时,我们收到IllegalStageException,但我不知道是什么原因引起的。
有人可以告诉我这可能是什么原因吗?
注意:这仅在Pie上发生
这是来自Google Play控制台的报告(崩溃未在Crashlytics中显示):
java.lang.RuntimeException:
at android.app.ActivityThread.handleBindApplication (ActivityThread.java:5876)
at android.app.ActivityThread.access$1100 (ActivityThread.java:199)
at android.app.ActivityThread$H.handleMessage (ActivityThread.java:1650)
at android.os.Handler.dispatchMessage (Handler.java:106)
at android.os.Looper.loop (Looper.java:193)
at android.app.ActivityThread.main (ActivityThread.java:6669)
at java.lang.reflect.Method.invoke (Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run (RuntimeInit.java:493)
at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:858)
Caused by: java.lang.IllegalStateException:
at android.app.ContextImpl.getSharedPreferences (ContextImpl.java:419)
at android.app.ContextImpl.getSharedPreferences (ContextImpl.java:404)
at android.content.ContextWrapper.getSharedPreferences (ContextWrapper.java:174)
at com.nbc.news.utils.SharedPreferences.<init> (SharedPreferences.java:27)
at com.nbc.news.utils.SharedPreferences.init (SharedPreferences.java:44)
at com.nbc.news.NbcNews.onCreate (NbcNews.java:122)
at android.app.Instrumentation.callApplicationOnCreate (Instrumentation.java:1154)
at android.app.ActivityThread.handleBindApplication (ActivityThread.java:5871)
Run Code Online (Sandbox Code Playgroud)
这是初始化代码:
private android.content.SharedPreferences sharedPreferences;
private static SharedPreferences instance;
private SharedPreferences(Context context) {
Context appContext = context.getApplicationContext();
sharedPreferences = …
Run Code Online (Sandbox Code Playgroud) android ×10
adb ×1
android-architecture-navigation ×1
android-collapsingtoolbarlayout ×1
dialog ×1
firebase ×1
gradle ×1
htc-android ×1