アプリにスピナーがあり、各行の間のスペースを大きくしたいと思います。私はすでにandroid:TextSize:"30sp"
運が悪かったアイデアを試しましたか?
2 に答える
スピナー用のアダプターを作成する際に、事前定義されたものではなくカスタムレイアウトを提供します
フォルダー内spinner_row.xml
に (任意の名前) という名前のxml を作成します。res/layout
<?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"/>
ここで、これを変更してスピナーの要素のマージンとパディングを設定することにより、色のテキストのサイズと幅、高さ、および間隔を変更できますtextview
アダプターの作成時にこのように使用します
ArrayAdapter<String> adapter=new ArrayAdapter<String>(context, R.layout.spinner_row,yourlist);
最後のタスクはルーチンです
spinner.setAdapter(adapter);
これがお役に立てば幸いです。
第二の方法、
テストサイズ、パディングなど、選択した属性を使用して、このようなスタイルを作成します。スタイルparent="@android:style/Widget.TextView.SpinnerItem"
には、以下のスタイルに示すように親が必要です
<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>
そして、スタイル属性を使用してスピナーにスタイルを適用します
style="@style/spinnerStyleView"
スピナーに項目を提供するために ArrayAdapter を使用している場合は、ドロップダウン ビューのリソース ファイルを指定したでしょうandroid.R.layout.simple_spinner_dropdown_item
か?
独自のドロップダウン リソースを作成し、高さを任意に設定してから、代わりにアダプターに渡すことができます。android.R.layout.simple_spinner_dropdown_item