FloatingActionButton下方的协调器布局TextInput [英] Coordinator layout TextInput below FloatingActionButton

查看:116
本文介绍了FloatingActionButton下方的协调器布局TextInput的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在这里遇到协调员布局方面的问题. 我有TextInputLayout,里面有editText.我要的是在单击左侧的FAB时显示它,然后在单击FAB时隐藏它.

Halloo guys I have problem here with coordinator layout. I have TextInputLayout and inside it I have editText. What I want is to show it on click on FAB on the left side and hide on click on FAB.

但是我总是对FAB以下的编辑文本有疑问:

But I have always problem with edit text going below FAB:

使用marginRight只能以某种方式实现它,请参见下面的xml.但是如果没有它,有没有办法做到这一点,我认为必须有更好的办法.

Only way I was able to somehow do it is with using marginRight, see xml below. But is there any way to do it without that I think there must be better way.

<android.support.design.widget.FloatingActionButton
    android:id="@+id/fab"
    android:layout_width="@dimen/fab_normal_size"
    android:layout_height="@dimen/fab_normal_size"
    android:layout_gravity="bottom|end"
    android:layout_margin="@dimen/fab_margin"
    app:fabSize="normal"
    android:src="@drawable/ic_add_black_24dp" />


<android.support.design.widget.TextInputLayout
    android:id="@+id/input_layout_txt"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    app:layout_anchor="@id/fab"
    app:layout_anchorGravity="left|center_vertical"
    android:layout_marginRight="@dimen/fab_normal_size">

    <EditText
        android:id="@+id/input_txt"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:hint="banany"
        android:text="testestes....." />

推荐答案

FAB始终通过UI

FAB is always over UI by design:

浮动操作按钮用于特殊类型的促销 行动.它们的特点是带有圆圈的图标浮在用户界面上方 并具有与变形,发射和变形有关的特殊运动行为 转移锚点.

Floating action buttons are used for a special type of promoted action. They are distinguished by a circled icon floating above the UI and have special motion behaviors related to morphing, launching, and the transferring anchor point.

我还没有检查过它的实现方式,因此,除非其他人提供更好的答案,否则您可以检查CoordinatorLayout和FAB来源以查看是什么使它悬停在UI上,或者如果时间很短,则只需放一些类似于FAB (您可以使用带有适当drawable的常规按钮,也可以使用第三方库).

I haven't checked how it is implemented so unless someone else come with better answer you can either check CoordinatorLayout and FAB sources to see what makes it hoovering over UI, or if time is short you simply put something that looks like FAB (either you use regular button with proper drawable, or 3rd party lib).

这篇关于FloatingActionButton下方的协调器布局TextInput的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