Android appcompat-v7:26编辑文本始终为白色
我是android编程新手,但所有描述我的问题的问题似乎都没有帮助 我肯定是在看一些非常愚蠢的东西 我的活动:Android appcompat-v7:26编辑文本始终为白色,android,android-edittext,android-appcompat,Android,Android Edittext,Android Appcompat,我是android编程新手,但所有描述我的问题的问题似乎都没有帮助 我肯定是在看一些非常愚蠢的东西 我的活动: <android.support.design.widget.TextInputLayout android:layout_width="match_parent" android:layout_height="wrap_content"> <EditText android:id="@+id/use
<android.support.design.widget.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<EditText
android:id="@+id/username"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:fontFamily="@string/font_family_regular"
android:hint="@string/user_name"
android:maxLines="1"
android:nextFocusDown="@+id/password"
android:imeOptions="actionNext"
android:inputType="text"
android:text=""
android:textColor="#000000"/>
</android.support.design.widget.TextInputLayout>
按如下所示更改appcomcat版本并检查
compile'com.android.support:appcompat-v7:26.+'
您应该在部分中添加android:theme
,而不是EditText部分
<android.support.design.widget.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="@style/AppTheme">
我想你应该试试这个:- 活动\u main.xml
<android.support.design.widget.TextInputLayout
android:id="@+id/input_layout_name"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<EditText
android:id="@+id/ed_name"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Enter Your Name"
android:textColor="@android:color/black"/>
</android.support.design.widget.TextInputLayout>
并按如下方式更新youestyle.xml:-
<!-- Base application theme. -->
<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>
@颜色/原色
@颜色/原色暗
@颜色/颜色重音
我在@Dahnark发布的文章中找到了解决方案: 尝试在
EditText
style="@style/Widget.AppCompat.EditText"
签入真实设备
在myEditText
works中,这是我的EditText:
<EditText
android:id="@+id/editTextFacebookID"
style="@style/Widget.AppCompat.EditText"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_marginLeft="64dp"
android:layout_marginRight="8dp"
android:gravity="center_vertical"
android:hint="Facebook ID"
android:textColor="@color/md_text"
android:textColorHint="@color/md_disabled_hint_text" />
您可以在此处检查md_文本和md_禁用的提示_文本颜色:
这是我的应用程序的v19风格:
<style name="AppTheme" parent="Theme.AppCompat.NoActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">@color/md_red_500</item>
<item name="colorPrimaryDark">@color/md_red_700</item>
<item name="colorAccent">@color/md_blue_A200</item>
<item name="colorControlHighlight">@color/md_black_1000_25</item>
<item name="colorControlNormal">@color/md_black_1000_50</item>
<item name="colorSwitchThumbNormal">@color/md_grey_200</item>
<item name="android:colorForeground">@color/md_black_1000_75</item>
<item name="android:windowTranslucentNavigation">@bool/translucentNavigationBar</item>
<item name="android:windowTranslucentStatus">@bool/translucentStatusBar</item>
<!-- Navigation Drawer Arrow Style. -->
<item name="drawerArrowStyle">@style/DrawerArrowStyle</item>
<!-- Overflow Button Style. -->
<item name="actionOverflowButtonStyle">@style/OverflowStyle</item>
</style>
@颜色/md_红色_500
@颜色/md_红色_700
@颜色/md_蓝色_A200
@颜色/md\U黑色\U 1000\U 25
@颜色/md_黑色_1000_50
@颜色/md\U灰色\U 200
@颜色/md_黑色_1000_75
@布尔/半透明导航栏
@布尔/半透明状态栏
@样式/抽屉箭头样式
@样式/溢出样式
我的编辑文本在未聚焦时是灰色的,而蓝色聚焦时则需要
颜色来自颜色重音
当我更改AppTheme时,它会改变颜色。在style.xml中更改theme并检查我将其更改为theme.AppCompat,结果是相同的,您是否建议另一个?您可以发布您的应用程序gradle吗???@merjr请检查我的answer@OmarDanishaaddedI添加了主题,文本看起来仍然是white@merjr你应该使用
v7:26.0.1
version导致我的项目抛出无法解析的错误:com.android.support:appcompat-v7:26.0。1@merjr修正了编译!谢谢可悲的是,当我用键盘打字时,文本还是静止的。提示文本很好。我已将渐变文件添加到问题中。我已经在文件中有了编译。当我键入时,文本仍然显示为白色
style="@style/Widget.AppCompat.EditText"
<EditText
android:id="@+id/editTextFacebookID"
style="@style/Widget.AppCompat.EditText"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_marginLeft="64dp"
android:layout_marginRight="8dp"
android:gravity="center_vertical"
android:hint="Facebook ID"
android:textColor="@color/md_text"
android:textColorHint="@color/md_disabled_hint_text" />
<style name="AppTheme" parent="Theme.AppCompat.NoActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">@color/md_red_500</item>
<item name="colorPrimaryDark">@color/md_red_700</item>
<item name="colorAccent">@color/md_blue_A200</item>
<item name="colorControlHighlight">@color/md_black_1000_25</item>
<item name="colorControlNormal">@color/md_black_1000_50</item>
<item name="colorSwitchThumbNormal">@color/md_grey_200</item>
<item name="android:colorForeground">@color/md_black_1000_75</item>
<item name="android:windowTranslucentNavigation">@bool/translucentNavigationBar</item>
<item name="android:windowTranslucentStatus">@bool/translucentStatusBar</item>
<!-- Navigation Drawer Arrow Style. -->
<item name="drawerArrowStyle">@style/DrawerArrowStyle</item>
<!-- Overflow Button Style. -->
<item name="actionOverflowButtonStyle">@style/OverflowStyle</item>
</style>