浮动标签微调? [英] Floating label Spinner?

查看:293
本文介绍了浮动标签微调?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用后,Android设计支持库的 TextInputLayout 放置一个以上的浮动标签的 的EditText 组成部分,我想知道是否有一种方法可以浮动标签添加到的 微调 组件(不一定使用设计库)。

After using the Android Design Support Library's TextInputLayout to place a floating label above an EditText component, I was wondering if there is a way to add a floating label to the Spinner component (not necessarily using the Design Library).

这样,我的意思是这样一个 的TextView 上面摆放着微调(显然没有如动画的 TextInputLayout ),但我想在文字大小,字体和颜色以匹配 TextInputLayout 的浮动标签的

By this, I mean something like a TextView placed above the Spinner (obviously no animations like the TextInputLayout), but I want the text size, font and colour to match that of the TextInputLayout's floating label.

例如,它会是这个样子(见上面的标签微调 S):

For example, it would look something like this (see the labels above the Spinners):

在这里输入的形象描述

正如我前面提到的,我的主要目的是上面有一个标签微调,就像在 TextInputLayout - 所以文本大小,字体,颜色,标签和成分之间的距离将是相同的

As I mentioned before, my main aim is to have a label above the Spinner, just as in the TextInputLayout - so text size, font, colour, and distances between the label and the component would be the same.

在了解谷歌网页设计浮动标签文本字段的,有示出相对于该部件的标签的尺寸的图,但没有标签文本颜色或大小的指示:

On the Google Design page about floating label text fields, there is a diagram showing dimensions of the label relative to the component, but there is no indication of the label text colour or size:

在这里输入的形象描述

因此,要总结,我问:结果
- 如果有一个特殊的组件来实现什么,我问或自定义视图我可以使用,那会是什么,以及如何我可以用它结果。
- 如果不是,什么是浮动标签文字大小,颜色和字体,这样我可以放置一个的TextView 我上面的微调与上面的图片中显示的布局尺寸。

So, to summarise, I am asking:
- If there is a special component to achieve what I am asking or a custom view I can use, what would it be, and how can I use it.
- If not, what is the floating label text size, colour and font, so that I can place a TextView above my Spinner with the layout dimensions shown in the above image.

谷歌设计文本字段准则,它hasthe以下为浮动标签:

From the Google Design guidelines for text fields, it hasthe following for floating labels:

提示输入字体:定期的Roboto结果16SP
  标签字体:定期的Roboto结果12SP
  瓷砖高度:72dp结果
  文字顶部和底部填充:16DP结果
  文本字段分填充:8DP

Hint and input font: Roboto Regular 16sp
Label font: Roboto Regular 12sp
Tile height: 72dp
Text top and bottom padding: 16dp
Text field divider padding: 8dp

以及上面显示的图像。

as well as the images shown above.

所以浮动标签字体是: 的Roboto定期12SP 的。因此,您可以使用的TextView 显示微调标签,因为我不知道任何自定义的查看 s或特殊成分可以使用。

So the floating label font is: Roboto Regular 12sp. You can therefore use a TextView to display the Spinner label as I do not know of any custom Views or special components you could use.

然而,尝试出来后,它看起来不作为图中所示的例子一样好。 A 自定义视图可能是此更好,因为它可能看起来更好,但上面的解决方案是实现东西接近我本来想只是其中一种方法。

However, after trying it out, it does not look quite as good as the example shown in the image. A custom view may be better for this, as it could look nicer, but the solution above is just one way of achieving something close to what I originally wanted.

推荐答案

我创建了显示上述标签的复合查看组件的微调。为标签的文本可以用XML或Java中进行设置。

I have created a compound View component which displays a label above the Spinner. The text for the label can be set using XML or in Java.

该组件有一个微调的主要特点(的不是所有的人),以及寻找类似 TextInputLayout 部分。

The component has the key features of a Spinner (not all of them) as well as looking similar to the TextInputLayout component.

我已经把它命名为一个 LabelledSpinner ,它是可用的在这里,作为在GitHub上一个Android库中的的rel=\"nofollow\"> Apache 2.0许可

I have named it a LabelledSpinner, and it is available here, as an Android library on GitHub under the Apache 2.0 License.

要使用它,添加在的build.gradle 文件库相关:

To use it, add the library dependency in your build.gradle file:

compile 'com.farbod.labelledspinner:labelledspinner:+'

其使用的例子可以在GitHub的库(包括一个示例应用程序,以及使用指南)。

Examples of its usage are available at the GitHub repository (both a sample app, and a usage guide).

这篇关于浮动标签微调?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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