CSS 在 React Native 中删除 inputText 中的下划线

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/40478246/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-30 12:14:30  来源:igfitidea点击:

remove underline in inputText in React Native

cssreact-native

提问by Nima

I cannot remove underline in input text

我无法删除输入文本中的下划线

enter image description here

在此处输入图片说明

回答by vinayr

I guess it should be

我想应该是

underlineColorAndroid="transparent"

See the related issue https://github.com/facebook/react-native/issues/10108

查看相关问题https://github.com/facebook/react-native/issues/10108

回答by vijay22uk

Use underlineColorAndroid property of TextInput component

使用 TextInput 组件的 underlineColorAndroid 属性

<TextInput underlineColorAndroid='transparent'
           placeholder="type here ..">
 TXT
</TextInput>

回答by Urska

Following prop in TextField works for me

TextField 中的以下道具对我有用

underlineColorAndroid='rgba(0,0,0,0)' 

回答by Nima

I found a simple solution

我找到了一个简单的解决方案

underlineColorAndroid='#FFF'

回答by Prafull Sharma

underlineColorAndroid="transparent"is perfectly working for me

underlineColorAndroid="transparent"非常适合我

<TextInput underlineColorAndroid="transparent" placeholder="Your Placeholder" />

<TextInput underlineColorAndroid="transparent" placeholder="Your Placeholder" />

See Discussion here

请参阅此处的讨论

回答by Rajesh Nasit

I agree with above answers but it produces following problem randomly

我同意上述答案,但它会随机产生以下问题

https://github.com/facebook/react-native/issues/18214

https://github.com/facebook/react-native/issues/18214

NullPointerException:tempt to invoke virtual method 'android.graphics.drawable.Drawable android.graphics.drawable.Drawable$ConstantState.newDrawable(android.content.res.Resources)

NullPointerException:试图调用虚拟方法 'android.graphics.drawable.Drawable android.graphics.drawable.Drawable$ConstantState.newDrawable(android.content.res.Resources)

So i get up with other solution. I added editbox style in style.xml

所以我起床了其他解决方案。我在 style.xml 中添加了编辑框样式

<item name="android:background">@android:color/transparent</item>

---------------------------Full code------------------------------------

---------------------------完整代码--------------------- ---------------

<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
        <!-- Customize your theme here. -->
        <item name="android:windowBackground">@color/backgroundcolor</item>
        <item name="android:editTextStyle">@style/AppEditTextStyle</item>
    </style>
    <style name="AppEditTextStyle" parent="@style/Widget.AppCompat.EditText">
        <item name="android:background">@android:color/transparent</item>
        <item name="android:minHeight">40dp</item>
    </style>

回答by Mathieu Morand

I found another way to surcharge InputContainer styles directly on the TextInput :

我找到了另一种直接在 TextInput 上附加 InputContainer 样式的方法:

inputContainerStyle={{borderBottomWidth:0}}

回答by slavitto

I found only one way to remove underline exactly from input container:

我发现只有一种方法可以从输入容器中完全删除下划线:

<TextField
    placeholder="[email protected]" 
    InputProps={{ disableUnderline: true }}
/>