首页 \ 问答 \ 协调器布局TextInput在FloatingActionButton下面(Coordinator layout TextInput below FloatingActionButton)

协调器布局TextInput在FloatingActionButton下面(Coordinator layout TextInput below FloatingActionButton)

Halloo伙计们我在协调员布局方面遇到问题。 我有TextInputLayout,在里面我有editText。 我想要的是点击左侧的FAB显示它并隐藏点击FAB。

但我总是有问题编辑文本在FAB下面: 但我总是遇到编辑文本在FAB下面的问题

只有我能够以某种方式做到这一点是使用marginRight ,请参阅下面的xml。 但是没有任何方法可以做到这一点我认为必须有更好的方法。

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

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.

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

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

原文:https://stackoverflow.com/questions/37121028
更新时间:2021-09-06 11:09

最满意答案

你最大的问题不是循环。 对于矩阵这么小的调用MATLABs A*B引入了很多开销。 您可以做的最好的事情是将所有矩阵存储在一个大的4 x n_matrices矩阵中并手动拼出矩阵乘法:

A = rand(4, 1000);
B = rand(4, 1000);

tic;
C = zeros(size(A));
C(1,:) = A(1,:).*B(1,:) + A(3,:).*B(2,:);
C(2,:) = A(2,:).*B(1,:) + A(4,:).*B(2,:);
C(3,:) = A(1,:).*B(3,:) + A(3,:).*B(4,:);
C(4,:) = A(2,:).*B(3,:) + A(4,:).*B(4,:);
toc

Elapsed time is 0.020950 seconds.

如您所见,这需要很少的时间(这是一台6年的台式PC)。 对于像这样的小矩阵来说这是实用的,我无法想象用MATLAB编写的其他任何可以击败这种性能的东西。 好吧,对于非常大量的2x2矩阵,您可以引入阻塞(即,一次只处理多个矩阵)以增强缓存重用。


Your biggest problem is not the loops. For matrices so small calling MATLABs A*B introduces a lot of overhead. The best thing you can do is to store all the matrices in a large 4 x n_matrices matrix and spell out the matrix multiplications manually:

A = rand(4, 1000);
B = rand(4, 1000);

tic;
C = zeros(size(A));
C(1,:) = A(1,:).*B(1,:) + A(3,:).*B(2,:);
C(2,:) = A(2,:).*B(1,:) + A(4,:).*B(2,:);
C(3,:) = A(1,:).*B(3,:) + A(3,:).*B(4,:);
C(4,:) = A(2,:).*B(3,:) + A(4,:).*B(4,:);
toc

Elapsed time is 0.020950 seconds.

As you see, this takes little time (this is a 6-years old desktop PC). For small matrices like this it is practical and I can not imagine anything else written in MATLAB that could beat this performance-wise. Well, for very large number of 2x2 matrices you could introduce blocking (i.e., handle only a number of matrices at a time) to enhance cache reuse.

相关问答

