1
我是Android应用程序开发领域的新手。我目前正在尝试一些基本的东西。目前,我正在尝试实现像各种材质设计应用中看到的浮动标签。TextInputLayout未显示
我想要做的是得到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显示不出来。不过,我可以点击它,然后重点并让我输入文字。 (请参阅下面的示例)
我想补充一点,我在虚拟机上测试它,而不是在实际设备上测试它。
谢谢。
编辑:根据要求,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>
'android:layout_height =“wrap_content”'in edit text。在你当前的代码中,parent有wrap_content,child有match_parent,它们相互抵消为0,因此确保有适当的子代和父代。layout_params –
建议在TextInputLayout中使用'TextInputEditText'而不是普通的'EditText' https ://developer.android.com/reference/android/support/design/widget/TextInputEditText.html –
@MohammedAtif刚刚尝试过'android.support.design.widget.TextInputEditText'。当我使用它时,它变得完全不可见且不可点击 –