【发布时间】:2012-10-10 13:12:09
【问题描述】:
我像这样创建了一个 Android“Spinner”元素:
<Spinner
android:id="@+id/choice"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_span="2"
android:background="@drawable/cell_shape"
android:gravity="center"
android:padding="3dp"
android:text="Choice"
android:textColor="@android:color/holo_orange_dark" />
cell_shape.xml 如下所示:
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<solid android:color="#99CC3300"/>
<corners android:radius="10px"/>
<padding android:left="0dp" android:top="0dp" android:right="0dp" android:bottom="0dp" />
</shape>
我创建了一个“custom_spinner.xml”文件来显示带有圆角的“Spinner-Elements”:
<?xml version="1.0" encoding="utf-8"?>
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/custom_spinner"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="@drawable/cell_shape"
android:textColor="#988767" >
</TextView>
要显示“Spinner-Element”,我使用以下代码:
Spinner spinner = (Spinner) table.findViewById(R.id.choice);
ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(this,
R.array.planets_array, R.layout.custom_spinner);
adapter.setDropDownViewResource(R.layout.custom_spinner);
spinner.setAdapter(adapter);
现在的问题是微调器的元素项也有方角。似乎只有“TextView”有圆角,但微调器元素本身没有。
这里有什么问题?我是不是使用了错误的元素类型?
问候
【问题讨论】:
-
尝试使用
android:background="#0000"将<Spinner>的背景设置为透明 -
@SherifelKhatib 嗯。没用:(。
-
也许你也应该添加 android:popupBackground="#0000"
标签: android android-layout rounded-corners android-spinner