我想展示上面带有静态小标签的微调器,这是怎么可能的 看到一个流行的应用程序想要显示相同的内容。
这是我的图片,红色标记的是上面有灰色文本的微调器,它不会改变
我不想显示在微调器中显示默认文本的 android:prompt
想要在同一控件中精确显示微调器上方
最佳答案
为此,您必须创建自定义微调器:
根据您的需要将微调器布局命名为custom_spinner
:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content">
<TextView
android:id="@+id/tVStaticSmallLabel"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="static text"
android:textColor="#777777"
android:textSize="22px" />
<TextView
android:id="@+id/tVMainText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/tVStaticSmallLabel"
android:layout_marginTop="5dip"
android:text="your changing text" />
</RelativeLayout>
在 Activity 中将此布局提供给微调器:
Spinner mySpinner = (Spinner) findViewById(R.id.yourSpinner);
mySpinner.setAdapter(new MyAdapter(this, R.layout.custom_spinner,
spinnerValues));
关于android - 如何显示带标签的微调器(静态文本)?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20853062/