如何更改标签图像比例

时间:2010-11-03 20:28:19

标签: android layout tabs margin scale

我有一个带有可绘制资源的标签布局作为标签图像。 在横向模式下一切都很好。但在纵向模式下,图像没有标签边缘。如何更改图像比例或如何设置图像边距?我不想使用固定大小,不要认为它是正确的方式。

这是我的布局

<TabWidget
                android:id="@android:id/tabs"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                />
        <FrameLayout
                android:id="@android:id/tabcontent"
                android:layout_width="fill_parent"
                android:layout_height="fill_parent"
                android:padding="5dp"
                >
            <ListView
                    android:id="@+id/list"
                    android:layout_width="fill_parent"
                    android:layout_height="fill_parent"
                    />
        </FrameLayout>


<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
    <item android:drawable="@drawable/logo" android:state_selected="true"  />
    <item android:drawable="@drawable/logo_disabled" />
</selector>

这是标签创建

    Drawable d = res.getDrawable(R.drawable.logos); 
    spec = tabHost.newTabSpec(1).setIndicator("", res.getDrawable(R.drawable.logos)).setContent(intent);
    tabHost.addTab(spec);

1 个答案:

答案 0 :(得分:3)

自己解决了我的问题

    //set icons padding
    for (int i = 0; i < tabHost.getTabWidget().getChildCount(); i++){
        tabHost.getTabWidget().getChildAt(i).setPadding(10,10,10,10);
    }
相关问题