更新时间:2023-01-28 09:48:14
在这里,您可以在布局文件夹中创建一个自定义xml文件,您可以在其中添加以下内容:
Here you can make a custom xml file in layout folder where you can add this:
<?xml version="1.0" encoding="utf-8"?>
<TextView
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textColor="#333333"
android:padding="10dp"
android:textStyle="bold" />
然后在您的代码中像这样提及它:
And then in your code mention it like this:
val adapter = ArrayAdapter.createFromResource(this, R.array.array_name, R.layout.custom_spinner) // where array_name consists of the items to show in Spinner
adapter.setDropDownViewResource(R.layout.custom_spinner) // where custom-spinner is mycustom xml file.
然后设置适配器.