代码之家  ›  专栏  ›  技术社区  ›  Ravi Parmar

运动布局材料设计扩展按钮错误

  •  0
  • Ravi Parmar  · 技术社区  · 4 年前

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

    按钮在约束布局或任何其他布局(中除外)中收缩和展开都非常精细

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

    <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" />
    

    我已经验证了代码,它没有任何这样的限制,防止收缩和扩展。

    0 回复  |  直到 4 年前
        1
  •  1
  •   hoford    4 年前

    晶圆厂似乎有麻烦被测量两次(motionLayout需要这样做)

    一个简单的解决方法是将fab包装在一个容器中 就像线性布局 在MotionLayout中放置LinearLayout

     <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>