【问题标题】:i want the line under EditText to stay put我希望 EditText 下的行保持不变
【发布时间】:2013-06-08 16:04:45
【问题描述】:

在输入编辑文本时,蓝线会出现在其下方。我希望它留在那里 w 即使不打结。这是因为我的背景很暗,你看不到那里有一个输入字段。如果有人对如何查看 EditText 输入有其他想法,请告知。 谢谢

【问题讨论】:

    标签: android colors background android-edittext


    【解决方案1】:

    转到您的 styles.xml 并简单地输入以下内容

    <style name="EditTextTheme" parent="Theme.AppCompat.Light">
        <item name="colorControlNormal">@color/YourChoice </item>
    </style>
    

    然后在你的布局文件whatever.xml中,将它添加到你的根目录

    <LinearLayout
       ...
       android:theme="@style/EditTextTheme">
       .
       .
       <EditText... />
    </LinearLayout>
    

    底部应该根据您设置的颜色而改变

    【讨论】:

      【解决方案2】:

      您要查找的drawable 名为textfield_multiline_activated_holo_dark.9.png,可以在...\android-sdk\platforms\android-**\data\res\drawable-*dpi 中找到。将它们全部复制到您的项目中,然后将以下内容添加到您的 xml 布局文件中的 EditText

      android:background="@drawable/textfield_multiline_activated_holo_dark"
      

      并且,如果需要,可以像这样更改那里的文本颜色:

      android:textColor="@android:color/white"
      

      【讨论】:

      • 谢谢,易于实施。我们中的许多人不知道这些事情。
      【解决方案3】:

      您必须像这样创建一个选择 xml 文件:

      <?xml version="1.0" encoding="utf-8"?>
      <selector xmlns:android="http://schemas.android.com/apk/res/android">
      
      <item android:state_window_focused="false" android:state_enabled="true" android:drawable="@drawable/your_drawable>
      <item android:state_window_focused="false" android:state_enabled="false" android:drawable="@drawable/your_drawable>
      <item android:state_enabled="true" android:state_focused="true" android:drawable="@drawable/your_drawable>
      <item android:state_enabled="true" android:state_focused="true" android:drawable="@drawable/your_drawable>
      <item android:state_enabled="true" android:drawable="@drawable/your_drawable>
      <item android:state_focused="true" android:drawable="@drawable/your_drawable>
      <item android:drawable="@drawable/your_drawable">
      </selector>
      

      然后创建一个styles.xml 文件并插入:

      <style name="EditTextLight" parent="android:style/Widget.EditText">
          <item name="android:background">@drawable/edit_text_holo_light</item>
          <item name="android:textColor">white</item>
      </style>
      

      然后像这样设置你的编辑文本:

      <EditText
          style="@style/EditTextHololight" />
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2014-02-06
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多