我有一个带浮动标签的editText(提示)。我还为该editText添加了一个图标。我希望标签位于图标的顶部,但它出现在图标后面的顶部。我正在使用此依赖项 - 编译'com.github.vajro:MaterialDesignLibrary:1.6'
我的xml:
<ScrollView xmlns:tools="http://schemas.android.com/tools"
tools:context="com.itjobnotification.first.app.signupActivity"
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/scrollView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:fillViewport="true"
android:scrollbars="none">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:materialdesign="http://schemas.android.com/apk/res-auto"
>
<android.support.v7.widget.CardView
xmlns:card_view="http://schemas.android.com/apk/res-auto"
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/card_view"
android:layout_gravity="center"
android:layout_width="fill_parent"
android:layout_height="200dp"
android:layout_margin="5dp"
card_view:cardBackgroundColor="@android:color/transparent"
card_view:cardCornerRadius="2dp"
card_view:contentPadding="10dp">
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<TextView
android:id="@+id/textView"
android:text="Personal Details"
android:layout_marginTop="4dp"
android:layout_marginLeft="5dp"
android:textSize="18dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"/>
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_marginTop="5dp"
android:background="#d7d7d8"
android:layout_below="@+id/textView"/>
<android.support.design.widget.TextInputLayout
android:id="@+id/input_layout_name"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/textView"
android:layout_marginTop="15dp"
android:layout_marginLeft="-4dp"
android:layout_marginRight="-4dp"
android:layout_alignParentLeft="true">
<EditText
android:id="@+id/name"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Name"
android:paddingLeft="3dp"
android:drawableLeft="@drawable/name"
android:maxLines="1"/>
</android.support.design.widget.TextInputLayout>
<android.support.design.widget.TextInputLayout
android:id="@+id/input_layout_email"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/input_layout_name"
android:layout_marginTop="12dp"
android:layout_marginLeft="-4dp"
android:layout_marginRight="-4dp"
android:textColor="#ffffff"
android:layout_alignParentLeft="true">
<EditText
android:id="@+id/email"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Email"
android:maxLines="1"
/>
</android.support.design.widget.TextInputLayout>
</RelativeLayout>
</android.support.v7.widget.CardView>
<android.support.v7.widget.CardView
xmlns:card_view="http://schemas.android.com/apk/res-auto"
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/card_view_professional"
android:layout_below="@+id/card_view"
android:layout_gravity="center"
android:layout_width="fill_parent"
android:layout_height="200dp"
android:layout_margin="5dp"
card_view:cardBackgroundColor="@android:color/transparent"
card_view:cardCornerRadius="2dp"
card_view:contentPadding="10dp">>
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:id="@+id/prof">
<TextView
android:id="@+id/textView1"
android:text="Professional Details"
android:layout_marginTop="4dp"
android:layout_marginLeft="5dp"
android:textSize="18dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"/>
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_marginTop="5dp"
android:background="#d7d7d8"
android:layout_below="@+id/textView1"/>
<android.support.design.widget.TextInputLayout
android:id="@+id/input_layout_years"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/textView1"
android:layout_marginTop="15dp"
android:layout_marginLeft="-4dp"
android:layout_marginRight="-4dp"
android:layout_alignParentLeft="true">
<EditText
android:id="@+id/yearsOfExperience"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Years of Experience"
android:maxLines="1"/>
</android.support.design.widget.TextInputLayout>
<android.support.design.widget.TextInputLayout
android:id="@+id/input_layout_ctc"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/input_layout_years"
android:layout_marginTop="12dp"
android:layout_marginLeft="-4dp"
android:layout_marginRight="-4dp"
android:textColor="#ffffff"
android:layout_alignParentLeft="true">
<EditText
android:id="@+id/ctc"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Current CTC (in LPA)"
android:maxLines="1"
/>
</android.support.design.widget.TextInputLayout>
<Spinner
android:id="@+id/college"
style="@android:style/Widget.ListView.DropDown"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:dropDownWidth="wrap_content"
android:layout_gravity="center"
android:entries="@array/college"
android:layout_marginTop="20dp"
android:layout_below="@+id/input_layout_ctc"
android:layout_weight="1"
android:focusable="false"
android:focusableInTouchMode="false"
android:text="1"
android:layout_alignLeft="@+id/input_layout_ctc" />
<Spinner
android:id="@+id/loc"
style="@android:style/Widget.ListView.DropDown"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:dropDownWidth="wrap_content"
android:layout_gravity="center"
android:entries="@array/location"
android:layout_marginTop="40dp"
android:layout_below="@+id/college"
android:layout_weight="1"
android:focusable="false"
android:focusableInTouchMode="false"
android:text="1"
android:layout_alignLeft="@+id/input_layout_ctc" />
</RelativeLayout>
</android.support.v7.widget.CardView>
<android.support.design.widget.TextInputLayout
android:id="@+id/input_layout_promo"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/card_view_professional"
android:layout_marginTop="12dp"
android:layout_marginLeft="-4dp"
android:layout_marginRight="-4dp"
android:textColor="#ffffff"
android:layout_alignParentLeft="true">
<EditText
android:id="@+id/promocode"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Promo Code (Optional)"
android:maxLines="1"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
/>
</android.support.design.widget.TextInputLayout>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text=""
android:layout_below="@+id/button"
android:layout_marginTop="15dp"
android:layout_marginBottom="10dp"
android:layout_gravity="center_horizontal"
android:id="@+id/terms"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true" />
<com.gc.materialdesign.views.ButtonRectangle
android:id="@+id/button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#1E88E5"
android:layout_marginTop="10dp"
android:text="Button"
android:layout_below="@+id/chooseSkills"
android:layout_alignLeft="@+id/card_view_professional"
android:layout_alignRight="@+id/card_view" />
<com.gc.materialdesign.views.ButtonRectangle
android:id="@+id/chooseSkills"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#1E88E5"
android:text="Choose skills"
android:layout_marginTop="10dp"
android:layout_below="@+id/input_layout_promo"
android:layout_alignLeft="@+id/button"
android:layout_alignRight="@+id/card_view" />
</RelativeLayout>
</ScrollView>
答案 0 :(得分:0)
好吧我没有完全得到这个问题,但是当我添加填充错误的自定义背景时我遇到了TextInputLayout的问题所以我最终添加了一些使用xml背景的额外填充可能这将帮助你然后添加thia as编辑文本的背景
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:drawable="@drawable/edittext_selector"
android:top="@dimen/activity_medim_margin">
<!--<your original background; can be <bitmap> or <shape> or whatever./>-->
</item>