本文介绍了tabhost /图标的TabBar不显示的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的标签栏图标不会显示出来

my tab bar icon wont show up

TabHost tabHost = getTabHost();

TabSpec barcodeInsertSpec = tabHost.newTabSpec("Barcode Insert");
barcodeInsertSpec.setIndicator("Barcode Insert", getResources().getDrawable(R.drawable.home2));
barcodeInsertSpec.setContent(new Intent(getBaseContext(), BarcodeInsertActivity.class));

tabHost.addTab(barcodeInsertSpec);

绘制/ home2.xml

drawable/home2.xml

<?xml version="1.0" encoding="utf-8"?>
    <selector xmlns:android="http://schemas.android.com/apk/res/android">
        <!-- When not selected, use that-->
        <item android:drawable="@drawable/home22" />
    </selector>

和把画面在不同尺寸(48×48,32×32,24×24)绘制,华电国际三个文件夹
,绘制-LDPI,...为png格式

and put picture in three folders in different sizes (48x48, 32x32, 24x24) drawable-hdpi, drawable-ldpi, ... as .png

像绘制,华电国际/ home22.png

like drawable-hdpi/home22.png

推荐答案

试试这个code

<selector xmlns:android="http://schemas.android.com/apk/res/android" >
     <item  android:state_focused="true"
            android:state_pressed="true"
            android:drawable="@drawable/button0_click"></item>
    <item   android:state_focused="true"
            android:state_pressed="false"
            android:drawable="@drawable/button0_click"></item>
    <item
            android:state_focused="false"
            android:state_pressed="true"
            android:drawable="@drawable/button0_click" />
     <item
            android:drawable="@drawable/button0"></item>

</selector>

这篇关于tabhost /图标的TabBar不显示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-04 01:27