ярлык не показывался - PullRequest
       1

ярлык не показывался

0 голосов
/ 14 ноября 2018

Вот так выглядит мой интерфейс в Android Studio:

enter image description here

Это мой интерфейс в реальном устройстве:

enter image description here

Почему метка не появилась, и я даже не могу изменить цвет фона EditText?

Вот некоторые из моего XML-файла кода, для приведенной ниже части я использую ScrollView, а для цветной части я использую Относительный макет.Оба эти макета находятся в CardView.

<?xml version="1.0" encoding="utf-8"?>
<android.support.v7.widget.CardView 
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:card_view="http://schemas.android.com/apk/res-auto"
xmlns:app="http://schemas.android.com/tools"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/card_view"

<ScrollView
    android:layout_width="match_parent"
    android:layout_marginTop="235dp"
    android:layout_height="wrap_content"
    android:fillViewport="true">


    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginLeft="30dp"
        android:layout_marginRight="30dp"
        android:layout_marginTop="20dp"
        android:orientation="vertical"
        android:background="@color/transparent">

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="vertical"
            android:background="@color/transparent">


            <studio.carbonylgroup.textfieldboxes.TextFieldBoxes
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                app:labelText="Email"
                app:hasClearButton="true">

                <studio.carbonylgroup.textfieldboxes.ExtendedEditText
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_marginTop="8dp"
                    android:layout_marginBottom="8dp"
                    android:inputType="textEmailAddress"
                    android:id="@+id/input_email"/>

            </studio.carbonylgroup.textfieldboxes.TextFieldBoxes>



        </LinearLayout>

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginTop="15dp"
            android:orientation="vertical"
            android:background="@color/transparent">

            <studio.carbonylgroup.textfieldboxes.TextFieldBoxes
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                app:labelText="Username"
                app:hasClearButton="true">

                <studio.carbonylgroup.textfieldboxes.ExtendedEditText
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:id="@+id/input_name"
                    android:inputType="textPersonName"
                    android:layout_marginTop="8dp"
                    android:layout_marginBottom="8dp"/>

            </studio.carbonylgroup.textfieldboxes.TextFieldBoxes>

        </LinearLayout>

Ответы [ 2 ]

0 голосов
/ 14 ноября 2018

Создайте файл drawable.xml и установите его в качестве фона для текста, например:

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">

    <stroke
        android:width="4sp"
        android:color="@android:color/white" />

    <corners android:radius="20dp" />
    <solid android:color="@color/colorPrimary"/>

</shape> 


    <studio.carbonylgroup.textfieldboxes.ExtendedEditText
                android:id="@+id/et"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:background="@drawable/drawable"
   />

добавить xmlns:tools="http://schemas.android.com/tools" в свои поля TextFieldBoxes

0 голосов
/ 14 ноября 2018

Обратите внимание на строки:

    xmlns:app="http://schemas.android.com/tools"
    ...

    app:labelText="Username"  //app is a tool namespace, so label text only shown in preview

Изменить на:

    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    ...

    app:labelText="Username"
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...