TextInputLayout未显示

时间:2016-10-11 07:39:08

标签: android xml material-design

我是Android应用开发领域的新手。我现在正在尝试一些基本的东西。目前,我正在努力实现像各种材料设计应用程序中看到的浮动标签。

我要做的是获得CardView并在该卡中放置TextInputLayout

<android.support.v7.widget.CardView
        android:layout_width="310dp"
        android:layout_height="250dp"
        android:layout_below="@+id/textView"
        android:layout_alignRight="@+id/textView"
        android:layout_alignEnd="@+id/textView"
        android:layout_marginTop="13dp" >

        <RelativeLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent">
            <android.support.design.widget.TextInputLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content">

                <EditText
                    android:id="@+id/labeltest"
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:hint="floating label"/>
            </android.support.design.widget.TextInputLayout>
        </RelativeLayout>
    </android.support.v7.widget.CardView>

现在,当我这样做时,我会得到一张像我应该得到的CardView,但TextInputLayout并没有出现。但是,我可以点击它,之后它会聚焦并让我输入文本。 (见下面的例子)

我想补充一点,我是在虚拟机上测试它,而不是在实际设备上测试它。

感谢。

Example 1

修改:根据请求,colors.xml

<resources>
    <color name="colorPrimary">#E43F3F</color>
    <color name="colorPrimaryDark">#E12929</color>
    <color name="primary_darker">#CC1D1D</color>
    <color name="colorAccent">#FFFFFF</color>

    <color name="black">#000000</color>
    <color name="jet">#222222</color>
    <color name="oil">#333333</color>
    <color name="monsoon">#777777</color>
    <color name="jumbo">#888888</color>
    <color name="aluminum">#999999</color>
    <color name="base">#AAAAAA</color>
    <color name="iron">#CCCCCC</color>
    <color name="white">#FFFFFF</color>
    <color name="Trans_text">#a8ffffff</color>
</resources>

1 个答案:

答案 0 :(得分:1)

如果您已阅读Material Design Guidelines,则会发现'kittens': { create: function(options) { var dataWithParent = Object.assign({}, options.data, { parent: options.parent }); return new KittenModel(dataWithParent); } }, 被用作字段下方行的颜色。您将colorAccent设置为白色(请参阅colorAccent文件),因此,我的猜测是colors.xmlTextInputLayout的背景颜色相混合,后者也是白色或相似的东西。尝试将parent更改为红色或其他内容以查看是否存在问题。