android - 我怎样才能给我的 EditTexts 一个更亮的背景?

标签 android android-layout android-edittext android-xml android-button

我可以更改屏幕/表单本身的背景色和文本的颜色,但是 EditText 小部件的“内部”怎么办?它们太黑了,我不喜欢:

enter image description here

我希望它们是白色的,或者至少是浅灰色。

更新

应大众需求,这是 XML:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@color/black"
    android:orientation="vertical"
    android:paddingBottom="@dimen/activity_vertical_margin"
    android:paddingLeft="4dip"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:paddingTop="@dimen/activity_vertical_margin">

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="horizontal">

        <TextView
            android:layout_width="0dip"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:lines="1"
            android:padding="5dip"
            android:textColor="#FFFF00"
            android:text="@string/textview_Inv_"
            android:textAppearance="?android:attr/textAppearanceMedium" />

        <EditText
            android:id="@+id/edttxtInvoiceNum"
            android:layout_width="0dip"
            android:layout_height="wrap_content"
            android:layout_weight="2"
            android:background="@drawable/greyframe" />

        <TextView
            android:layout_width="0dip"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:textColor="#FFFF00"
            android:lines="1"
            android:padding="5dip"
            android:text="@string/textview_Vendor"
            android:textAppearance="?android:attr/textAppearanceMedium" />

        <EditText
            android:id="@+id/edttxtVendor"
            android:layout_width="0dip"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:background="@drawable/greyframe" />

    </LinearLayout>

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="horizontal">

        <TextView
            android:layout_width="0dip"
            android:layout_height="wrap_content"
            android:layout_weight="1.25"
            android:lines="1"
            android:textColor="#FFFF00"
            android:padding="5dip"
            android:text="@string/textview_Total_"
            android:textAppearance="?android:attr/textAppearanceMedium" />

        <EditText
            android:id="@+id/edttxtTotalDollars"
            android:layout_width="0dip"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:background="@drawable/greyframe" />

        <TextView
            android:layout_width="0dip"
            android:layout_height="wrap_content"
            android:layout_weight="1.5"
            android:lines="1"
            android:textColor="#FFFF00"
            android:padding="5dip"
            android:text="@string/textview_Cur_Tot"
            android:textAppearance="?android:attr/textAppearanceMedium" />

        <EditText
            android:id="@+id/edttxtCurrentTotal"
            android:layout_width="0dip"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:background="@drawable/greyframe" />

        <TextView
            android:layout_width="0dip"
            android:textColor="#FFFF00"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:lines="1"
            android:padding="5dip"
            android:text="@string/textview_Qty"
            android:textAppearance="?android:attr/textAppearanceMedium" />

        <EditText
            android:id="@+id/edttxtQty"
            android:layout_width="0dip"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:background="@drawable/greyframe" />

    </LinearLayout>

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="horizontal">

        <Button
            android:id="@+id/btnPrint"
            android:layout_width="0dip"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:textColor="@color/white"
            android:text="@string/button_Print" />

        <Button
            android:id="@+id/btnSave"
            android:layout_width="0dip"
            android:layout_height="wrap_content"
            android:textColor="@color/white"
            android:layout_weight="1"
            android:text="@string/button_Save" />

        <Button
            android:id="@+id/btnFind"
            android:layout_width="0dip"
            android:textColor="@color/white"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:text="@string/button_Find" />

        <Button
            android:id="@+id/btnClear"
            android:layout_width="0dip"
            android:textColor="@color/white"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:text="@string/button_Clear" />

    </LinearLayout>

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="horizontal">

        <EditText
            android:id="@+id/edttxtRed"
            android:layout_width="0dip"
            android:layout_height="wrap_content"
            android:layout_margin="4dip"
            android:layout_weight="1"
            android:background="@drawable/redframe" />

        <EditText
            android:id="@+id/edttxtOrange"
            android:layout_width="0dip"
            android:layout_height="wrap_content"
            android:layout_margin="4dip"
            android:layout_weight="1"
            android:background="@drawable/orangeframe" />

        <EditText
            android:id="@+id/edttxtYellow"
            android:layout_width="0dip"
            android:layout_height="wrap_content"
            android:layout_margin="4dip"
            android:layout_weight="1"
            android:background="@drawable/yellowframe" />
    </LinearLayout>

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="horizontal">

        <EditText
            android:id="@+id/edttxtGreen"
            android:layout_width="0dip"
            android:layout_height="wrap_content"
            android:layout_margin="4dip"
            android:layout_weight="1"
            android:background="@drawable/greenframe" />

        <EditText
            android:id="@+id/edttxtBlue"
            android:layout_width="0dip"
            android:layout_height="wrap_content"
            android:layout_margin="4dip"
            android:layout_weight="1"
            android:background="@drawable/blueframe" />

        <EditText
            android:id="@+id/edttxtIndigo"
            android:layout_width="0dip"
            android:layout_height="wrap_content"
            android:layout_margin="4dip"
            android:layout_weight="1"
            android:background="@drawable/indigoframe" />

        <EditText
            android:id="@+id/edttxtViolet"
            android:layout_width="0dip"
            android:layout_height="wrap_content"
            android:layout_margin="4dip"
            android:layout_weight="1"
            android:background="@drawable/violetframe" />
    </LinearLayout>

更新 2

我使用了 Eldar 的 XML,它现在符合我的半严格标准:

enter image description here

最佳答案

我认为您需要使用shapes。 在可绘制对象中创建 xml 文件:

<shape 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    android:shape="rectangle">

    <corners android:radius="5dp" />
    <solid android:color="@android:color/white" />
    <stroke
        android:width="1dip"
        android:color="@color/bggrey" />
</shape>

并将其设置为任何 View 的背景

<EditText
        android:layout_width="0dp"
        android:layout_weight=".50"
        android:layout_height="wrap_content"
        android:background="@drawable/your_file_name"
        android:id="@+id/editText3"/>

关于android - 我怎样才能给我的 EditTexts 一个更亮的背景?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24091161/

相关文章:

android - android playstore 是否支持非续订订阅?

android - TextView onClick()不起作用

android-layout - 了解constraintBottom 和constraintBaseline

android - 如何在默认键盘上放置一个按钮?我想要一个按钮,当按下它时,它有机会进行另一项 Activity

Android 编辑文本光标不出现

android - 带有 ListView 的 ScrollView 不滚动 - android

c# - 如何从代码动态填充ListPreference?

java - 应用程序崩溃: Android Studio: Switching Activities Using If Statements (INTENT)

java - Android EditText动态高度以编程方式

android - Dimen 值未按预期工作