Edittext轮廓并不总是可见的

时间:2015-11-18 08:45:08

标签: android android-edittext line visibility outline

以下是样本

当我进入活动时,该行不会显示,但如果我多次输入它,它最终会显示。我不明白,我不知道我是否能做些什么让它发挥作用。 No line

With line

这是我的风格xml:

  <!-- Base application theme. -->
<style name="AppTheme" parent="AppTheme.Base">
    <!-- Customize your theme here. -->
</style>

<style name="AppTheme.Base" parent="Theme.AppCompat.Light.NoActionBar">

    <item name="colorPrimary">@color/primaryColor</item>
    <item name="colorPrimaryDark">@color/primaryColor</item>
    <item name="colorAccent">@color/colorAccent</item>
    <item name="android:windowBackground">@android:color/white</item>
    <item name="android:dialogTheme">@style/DialogCustom</item>
    <item name="android:textViewStyle">@style/RobotoTextViewStyle</item>
    <item name="buttonStyle">@style/RobotoButtonStyle</item>
    <item name="colorControlNormal">#9e9e9e</item>
    <item name="android:editTextStyle">@style/EditTextAppTheme</item>

</style>

<style name="ToolbarTitle" parent="@style/TextAppearance.Widget.AppCompat.Toolbar.Title">

</style>

<style name="MyCardViewStyle" parent="CardView">
    <!-- Card background color -->
    <item name="cardBackgroundColor">@color/orange</item>
    <!-- Ripple for API 21 of android, and regular selector on older -->
    <item name="android:foreground">?android:selectableItemBackground</item>
    <!-- Resting Elevation from Material guidelines -->
    <item name="cardCornerRadius">3dp</item>
</style>


<style name="SynevoDialogTheme" parent="Theme.AppCompat.Light.Dialog">
    <item name="android:layout_width">match_parent</item>
    <item name="android:layout_height">wrap_content</item>

    <item name="android:windowBackground">@null</item>
    <item name="android:windowNoTitle">true</item>
    <item name="android:windowIsFloating">false</item>

    <item name="android:backgroundDimEnabled">true</item>
    <item name="android:backgroundDimAmount">0.5</item>

    <item name="android:windowEnterAnimation">@null</item>
    <item name="android:windowExitAnimation">@null</item>
    <item name="android:windowAnimationStyle">@style/DialogAnimation</item>
</style>

<style name="LoadingDialogTheme" parent="Theme.AppCompat.Light.Dialog">
    <item name="android:windowBackground">@android:color/transparent</item>
    <item name="android:windowNoTitle">true</item>

</style>

<style name="AuthErrorDialog" parent="Theme.AppCompat.Light.Dialog">
    <item name="android:windowBackground">@android:color/transparent</item>
    <item name="android:windowNoTitle">true</item>
    <item name="android:layout_width">match_parent</item>
    <item name="android:layout_height">wrap_content</item>
</style>


<style name="DialogCustom" parent="Theme.AppCompat.Light.Dialog">
    <item name="colorAccent">@color/primaryColor</item>
    <item name="android:windowNoTitle">true</item>
    <item name="android:windowBackground">@drawable/material_dialog_shape</item>

</style>

<style name="AppFullScreenTheme" parent="Theme.AppCompat.Light.NoActionBar">
    <item name="android:windowNoTitle">true</item>
    <item name="android:windowActionBar">false</item>
    <item name="android:windowFullscreen">true</item>
</style>


<style name="DialogAnimation">
    <item name="android:windowEnterAnimation">@anim/slide_up_dialog</item>
    <item name="android:windowExitAnimation">@anim/slide_down_dialog</item>
</style>
<style name="AppTheme.AppBarOverlay" parent="ThemeOverlay.AppCompat.Dark.ActionBar" />
<style name="AppTheme.PopupOverlay" parent="ThemeOverlay.AppCompat.Light" />

<style name="RobotoTextViewStyle" parent="android:Widget.TextView">
    <item name="android:fontFamily">sans-serif</item>
