【问题标题】:How to change tab image scale如何更改标签图像比例
【发布时间】:2011-05-04 17:33:10
【问题描述】:

我有一个选项卡布局,其中包含可绘制资源作为选项卡图像。 在横向模式下一切正常。但在纵向模式下,图像没有标签页边距。如何更改图像比例或如何为图像设置一些边距?我不想使用固定大小,不要认为这是正确的方式。

这是我的布局

<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);

【问题讨论】:

    标签: android layout tabs margin scale


    【解决方案1】:

    自己解决了我的问题

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

    【讨论】:

      猜你喜欢
      • 2012-07-12
      • 2013-02-10
      • 1970-01-01
      • 2019-10-22
      • 2021-06-25
      • 2014-02-27
      • 1970-01-01
      • 2017-03-19
      相关资源
      最近更新 更多