小编kja*_*on2的帖子

Android 10 手势导航禁用

TLDR:我需要一种以编程方式禁用 Android 10 手势导航的方法,以便他们在从侧面滑动时不会意外返回

背景故事:Android 10 引入了手势导航,而不是底部的按钮。因此,现在在启用了该功能的 Android 10 设备上,他们可以从屏幕任意一侧滑动以返回,从底部滑动以导航至主页或在应用程序之间导航。然而,我正在研究 AR 中的实现,并希望将屏幕锁定为纵向,但允许用户横向显示。

如果用户将手机转为横向,但活动锁定为纵向,则返回手势导航现在是从顶部滑动,这是在全屏应用程序(就是这个)中访问状态栏的常见方式,因此用户如果他们习惯了 Android 导航,他们会不经意地返回并留下体验。

有谁知道如何a)以编程方式禁用Android 10的手势导航(但用户如何返回/回家?)或b)知道如何仅更改手势方向而不需要您的活动支持横向?

android gesture-recognition gesture android-orientation onbackpressed

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

API 19 Scrollview没有动力

我在CoordinatorLayout中有一个NestedScrollView,它包含一个recyclerView.整个片段很长,没有滚动动量,我不知道我能做些什么来修复它.我以前有更高的Android版本的问题,并能够包括

android:nestedScrollingEnabled="false"
Run Code Online (Sandbox Code Playgroud)

解决我的问题.但是,这是在api 21中添加的,我的项目支持19+.对于api 19设备,我的应用程序仍然没有这个片段的动力.

下面是我的xml:

<android.support.design.widget.CoordinatorLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_height="match_parent"
    android:layout_width="match_parent"
    android:background="@color/primary_color"
    android:fitsSystemWindows="true">

<android.support.v4.widget.NestedScrollView
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        app:layout_behavior="android.support.design.widget.AppBarLayout$ScrollingViewBehavior">

    <android.support.percent.PercentRelativeLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:nestedScrollingEnabled="false">

        <ImageView
                android:id="@+id/logo"
                android:src="@drawable/logo"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_marginTop="@dimen/profile_margin_medium_huge"
                android:layout_marginBottom="46dp"
                android:layout_marginRight="@dimen/activity_horizontal_margin"
                android:layout_marginLeft="@dimen/activity_horizontal_margin"
                android:layout_alignParentEnd="true"/>

        <TypefaceTextView
                android:id="@+id/textview_title"
                android:layout_below="@id/logo"
                android:text="@string/title"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                style="@style/myStyle"
                android:layout_marginLeft="@dimen/activity_horizontal_margin"
                android:layout_marginRight="@dimen/activity_horizontal_margin"
                android:layout_marginBottom="16dp"
                android:layout_alignParentLeft="true"/>

        <TypefaceTextView
                android:id="@+id/textview_byline"
                android:text="@string/byline"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                style="@style/myStyle"
                android:layout_below="@id/textview_title"
                android:layout_marginLeft="@dimen/activity_horizontal_margin"
                android:layout_marginRight="@dimen/activity_horizontal_margin"
                android:layout_marginBottom="40dp"/>

        <RadioGroup
                android:id="@+id/radiogroup_filter"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:orientation="horizontal"
                android:layout_below="@id/textview_byline"
                android:layout_alignParentRight="true"
                android:layout_marginLeft="@dimen/activity_horizontal_margin"
                android:layout_marginRight="@dimen/activity_horizontal_margin"
                android:layout_marginBottom="@dimen/activity_vertical_margin">

            <TypefaceRadioButton
                    android:id="@+id/button_filter_new"
                    android:text="@string/filter_new"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    style="@style/buttonStyleRadio"
                    android:theme="@style/ButtonSecondary"
                    android:button="@null"/>

            <TypefaceRadioButton
                    android:id="@+id/button_filter_history"
                    android:text="@string/filter_history"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    style="@style/ButtonStyleRadio"
                    android:theme="@style/ButtonSecondary"
                    android:layout_alignParentRight="true"
                    android:button="@null"/> …
Run Code Online (Sandbox Code Playgroud)

xml layout android android-4.4-kitkat android-coordinatorlayout

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

Android MotionLayout 运动交错

我试图让我的视图使用 MotionLayout 进行动画处理,但希望某些约束在其他约束之前进行动画处理。我认为这是 Motion:staggered property for Transition 的目的,但我不明白它是如何工作的,也没有它在任何地方成功工作的例子。使用 MotionLayout 的更新版本,似乎我们应该为单个约束设置 motion:motionStagger 但我似乎无法让它按需要交错。我在这里只能找到解释增强型交错 API 的文档,但我不明白如何使用它。

我在下面添加了我的 MotionLayout 代码。作为参考,我使用的2.0.0-beta3'是 ConstraintLayout的版本

<?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="300"
    motion:motionInterpolator="easeInOut"
    motion:staggered="0.4" />

<ConstraintSet android:id="@+id/start">
    <Constraint android:id="@id/translucentOverlay">
        <Layout
            android:layout_width="5dp"
            android:layout_height="5dp"
            motion:layout_constraintBottom_toBottomOf="@id/imageBorder"
            motion:layout_constraintEnd_toEndOf="@id/imageBorder"
            motion:layout_constraintStart_toStartOf="@id/imageBorder"
            motion:layout_constraintTop_toTopOf="@id/imageBorder" />
        <CustomAttribute
            motion:attributeName="alpha"
            motion:customFloatValue="0.0" />
        <Motion motion:motionStagger="2" />
    </Constraint>

    <Constraint android:id="@id/imageBorder">
        <Layout
            android:layout_width="48dp"
            android:layout_height="48dp"
            android:layout_marginStart="8dp"
            android:layout_marginTop="8dp"
            android:layout_marginEnd="8dp"
            android:layout_marginBottom="8dp"
            motion:layout_constraintEnd_toEndOf="parent"
            motion:layout_constraintTop_toTopOf="parent" />
        <CustomAttribute
            motion:attributeName="crossfade"
            motion:customFloatValue="0" />
        <Motion motion:motionStagger="2" />
    </Constraint>

    <Constraint android:id="@id/imageBackground">
        <Layout
            android:layout_width="32dp"
            android:layout_height="32dp" …
Run Code Online (Sandbox Code Playgroud)

layout animation android motion

2
推荐指数
1
解决办法
2271
查看次数