</style>

<style name="RobotoButtonStyle" parent="android:Widget.Holo.Button">
    <item name="android:fontFamily">sans-serif</item>
    <item name="android:textStyle">bold</item>
</style>

这是活动布局xml:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:focusableInTouchMode="true"
tools:context="com.mindit.synevo.doc.controller.PatientSearchActivity">

<include
    android:id="@+id/patient_search_toolbar"
    layout="@layout/app_bar"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_alignParentTop="true" />

<ScrollView
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_below="@+id/patient_search_toolbar">

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginEnd="10dp"
        android:layout_marginStart="10dp"
        android:orientation="vertical">

        <LinearLayout
            android:id="@+id/patient_search_name_wrapper"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"

            android:layout_marginTop="5dp"
            android:orientation="horizontal"
            android:weightSum="2">

            <AutoCompleteTextView
                android:id="@+id/patient_search_name_tv"
                android:layout_width="0dp"
                android:layout_height="wrap_content"
                android:layout_weight="1"
                android:ems="10"
                android:hint="@string/last_name"
                android:singleLine="true" />

            <AutoCompleteTextView
                android:id="@+id/patient_search_firstName_tv"
                android:layout_width="0dp"
                android:layout_height="wrap_content"
                android:layout_weight="1"
                android:ems="10"
                android:hint="@string/first_name"
                android:singleLine="true" />


        </LinearLayout>

        <LinearLayout
            android:id="@+id/patient_search_birthDate_wrapper"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="horizontal">

            <TextView
                style="?android:textAppearanceMedium"
                android:layout_width="0dp"
                android:layout_height="match_parent"
                android:layout_weight="1"
                android:gravity="bottom"
                android:text="@string/birth_date" />

            <EditText
                android:id="@+id/patient_search_birthDate_et"
                style="?android:textAppearanceMedium"
                android:layout_width="0dp"
                android:layout_height="match_parent"
                android:layout_weight="0.7"
                android:focusable="false"
                android:hint="@string/date_hint"
                android:inputType="none"
                android:singleLine="true" />
        </LinearLayout>


        <LinearLayout
            android:id="@+id/patient_search_register_date_wrapper"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="horizontal">

            <TextView
                style="?android:textAppearanceMedium"
                android:layout_width="0dp"
                android:layout_height="match_parent"
                android:layout_weight="1"
                android:gravity="bottom"
                android:text="@string/register_date" />

            <EditText
                android:id="@+id/patient_search_register_date_et"
                style="?android:textAppearanceMedium"
                android:layout_width="0dp"
                android:layout_height="match_parent"
                android:layout_weight="0.7"
                android:focusable="false"
                android:hint="@string/date_hint"
                android:inputType="none"
                android:singleLine="true" />
        </LinearLayout>

        <LinearLayout
            android:id="@+id/patient_search_location_wrapper"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="horizontal">

            <TextView
                android:labelFor="@+id/patient_search_location_et"
                android:id="@+id/patient_search_location_tv"
                style="?android:textAppearanceMedium"
                android:layout_width="0dp"
                android:layout_height="match_parent"
                android:layout_weight="1"
                android:gravity="bottom"
                android:text="@string/pick_up_place" />

            <EditText
                android:id="@+id/patient_search_location_et"
                style="?android:textAppearanceMedium"
                android:layout_width="0dp"
                android:layout_height="match_parent"
                android:layout_weight="0.7"
                android:singleLine="true"
                tools:ignore="TextFields" />

        </LinearLayout>

        <LinearLayout
            android:id="@+id/patient_search_received_results_wrapper"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginTop="30dp"
            android:orientation="vertical">

            <TextView
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:text="@string/just_received_results"
                android:textSize="20sp" />

            <RadioGroup
                android:id="@+id/patient_search_rg"
                android:layout_width="match_parent"
                android:layout_height="wrap_content">

                <RadioButton
                    android:id="@+id/patient_search_days_rb"
                    android:layout_width="wrap_content"
                    android:layout_height="match_parent"
                    android:checked="false"
                    android:padding="5dp"
                    android:text="@string/in_last_two_days" />

                <RadioButton
                    android:id="@+id/patient_search_week_rb"
                    android:layout_width="wrap_content"
                    android:layout_height="match_parent"
                    android:padding="5dp"
                    android:text="@string/last_week" />

                <RadioButton
                    android:id="@+id/patient_search_month_rb"
                    android:layout_width="wrap_content"
                    android:layout_height="match_parent"
                    android:checked="false"
                    android:padding="5dp"
                    android:text="@string/last_month" />

                <RadioButton
                    android:id="@+id/patient_search_custom_rb"
                    android:layout_width="wrap_content"
                    android:layout_height="match_parent"
                    android:checked="false"
                    android:padding="5dp"
                    android:text="@string/custom" />
            </RadioGroup>

        </LinearLayout>

        <com.mindit.synevo.doc.view.ExpandableLayout
            android:id="@+id/patient_search_custom_expand"
            android:layout_width="match_parent"
            android:layout_height="wrap_content">

            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:orientation="vertical"
                app:canExpand="true">

                <LinearLayout
                    android:id="@+id/patient_search_start_date_wrapper"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:orientation="horizontal">

                    <TextView
                        style="?android:textAppearanceMedium"
                        android:layout_width="0dp"
                        android:layout_height="match_parent"
                        android:layout_weight="1"
                        android:gravity="bottom"
                        android:text="@string/patient_search_date_start" />

                    <EditText

                        android:id="@+id/patient_search_date_start_et"
                        style="?android:textAppearanceMedium"
                        android:layout_width="0dp"
                        android:layout_height="match_parent"
                        android:layout_weight="0.7"
                        android:focusable="false"
                        android:hint="@string/date_hint"
                        android:inputType="none"
                        android:singleLine="true" />
                </LinearLayout>

                <LinearLayout
                    android:id="@+id/patient_search_date_end_wrapper"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:orientation="horizontal">

                    <TextView

                        style="?android:textAppearanceMedium"
                        android:layout_width="0dp"
                        android:layout_height="match_parent"
                        android:layout_weight="1"
                        android:gravity="bottom"
                        android:text="@string/patient_search_date_end" />

                    <EditText
                        android:id="@+id/patient_search_date_end_et"
                        style="?android:textAppearanceMedium"
                        android:layout_width="0dp"
                        android:layout_height="match_parent"
                        android:layout_weight="0.7"
                        android:focusable="false"
                        android:hint="@string/date_hint"
                        android:inputType="none"
                        android:singleLine="true" />
                </LinearLayout>
            </LinearLayout>


        </com.mindit.synevo.doc.view.ExpandableLayout>


        <CheckBox
            android:id="@+id/patient_search_date_cb"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginTop="30dp"
            android:checked="false"
            android:padding="5dp"
            android:text="@string/sort_by_date" />


        <CheckBox
            android:id="@+id/patient_search_result_cb"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:padding="5dp"
            android:text="@string/sort_by_abnormal_result" />


        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_marginTop="10dp"
            android:gravity="end">

            <Button
                android:id="@+id/patient_search_reset_form_btn"
                style="?android:borderlessButtonStyle"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="@string/reset_form"
                android:textColor="@android:color/darker_gray" />

            <Button
                android:id="@+id/patient_search_btn"
                style="?android:borderlessButtonStyle"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="@string/search"
                android:textColor="@color/primaryColor" />
        </LinearLayout>
    </LinearLayout>
</ScrollView>

1 个答案:

答案 0 :(得分:1)

我发现这导致了我的问题。 问题是,有时边框是白色的,我有一个白色的背景,仍然不知道为什么它有时会出现白色。 在我的第一个活动中,我通过彩色滤镜将轮廓颜色设置为白色,并以某种方式泄漏到所有应用程序。

 <item name="android:windowBackground">@android:color/white</item>