微调标签大小大小、标签

2023-09-07 09:35:31 作者:算什么英雄

我有微调在我的应用程序,我想使每行之间的空间较大。 我已经尝试过机器人:TEXTSIZE:30sp,没有运气 任何想法?

I have spinner on my app and I want to make the spaces between each line larger. I have already tried android:TextSize:"30sp" with no luck any ideas?

推荐答案

在创建适配器的微调给自定义布局,而不是predefined一个

While Creating Adapter for your Spinner give custom layout instead of predefined one

在创建 RES /布局XML命名为 spinner_row.xml (您所选择的任何名称)文件夹

Create xml named spinner_row.xml (Any name of your choice) in res/layout folder

<?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="32sp"
    android:layout_height="36dp" 
    android:gravity="left|center_vertical"/> 

在这里,您可以通过修改此setitng在微调元素的margin和padding改变颜色文字大小和宽度,高度和间距的TextView

使用像这样在创建适配器

Use it like this while creating Adapter

 ArrayAdapter<String> adapter=new ArrayAdapter<String>(context, R.layout.spinner_row,yourlist);

最后的任务是常规

The Last task is routine

spinner.setAdapter(adapter);

我希望这会帮助你。

I hope this will help you.

第二种方式,

创建一个样式像你所选择的这个枝条属性,如测试大小,填充等和你的风格应该有一个父父=@安卓风格/ Widget.TextView.SpinnerItem如在下面的样式

create a style like this withe attributes of your choice, like test size, padding etc And your style should have a parent parent="@android:style/Widget.TextView.SpinnerItem" as shown in the below style

<style name="spinnerStyleView"  parent="@android:style/Widget.TextView.SpinnerItem">
        <item name="android:background"> @drawable/notetvbg</item>
          <item name="android:textColor">@android:color/darker_gray</item>
    </style>

和使用样式attribue应用样式的微调

And apply style to your spinner by using style attribue

 style="@style/spinnerStyleView"