我为每个选项卡设置了一个图像,结果与预期一致,但在某些设备(平板电脑或某些智能手机型号)上,图像较大且高于文本。如何解决?谢谢。
活动,
StateListDrawable selector = new StateListDrawable();
selector.addState(new int[] { android.R.attr.state_selected }, dSel);
icon.setImageDrawable(selector);布局,
<TabHost
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@android:id/tabhost"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<LinearLayout
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_below="@+id/mainLayout">
<FrameLayout
android:id="@android:id/tabcontent"
android:layout_width="fill_parent"
android:layout_height="0dip"
android:layout_weight="1"
android:scrollbars="none"
android:isScrollContainer="false">
</FrameLayout>
<TabWidget
android:id="@android:id/tabs"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="0"
/>
</LinearLayout>
</RelativeLayout>


发布于 2012-07-12 17:27:30
我相信这些链接会正确地指导你解决你的问题。
http://developer.android.com/guide/practices/screens_support.html
http://coding.smashingmagazine.com/2011/06/30/designing-for-android/
http://www.coronalabs.com/blog/2011/01/27/dynamic-image-resolution-made-easy/
另外,这个问题提出了一个类似的问题,我相信。
Determining image sizes for multiple android screen sizes/densities
https://stackoverflow.com/questions/11448559
复制相似问题