【问题标题】:Motion layout Material design Expanded Button bug运动布局材料设计扩展按钮错误
【发布时间】:2021-04-03 04:19:45
【问题描述】:

我有一个实现了扩展按钮的应用程序。

在约束布局或除运动布局之外的任何其他布局中,按钮可以完美地收缩和展开。

在收缩后按钮不展开,而在展开状态时,当按钮的状态在单击按钮时变为收缩时,文本消失但大小保持不变。

材料设计链接版本“实现'com.google.android.material:material:1.3.0-beta01'”

<com.google.android.material.floatingactionbutton.ExtendedFloatingActionButton
        android:id="@+id/btn_call_helpline"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginBottom="@dimen/dimen_20dp"
        android:text="@string/txt_emergency"
        android:textColor="@color/color_white"
        app:backgroundTint="@color/red"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintBottom_toBottomOf="parent"
        app:cornerRadius="@dimen/dimen_20dp"
        app:elevation="@dimen/dimen_10dp"
        app:icon="@drawable/ic_baseline_call_24"
        app:iconTint="@color/color_white"
        app:rippleColor="@color/color_white" />

我已经验证了代码,它没有任何阻止收缩和扩展的约束。

【问题讨论】:

    标签: android material-design floating-action-button android-motionlayout


    【解决方案1】:

    FAB 似乎无法进行两次测量。 (motionLayout 需要这样做)

    一个简单的解决方法是将晶圆厂包装在一个容器中 像线性布局 将LinearLayout放入MotionLayout

     <LinearLayout
       android:id="@+id/fabwrap"
       android:layout_width="wrap_content"
       android:layout_height="wrap_content"
       android:layout_marginBottom="20dp"
       app:layout_constraintEnd_toEndOf="parent"
       app:layout_constraintBottom_toBottomOf="parent"
       >
    
       <com.google.android.material.floatingactionbutton.ExtendedFloatingActionButton
        android:id="@+id/fab"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
    
        android:text="hello"
        android:textColor="@color/white"
        app:backgroundTint="#F00"
        app:icon="@drawable/ic_battery"/>
       </LinearLayout>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-06-28
      • 2015-01-04
      • 1970-01-01
      • 1970-01-01
      • 2019-11-01
      相关资源
      最近更新 更多