当我减小spinner的layout_width和layout_height时,项目名称会被裁剪。我想要缩小spinner的大小,而不影响项目名称。该如何实现?
在为您的Spinner创建适配器时,请使用自定义布局而不是预定义的布局。
创建名为spinner_row.xml的XML文件。
<?xml version="1.0" encoding="utf-8"?>
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/cust_view"
android:layout_width="match_parent"
android:textColor="@color/black"
android:textSize="12dp"
android:layout_height="36dp"
android:gravity="left|center_vertical"/>
您可以通过修改此textview来更改微调器中元素的颜色、文本大小、宽度和高度。
在创建适配器时,可以像这样使用它:
ArrayAdapter<String> adapter=new ArrayAdapter<String>(context, R.layout.spinner_row,yourlist);
spinner.setAdapter(adapter);
我希望这能对你有所帮助。
fontSize
。如果有效,请告诉我,我会将其发布为答案。 - Nezam