带有 android:drawable="@color/transparent" 属性的选择器

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/21670717/
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-20 04:54:34  来源:igfitidea点击:

selector with android:drawable="@color/transparent" attribute

androidxmlandroid-layoutdrawable

提问by Giant

<!--  Active tab -->
<item android:state_selected="true" android:state_focused="false"
    android:state_pressed="false" android:drawable="@drawable/tab_bg_selected" />
<!--  Inactive tab -->
<item android:state_selected="false" android:state_focused="false"
    android:state_pressed="false" android:drawable="@drawable/tab_bg_unselected" />
<!--  Pressed tab -->
<item android:state_pressed="true" android:drawable="@color/transparent" />
<!--  Selected tab (using d-pad) -->
<item android:state_focused="true" android:state_selected="true"
    android:state_pressed="false" android:drawable="@color/transparent" />

is there a way to get the error in this kind of selector i want to use this kind o selector but i get an error in android:drawable="@color/transparenti get this error when i run it

有没有办法在这种选择器中获取错误我想使用这种 o 选择器但是我在android:drawable="@color/transparent运行它时出现错误

enter image description here

在此处输入图片说明

i run out of ideas to do on make it work

我没有任何想法可以让它发挥作用

回答by Gopal Gopi

replace

代替

android:drawable="@color/transparent"

with

android:drawable="@android:color/transparent"

You should refer to the androidnamespace

你应该参考android命名空间

回答by pratiti-systematix

Try writing the line of code for transparency like this:

尝试编写这样的透明代码行:

 <item android:drawable="@android:color/transparent"/>

回答by Piyush

android:drawable="@color/transparent" 

is not used in android framework by default. And if you want to need it you have to make manually. So you need change this from

默认情况下不在android框架中使用。如果你想需要它,你必须手动制作。所以你需要改变这个

android:drawable="@color/transparent" 

to

android:drawable="@android:color/transparent"

回答by The Heist

Replace android:drawablewith android:colorand put color code of the color here. i.e.android:color="#00000000".

替换android:drawableandroid:color并在此处放置颜色的颜色代码。即android:color="#00000000"

回答by Andrew Coder

You may use this code:

您可以使用此代码:

android:background="any color u want"
android:alpha=".6" 

It'll give you a colour with tranparent background

它会给你一个透明背景的颜色