Ostatnio próbowałem adoptować opartą na stylistyce podejście do mojej aplikacji na Androida. Jednak utknąłem z tym dylematem.Jak dziedziczyć atrybut stylu Androida?
W moim pliku układu pierwotnie miał to:
<LinearLayout
android:id="@+id/layout_event_buttons"
style="?android:attr/buttonBarStyle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:orientation="horizontal" >
<ImageButton
android:id="@+id/btn_create_event"
style="?android:attr/buttonBarButtonStyle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:contentDescription="@string/btn_save"
android:src="@drawable/content_save"
android:text="@string/btn_save" />
</LinearLayout>
W moim styles.xml Próbowałem robić to bez powodzenia:
<style name="Buttons" parent="?android:attr/buttonBarButtonStyle">
<item name="android:layout_width">match_parent</item>
<item name="android:layout_height">wrap_content</item>
</style>
Próbowałem już różne odmiany jak wyżej:
?android:buttonBarButtonStyle
?attr:buttonBarButtonStyle
@android:attr/buttonBarButtonStyle
@android:buttonBarButtonStyle
Próbowałem również:
<item name="style">?android:attr/buttonBarButtonStyle</item>
bezskutecznie.
Moja aplikacja nie będzie się kompilować, ponieważ nie może znaleźć zasobu buttonBarButtonStyle.
Tak to zastosowałem. Moje inne style działać dobrze, jeśli tylko dziedziczą wspólne tematy jak Holo itp
<ImageButton
style="@style/Buttons"
android:id="@+id/btn_create_event"
android:contentDescription="@string/btn_save"
android:src="@drawable/content_save"
android:text="@string/btn_save" />
Przy okazji mam to w moim manifeście Nie wydaje mi się, że używam go z nieobsługiwanego interfejsu API Poziom: –
Chad