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

标签 android android-layout android-actionbar android-theme

在我的一项 Activity 中,我的 EditText View 过去看起来像这样

enter image description here

但是现在他们是这个样子

enter image description here

我需要帮助将其改回:从矩形改成下划线。

背景

因为我需要创建一个自定义的 ActionBar,所以我不得不更改相关 Activity 的主题,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>

list :

  <activity
        android:name="com.example.YesterdayActivity"
        android:theme="@style/CustomTheme">
    </activity>

创建时:

@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);
…
}

最佳答案

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

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

因为你没有使用旧的 android 主题而不是 HoLo 有那种 editTextView

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

关于android - 将 android EditText 样式从矩形边框更改为下划线,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17607173/

相关文章:

android - 使用游标适配器和加载器时动态编辑 ListView 项

android - 折叠工具栏不会与 RecyclerView 一起折叠

android - Action Bar 和 Title 不在一条线上

android - 改变安卓的颜色

android - 如何为 View 设置移动监听器

Windows 上没有 Eclipse 的 Android 应用程序代码签名

Android:具有自定义 View 和圆角的 AlertDialog

WebView 下方按钮的 Android 布局问题

java - 如何从 fragment 中的工具栏在 ListView 中搜索

android - 从 WebView 导航到不同的父 Activity