小编Boo*_*ger的帖子

CollapsingToolbarLayout crash on 4.4 devices (java.lang.IllegalArgumentException: radius must be > 0)

I have implemented the new style Collapsible Toolbar. I am using the same code as the example (Cheesesquare) demo app - which of course works fine on all devices. I need help figuring out what I am doing different then the sample (so my app won't crash).

My app runs great on 5.0+ devices, but crashes on older devices (OS 4.4.4) with an error that I can't isolate to my code (no references to my project's classes in the stack). …

android android-toolbar androiddesignsupport

14
推荐指数
2
解决办法
4142
查看次数

使用SpannableString调整文本对齐方式

SpannableString用第一个字符创建了一个,而后两个小于其余字符.它看起来像这样:

sBBBBss
Run Code Online (Sandbox Code Playgroud)

我想对齐较小的字符,使它们与较大文本的顶部对齐,而不是与底部对齐(如此处所示).

这可能吗?

我想我正在寻找像这样的伪代码:

myAmount.setSpan(new RelativeAlignSpan(View.TOP),0,1,0);

我唯一的另一种选择是使用多个TextView创建一个新的布局,我可以独立填充,然后我可以对齐.我认为这有点混乱,并且更喜欢使用SpannableString方法.

android spannablestring

13
推荐指数
1
解决办法
5042
查看次数

适用于Android的TestFlight替代品

有没有人有适用于Android或iOS的TestFlight替代品的建议?自从TestFlight宣布放弃对Android的支持以来,这变得更加重要.

android over-the-air ios testflight

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

在后台查看Play商店以确定是否可以在设备上下载应用程序

我知道我可以使用URL链接到Play商店:

market://details?id=com.example.appname
Run Code Online (Sandbox Code Playgroud)

我想做的是在后台"ping"此URL,并确定该应用程序是否实际可用,然后,我可以根据需要修改我的UI.

android google-play

5
推荐指数
1
解决办法
675
查看次数

Kotlin 多平台 Android 导入无法解决

我创建了一个非常简单的 KMP 项目,其结构如下:

-Root
  --app
  --gradle
--SharedCode
  --src\commonMain\kotlin\actual.kt
  --src\iosMain\kotlin\actual.kt
  --scr\androidMain\kotlin\actual.kt
  --build.gradle.kts
--native
  --KotlinIOS
    --iOS project (xcodeproj, etc)
Run Code Online (Sandbox Code Playgroud)

一切正常,基本项目可以在 Android 和 iOS 平台上运行。

但是当我尝试在 androidMain 目录中使用特定于 android 的导入语句时,导入语句将无法解析

import android.os.build // Android Studio can't find this

actual fun platformName(): String {
    return "Android"
}
Run Code Online (Sandbox Code Playgroud)

这很奇怪,因为 iOS 包成功地使用了iOS 特定的导入:

import platform.UIKit.UIDevice // This import works

actual fun platformName(): String {
    return UIDevice.currentDevice.systemName() +
            " " + UIDevice.currentDevice.systemVersion
}
Run Code Online (Sandbox Code Playgroud)

关于我可能需要配置什么才能让我的 Android 导入工作有什么建议吗?

为了完整性,这是我的 build.gradle.kts 文件:

import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinNativeTarget

plugins …
Run Code Online (Sandbox Code Playgroud)

android kotlin kotlin-multiplatform

5
推荐指数
1
解决办法
6538
查看次数

MotionLayout 使用 Crossfade - altSrc 出现在 src 之上(原始图像不会消失)

我正在使用 ImageFilterView 与 MotionScene 配合,在用户滑动时在图像之间切换(我也在向上移动图像)。

新图像确实出现,但旧图像仍然存在。我可以在原始图像的顶部看到altSrc图像。

新旧标志

难道我做错了什么? 我的期望是不是不正确,旧图像会淡出?

这是相关的代码:

布局.xml

<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.motion.widget.MotionLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/motionlayout_demo"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    app:layoutDescription="@xml/the_scene_alt"
    app:showPaths="true"
    tools:context="com.designdemo.uaha.ui.MotionLayoutActivity">

...

    <androidx.constraintlayout.utils.widget.ImageFilterView
        android:id="@+id/nerd_text_img"
        android:src="@drawable/ic_nerderytxt_old"
        app:altSrc="@drawable/ic_nerderytxt_new"
        android:layout_width="450dp"
        android:layout_height="wrap_content"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent"
        app:layout_constraintVertical_bias="0.43"/>

...

</androidx.constraintlayout.motion.widget.MotionLayout>
Run Code Online (Sandbox Code Playgroud)

the_scene_alt.xml

