Reputation: 2780
I'm quite new in the world of Android app development. I'm currently trying out some basic things. Currently I'm trying to achieve a floating label like the ones seen in various material design apps.
What I'm trying to do is get a CardView
and place a TextInputLayout
in that card.
<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>
Now when I do this, I get a CardView like I'm supposed to get, but the TextInputLayout doesn't show up. However, I can tap it, after which it focusses and lets me enter text. (see example below)
I would like to add that I'm testing it on a virtual machine, not on an actual device.
Thanks.
Edit: As per request, 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>
Upvotes: 1
Views: 1775
Reputation: 2643
If you'll read the Material Design Guidelines you'll find that the colorAccent
is used as color for the line below your field. You have the colorAccent
set to white (see colors.xml
file) so, my guess is that the TextInputLayout
is blending with the background color of the parent
which is also white or something similar. Try changing the colorAccent
in red or something to see if it was the problem.
Upvotes: 1