开发者

How to change tab image scale

开发者 https://www.devze.com 2023-01-23 15:06 出处:网络
I have a tab layout with drawable resources as tab images. In landscape mode everything fine. But in portrait mode images doesn\'t have some margin from tabs. How I can change images scale or how to

I have a tab layout with drawable resources as tab images. In landscape mode everything fine. But in portrait mode images doesn't have some margin from tabs. How I can change images scale or how to set some margin to image? I don't want use fixed size, don't think that it is right way.

Here is my layout

<TabWidget
                android:id="@android:id/tabs"
      开发者_如何学JAVA          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>

Here is tab creation

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


Solved my problem myself

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

精彩评论

暂无评论...
验证码 换一张
取 消