更多
  • 这是我的结果,使用MATLAB R2011a + 并行计算工具箱在一台具有特斯拉C2070的机器上: >> A = rand(1024); gA = gpuArray(A); % warm up by executing the operations a couple of times, and then: >> tic, C = A * A; toc Elapsed time is 0.075396 seconds. >> tic, gC = gA * gA; toc Elapsed time is 0. ...
  • 使用单元阵列。 喜欢这个 c = cell(3,3) %Create cell array of size *3x3* c = [] [] [] [] [] [] [] [] [] c{1,1}; = rand(3,3); %Set cell {1,1} to be random matrix of size *3x3* c{1,2} = ones(4,6) %Set cell {1,2} to be matrix of ones si ...
  • 由于矩阵乘法在Matlab中高度优化,所以在底层使用LAPACK库。 你会发现很难击败那些图书馆的表现。 当然,简单的嵌套循环不会考虑缓存效果 ,因此会表现出糟糕的性能。 Because matrix multiplication is highly optimised in Matlab, using LAPACK libraries under the hood. You will find it hard to beat the performance of those libraries. Cert ...
  • 你最大的问题不是循环。 对于矩阵这么小的调用MATLABs A*B引入了很多开销。 您可以做的最好的事情是将所有矩阵存储在一个大的4 x n_matrices矩阵中并手动拼出矩阵乘法: A = rand(4, 1000); B = rand(4, 1000); tic; C = zeros(size(A)); C(1,:) = A(1,:).*B(1,:) + A(3,:).*B(2,:); C(2,:) = A(2,:).*B(1,:) + A(4,:).*B(2,:); C(3,:) = A(1,:) ...
  • 你有两个问题: 在Python中,您可以计算随机初始化以及计算,而Fortran和MATLAB则不然 在Fortran中,您可以在Python和MATLAB中测量经过的时间来测量CPU时间。 而且由于您注意到CPU使用率约为46%,这可能只是解释了差异。 只需修复这两件事date_and_time()试......您可以考虑使用date_and_time()而不是cpu_time()来实现此目的。 You have two issues here: In Python, you time the rando ...
  • 正如评论中所提到的, bsxfun可以在重塑B之后使用,就像这样 - squeeze(sum(bsxfun(@times,reshape(B,size(A,2),[],size(B,2)),A.'),1)) As mentioned in the comments, bsxfun could be used after reshaping B, like so - squeeze(sum(bsxfun(@times,reshape(B,size(A,2),[],size(B,2)),A.'),1))
  • Matlab的reshape功能非常方便(快速),但总是读写完整的列。 因此,对于您的问题,还需要一些额外的步骤。 以下是如何做到这一点: m = 5 % columns of submatrix n = 4 % rows of submatrix k = 50 % num submatrixes in matrix column l = 50 % num submatrixes in matrix row A = rand(m*k,n*l); % rand(250,200) 将矩阵重新整形为四维矩阵(维 ...
  • 这是一种方式: C = bsxfun(@times, A, B) 根据文档 ,得到的矩阵C是稀疏的: 如果两个操作数都是稀疏的,则二元运算符产生稀疏结果,如果两个操作数都是满的,则产生完整结果。 对于混合操作数,除非操作保留稀疏性,否则结果将为完整 。 如果S稀疏且F满,则S + F,S * F和F \ S满, 而S. * F和S&F稀疏 。 在某些情况下,即使矩阵的零元素很少,结果也可能是稀疏的。 Here's one way: C = bsxfun(@times, A, B) According t ...
  • 首先:我假设nnz(A)相当低。 我刚用nnz(A) = 9999963测试了它,并且size(A) = 1000000x1000000 。 直观的方法是使用“块”中的数据。 取前10000列(所有行)和前10000行(所有列),下一个10000,下一个等。我相信这应该避免内存问题。 我刚刚测试了A*A ,并且遇到了和你一样的内存问题。 我做的是,将A转换为逻辑: A_logical = logical(A) 。 这大大减少了矩阵的大小。 注意,您不能使用uint8或类似的东西,因为sparse支持的唯一数 ...
  • 您正在尝试计算每行的外积,并将其自身存储为3D矩阵中的单个切片。 你的代码几乎可以工作 你正在做的是计算每行的内积或点积。 因此它会给你一个数字而不是矩阵。 您需要更改转置操作,以便在P1上完成,而不是P2 , P2现在只需P1 。 此外,您在每次迭代时都会覆盖矩阵M 我假设您想将这些作为单个切片存储在3D矩阵中。 为此,请分配一个3D矩阵,其中每个2D切片具有相同数量的行和列,这是D的列数,而切片总数等于D的总行数。 然后只需索引到每个切片并相应地放置结果: M = zeros(size(D,2), si ...

相关文章

更多

最新问答

更多
  • 您如何使用git diff文件,并将其应用于同一存储库的副本的本地分支?(How do you take a git diff file, and apply it to a local branch that is a copy of the same repository?)
  • 将长浮点值剪切为2个小数点并复制到字符数组(Cut Long Float Value to 2 decimal points and copy to Character Array)
  • OctoberCMS侧边栏不呈现(OctoberCMS Sidebar not rendering)
  • 页面加载后对象是否有资格进行垃圾回收?(Are objects eligible for garbage collection after the page loads?)
  • codeigniter中的语言不能按预期工作(language in codeigniter doesn' t work as expected)
  • 在计算机拍照在哪里进入
  • 使用cin.get()从c ++中的输入流中丢弃不需要的字符(Using cin.get() to discard unwanted characters from the input stream in c++)
  • No for循环将在for循环中运行。(No for loop will run inside for loop. Testing for primes)
  • 单页应用程序:页面重新加载(Single Page Application: page reload)
  • 在循环中选择具有相似模式的列名称(Selecting Column Name With Similar Pattern in a Loop)
  • System.StackOverflow错误(System.StackOverflow error)
  • KnockoutJS未在嵌套模板上应用beforeRemove和afterAdd(KnockoutJS not applying beforeRemove and afterAdd on nested templates)
  • 散列包括方法和/或嵌套属性(Hash include methods and/or nested attributes)
  • android - 如何避免使用Samsung RFS文件系统延迟/冻结?(android - how to avoid lag/freezes with Samsung RFS filesystem?)
  • TensorFlow:基于索引列表创建新张量(TensorFlow: Create a new tensor based on list of indices)
  • 企业安全培训的各项内容
  • 错误:RPC失败;(error: RPC failed; curl transfer closed with outstanding read data remaining)
  • C#类名中允许哪些字符?(What characters are allowed in C# class name?)
  • NumPy:将int64值存储在np.array中并使用dtype float64并将其转换回整数是否安全?(NumPy: Is it safe to store an int64 value in an np.array with dtype float64 and later convert it back to integer?)
  • 注销后如何隐藏导航portlet?(How to hide navigation portlet after logout?)
  • 将多个行和可变行移动到列(moving multiple and variable rows to columns)
  • 提交表单时忽略基础href,而不使用Javascript(ignore base href when submitting form, without using Javascript)
  • 对setOnInfoWindowClickListener的意图(Intent on setOnInfoWindowClickListener)
  • Angular $资源不会改变方法(Angular $resource doesn't change method)
  • 在Angular 5中不是一个函数(is not a function in Angular 5)
  • 如何配置Composite C1以将.m和桌面作为同一站点提供服务(How to configure Composite C1 to serve .m and desktop as the same site)
  • 不适用:悬停在悬停时:在元素之前[复制](Don't apply :hover when hovering on :before element [duplicate])
  • 常见的python rpc和cli接口(Common python rpc and cli interface)
  • Mysql DB单个字段匹配多个其他字段(Mysql DB single field matching to multiple other fields)
  • 产品页面上的Magento Up出售对齐问题(Magento Up sell alignment issue on the products page)