<?xml version="1.0" encoding="utf-8"?>
<MotionScene xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:motion="http://schemas.android.com/apk/res-auto">

    <Transition
        motion:constraintSetEnd="@+id/end"
        motion:constraintSetStart="@+id/start"
        motion:duration="1000">
        <OnSwipe
            motion:dragDirection="dragUp"
            motion:touchAnchorId="@id/text_the"
            motion:touchAnchorSide="right" />
    </Transition>

    <ConstraintSet android:id="@+id/start">
        <Constraint
            android:id="@+id/nerd_text_img"
            android:layout_width="450dp"
            android:layout_height="wrap_content"
            motion:layout_constraintBottom_toBottomOf="parent"
            motion:layout_constraintEnd_toEndOf="parent"
            motion:layout_constraintStart_toStartOf="parent"
            motion:layout_constraintTop_toTopOf="parent"
            motion:layout_constraintVertical_bias="0.43" >
            <CustomAttribute
                motion:attributeName="Crossfade"
                motion:customFloatValue="0" />
        </Constraint>        
    </ConstraintSet>

    <ConstraintSet android:id="@+id/end">   
        <Constraint
            android:id="@+id/nerd_text_img"
            android:layout_width="450dp" …
Run Code Online (Sandbox Code Playgroud)

android android-appcompat android-constraintlayout android-motionlayout

4
推荐指数
1
解决办法
1303
查看次数

如何通过 UI 测试读取 Jetpack Compose TextField 的语义值?

我是 Jetpack Compose 测试的新手,并试图弄清楚如何访问 an 的值OutlinedTextField以对它们执行 Instrumentation 测试:

我无法弄清楚访问和检查 EditField 的 SemanticsNode 中的某些值的语法。

我正在使用以下仪器测试:

@Test
fun NameTextField_LongInput_CompleteStatusAndLabelCorrect() {
    composeTestRule.setContent {
        ComposeTemplateTheme {
            NameTextInput(name = "RandomName123", onNameInfoValid = { isComplete = it })
        }
        assertEquals(isComplete, true)

        // This is accessing the label text 
        composeTestRule.onNodeWithText("Name").assertIsDisplayed()
        //How do I access the Editable text?
        //composeTestRule.onNodeWithEditableText("RandomName123") // How do I do something like this?!?!123
    }
}
Run Code Online (Sandbox Code Playgroud)

我想弄清楚如何访问这棵树中的各个项目:

printToLog:
 Printing with useUnmergedTree = 'false'
 Node #1 at (l=0.0, t=110.0, r=1080.0, b=350.0)px
  |-Node #2 at …
Run Code Online (Sandbox Code Playgroud)

android android-testing android-espresso android-jetpack-compose android-jetpack-compose-testing

4
推荐指数
1
解决办法
5912
查看次数

Google Analytics V2 - IllegalStateException - 我可以在onCreate()而不是onStart()中初始化

我正在使用新的Google Analytics Beta for Mobile.我运行代码时有时遇到以下异常:

E/AndroidRuntime(29101):java.lang.RuntimeException:无法启动活动ComponentInfo {com.wsoft/com.wsoft.ui.AppActivity}:java.lang.IllegalStateException:您必须调用EasyTracker.getInstance().setContext(context )或调用getTracker()之前的startActivity(activity)E/AndroidRuntime(29101):在android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2059)E/AndroidRuntime(29101):在android.app.ActivityThread.handleLaunchActivity(ActivityThread) .java:2084)E/AndroidRuntime(29101):在android.app.ActivityThread.access $ 600(ActivityThread.java:130)E/AndroidRuntime(29101):在android.app.ActivityThread $ H.handleMessage(ActivityThread.java: 1195)E/AndroidRuntime(29101):在android.os.Handler.dispatchMessage(Handler.java:99)E/AndroidRuntime(29101):在android.os.Looper.loop(Looper.java:137)E/AndroidRuntime( 29101):在android.app.ActivityThread.main(ActivityThread.java:4745)E/AndroidRuntime(29101):at java.lang.reflect.Method.invokeNative(Native Method)E/AndroidRuntim e(29101):at java.lang.reflect.Method.invoke(Method.java:511)E/AndroidRuntime(29101):at com.android.internal.os.ZygoteInit $ MethodAndArgsCaller.run(ZygoteInit.java:786) E/AndroidRuntime(29101):at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)E/AndroidRuntime(29101):at dalvik.system.NativeStart.main(Native Method)E/AndroidRuntime(29101) ):

引起:java.lang.IllegalStateException:在调用getTracker()E/AndroidRuntime(29101):com.google.analytics.tracking.android之前,必须调用EasyTracker.getInstance().setContext(context)或startActivity(activity). EasyTracker.getTracker(EasyTracker.java:113)E/AndroidRuntime(29101):at com.wsoft.ui.AppActivity.setupApp(AppActivity.java:425)E/AndroidRuntime(29101):at com.wsoft.ui.AppActivity.的onCreate(AppActivity.java:121)

为了设置分析,我在onStart()方法(每个文档)中初始化了EasyTracker,如下所示:

public void onStart() {
        super.onStart();
        EasyTracker.getInstance().activityStart(this); 
    }
Run Code Online (Sandbox Code Playgroud)

IllegalStateException被抛出代码,在我的onCreate()方法中执行 - 当然在onStart()之前运行 - 所以我理解为什么抛出它.

我正在考虑在onCreate()中移动EasyTracker初始化,而不是onStart().

我不应该这样做的任何理由?有关如何设置EasyTracker更可靠的任何建议(关于活动生命周期?)

或者,如果有人对我在使用之前如何确保EasyTracker初始化有任何好的建议(这会导致FC,这显然是一件坏事.

android google-analytics

3
推荐指数
1
解决办法
3156
查看次数