Android 将文本样式从矩形边框更改为下划线

Android 将文本样式从矩形边框更改为下划线,android,android-layout,android-actionbar,android-theme,Android,Android Layout,Android Actionbar,Android Theme,在我的一个活动中,我的EditText视图以前是这样的 但现在它们看起来像这样 我需要帮助把它改回来:从矩形改成下划线 背景 因为我需要创建一个定制的ActionBar,所以我必须使用以下命令更改相关活动的主题,YesterdayActivity 风格: <style name="CustomWindowTitleBackground"> <item name="android:background">#323331</item>

在我的一个活动中,我的EditText视图以前是这样的

但现在它们看起来像这样

我需要帮助把它改回来:从矩形改成下划线

背景

因为我需要创建一个定制的ActionBar,所以我必须使用以下命令更改相关活动的主题,
YesterdayActivity

风格:

<style name="CustomWindowTitleBackground">
        <item name="android:background">#323331</item>
    </style>

    <style name="CustomTheme" parent="android:Theme">
        <item name="android:windowTitleSize">40dip</item>
        <item name="android:windowTitleBackgroundStyle">@style/CustomWindowTitleBackground</item>
    </style>

像这样更改您的自定义主题

<style name="CustomTheme" parent="android:Theme.Holo.NoActionBar">

因为您没有使用旧的android主题not
HoLo
,它有一种
editTextView

在较新版本的安卓系统中,只要选择全息主题,框架就会使用
窗口.FEATURE\u ACTION\u BAR
功能。每当应用程序调用
setFeatureInt(Window.FEATURE\u CUSTOM\u TITLE)
FEATURE\u ACTION\u BAR
时,框架就会抛出异常。
它崩溃是因为Holo默认使用ActionBar。解决办法很简单。使用Holo时关闭操作栏从样式中删除此行

<item name="android:background">#323331</item>
#323331

因为它是反映行为的背景属性。

有两种方法可以实现这一点。第一种方法是更改应用程序的主题

第一种方法:

AndroidManifest.xml

参见android:theme


如果更改editText的主题,则可以实现此功能。

<EditText
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:inputType="textPersonName"
        android:text="Name"
        android:theme="@android:style/Theme.Holo"
        android:ems="10"
        android:id="@+id/editText"
        android:layout_below="@+id/textView"
        android:layout_centerHorizontal="true" />

@style/CustomWindowTitleBackground
将其更改回默认样式。或者从代码中删除这一行


导致共享的第一个图像是默认的EditText背景

是否要使edittext下划线?我只想返回默认设置,就像保留自定义操作栏一样。如果使用EditText构建一个简单的android应用程序,第一个图像是默认外观,这是我想要的。我有完全相同的问题。有关问题的更多背景信息,请查看此问题:当我更改父级时,它抱怨将自定义功能与其他功能相结合。所以应用程序崩溃了。谢谢你的帮助。但我不明白你的编辑。最终的代码是什么样子的?
<item name="android:background">#323331</item>
<application
    android:allowBackup="true"
    android:icon="@mipmap/ic_launcher"
    android:label="@string/app_name"
    android:supportsRtl="true"
    android:theme="@style/AppTheme">
    ...
    ...
    </application>
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
    <!-- Customize your theme here. -->
    <item name="colorPrimary">@color/colorPrimary</item>
    <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
    <item name="colorAccent">@color/colorAccent</item>
</style>
<EditText
      android:layout_width="match_parent"
      android:layout_height="48dp"
      android:hint="Email Address"
      android:inputType="textMultiLine"
      android:textSize="16dp" />
<EditText
      android:layout_width="match_parent"
      android:layout_height="48dp"
      android:background="@drawable/stroked_edittext_bg"
      android:hint="Email Address"
      android:inputType="textMultiLine"
      android:textSize="16dp" />
<EditText
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:inputType="textPersonName"
        android:text="Name"
        android:theme="@android:style/Theme.Holo"
        android:ems="10"
        android:id="@+id/editText"
        android:layout_below="@+id/textView"
        android:layout_centerHorizontal="true" />
<item name="android:windowTitleBackgroundStyle">@style/CustomWindowTitleBackground</item>