Android - Изменения в «Style.xml» для размера шрифта Listview

1

Я определил стиль для "TabWidget", как показано ниже:

<style name="MyTheme" parent="@android:style/Theme.Light">
        <item name="android:tabWidgetStyle">@style/LightTabWidget</item>
</style>

<style name="LightTabWidget" parent="@android:style/Widget.TabWidget">
            <item name="android:textSize">12px</item>
</style>

В котором я устанавливаю шрифт размером 12 пикселей для шрифта TabWidget Indicator (title).

Теперь моя проблема: тот же способ модификации стиля Tabwidget, Я хочу изменить стиль для Listview для увеличения/уменьшения размера шрифта. Я знаю, что мы можем изменить размер шрифта listview, указав custom-layout для Listview. Но если есть способ сделать styles.xml, тогда PLS поможет мне и дайте мне знать.

Теги:
listview
font-size
android-listview

1 ответ

1
Лучший ответ

AFAIK, по умолчанию tab_indicator.xml имеет атрибут стиля. но для макета ListView по умолчанию simple_list_item_1.xml его нет. поэтому его невозможно. Но вы можете добиться этого с помощью пользовательского адаптера для ListView.

Edit: вы можете использовать только настраиваемый адаптер для настройки элемента списка. Он упоминается в ArrayAdapter Documentation.

Из документации:

A ListAdapter that manages a ListView backed by an array of arbitrary objects. By default this class expects that the provided resource id references a single TextView. If you want to use a more complex layout, use the constructors that also takes a field id. That field id should reference a TextView in the larger layout resource. However the TextView is referenced, it will be filled with the toString() of each object in the array. You can add lists or arrays of custom objects. Override the toString() method of your objects to determine what text will be displayed for the item in the list. To use something other than TextViews for the array display, for instance, ImageViews, or to have some of data besides toString() results fill the views, override getView(int, View, ViewGroup) to return the type of view you want.

  • 0
    simple_list_item_1.xml имеет textview, тогда можно ли упомянуть атрибут android: textSize для textview ??
  • 0
    @Paresh Mayani: AFAIK, мы можем переопределить стиль. Но не атрибут. я еще не работал над этим. если это возможно. Дам вам знать.
Показать ещё 1 комментарий

Ещё вопросы

Сообщество Overcoder
Наверх
Меню