我正在尝试使旋转器完全透明。在 Android 4.0 中,我可以在 xml 布局设计器中将 alpha 属性设置为 0。但是当我使用 Android 2.2 时,我无法使用该属性,Eclipse 将其标记为错误并告诉我无法使用它。
我试图让它透明地编写这个java代码:
final Spinner cmbCategorias = (Spinner) findViewById(R.id.cmbCategorias);
cmbCategorias.getBackground().setAlpha(0);
它可以工作,但微调器中的文本保持可见。
有人可以告诉我我能做什么吗? 谢谢
最佳答案
制作类似于 spinner_textview.xml 的 xml 布局
<?xml version="1.0" encoding="utf-8"?>
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/txtview"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ellipsize="marquee"
android:singleLine="true"
android:textColor="@android:color/transparent" />
并在 Java 代码中添加以下内容:
Spinner sp=(Spinner)findViewById(R.id.sp);
sp.setAdapter(new ArrayAdapter(this,R.layout.spinner_textview,
items));
关于Android 2.2 - 如何设置微调器的 alpha 属性?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10495084/