我正在使用android的TextInputLayout在EditText上顯示浮動標籤。Viewgroup裏面的TextInputLayout使浮動標籤不工作
但我想在EditText的左邊顯示一個ProgressBar,因此我在該相對佈局內的TextInputLayout和EditText中添加了一個相對佈局。
通過這樣做,浮動標籤不起作用。
如果我從TextInputLayout的相對佈局中刪除並使EditText直接指向它的子節點,那麼它就可以工作。
那麼EditTExt需要是TextInputLayout的直接子元素,如果是的話,我們怎麼能把另一個小部件放到EditTexts左邊,如ProgressBar。
由於TextInputLayout從LinearLayout獲取,向其添加子對象將垂直添加子對象,但是我想在EditText的頂部添加視圖。
<android.support.design.widget.TextInputLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/holderName"
android:layout_height="wrap_content"
android:layout_width="match_parent">
<FrameLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<android.support.design.widget.TextInputEditText
android:id="@+id/etField"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Name"
>
</android.support.design.widget.TextInputEditText>
<ProgressBar
android:id="@+id/progress"
style="?android:attr/progressBarStyle"
android:layout_width="16dp"
android:layout_height="match_parent"
android:indeterminateTint="@color/primary"
android:layout_gravity="right|center_vertical"
android:layout_marginRight="15dp"
android:visibility="visible"
/>
</FrameLayout>
哪裏是你的代碼先生的職位? – Remario
我已經發布了代碼,即使代碼中有FrameLayout作爲子代,但不是相對於每個問題的佈局。 –