将android EditText样式从矩形边框更改为下划线

Cot*_*nyo 8 android android-layout android-theme android-actionbar

在我的一个活动中,我的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>
Run Code Online (Sandbox Code Playgroud)

表现:

  <activity
        android:name="com.example.YesterdayActivity"
        android:theme="@style/CustomTheme">
    </activity>
Run Code Online (Sandbox Code Playgroud)

的onCreate:

@Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        requestWindowFeature(Window.FEATURE_CUSTOM_TITLE);
        setContentView(R.layout.activity_yesterday);
        getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE, R.layout.yesterday_title_bar);
…
}
Run Code Online (Sandbox Code Playgroud)

DjH*_*orn 0

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

<style name="CustomTheme" parent="android:Theme.Holo.NoActionBar">
Run Code Online (Sandbox Code Playgroud)

因为你没有使用旧的 Android 主题,没有HoLo那种editTextView

Window.FEATURE_ACTION_BAR在较新版本的 Android 中,只要选择 Holo 主题,框架就会使用该功能。setFeatureInt(Window.FEATURE_CUSTOM_TITLE)每当应用程序调用并且FEATURE_ACTION_BAR已经设置时,框架都会引发异常。它崩溃是因为 Holo 默认使用 ActionBar。修复方法很简单。使用 Holo 时关闭 ActionBar