ViewLager'ı TabLayout ile yapmaya çalışıyorum ve TabLayout'ta metin yerine simgeler kullanıyorum. Öğreticiler, stackoverflow üzerindeki yanıtları denedim, ancak sorunumu çözmek için hiçbir şey yardımcı olmadı.Dize TabLayout'taki simgeyle nasıl değiştirilir?
Benim TabLayout
<android.support.design.widget.TabLayout
android:id="@+id/tab_layout"
style="@style/MyCustomTabLayout"
android:layout_width="match_parent"
android:layout_height="?android:attr/actionBarSize"
android:layout_alignParentBottom="true"
android:background="@color/colorPrimary"
app:tabGravity="fill"
app:tabMode="fixed"
local:theme="@style/ViewPagerTheme"
/>
MyCustomTabLayout Stil
<style name="MyCustomTabLayout" parent="Widget.Design.TabLayout">
<item name="tabTextAppearance">@style/MyCustomTextAppearance</item>
</style>
<style name="MyCustomTextAppearance" parent="TextAppearance.Design.Tab">
<item name="textAllCaps">false</item>
</style>
Benim PagerAdapter getPageTitle()
@Override
public CharSequence getPageTitle(int position) {
Drawable image = ContextCompat.getDrawable(App.getContext(), PageInfo.getByPosition(position).getIConResId());
image.setBounds(0, 0, image.getIntrinsicWidth(), image.getIntrinsicHeight());
SpannableString sb = new SpannableString(" ");
ImageSpan imageSpan = new ImageSpan(image, ImageSpan.ALIGN_BOTTOM);
sb.setSpan(imageSpan, 0, 1, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
return sb;
}
Sette
<item name="textAllCaps">false</item>
oluşan bir stil kullanıyorum ama bu
SpannableString sb = new SpannableString("a");
gibi bir şey için SpannableString sb = new SpannableString(" ");
değiştirdiğinizde benim TabLayout kapaklar A ile yansıtır ve eğer boş alana sahip benim TabLayout bırakmak değer ve boş değil, sanırım sorun bu adımda olmalı ama nasıl düzelteceğimi bilmiyorum.
deneyin çalışıyor? –