0

SeekBar があり、スクロールするたびにその値を取得します。位置は、スピナー内のテキストの大きさが要因になるはずです。

したがって、レイアウトのように50spではなくスクロールするたびに、スピナーアイテムのテキストサイズを変更したい

私のcustom_list_row.xml

<TextView xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/textViewRow"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:gravity="top|left"
    android:minHeight="?android:attr/listPreferredItemHeightSmall"
    android:paddingLeft="?android:attr/listPreferredItemPaddingLeft"
    android:paddingRight="?android:attr/listPreferredItemPaddingRight"
    android:textAppearance="?android:attr/textAppearanceListItemSmall"
    android:textSize="50sp" />

私のアダプター

ArrayAdapter<Language> adapter = new ArrayAdapter<Language>(this, R.layout.custom_list_row,
                currentLanguages);
        spinnerLanguage.setAdapter(adapter);

Language クラスは toString メソッドを持つオブジェクトです。

@Override
    public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
        resizeViews(progress);
    }

private void resizeViews(int progress){
    textViewFirstName.setTextSize(20+progress);
    //how can I do this for a spinner here?
}
4

1 に答える 1

1

これを使用できます。

private void resizeViews(int progress){
textViewFirstName.setTextSize(20+progress);
//this might be helpful
for(int i=0;i<spinnerLanguage.getChildCount();i++){
((TextView)spinnerLanguage.getChildAt(i)).setTextSize(20+progress);
}
}
于 2013-01-28T18:19:25.360 に答える