Android相同屏幕分辨率

问题描述 投票:2回答:1

在Android中,Default(WVGA800)我需要相同的分辨率HVGAQVGA和所有表示模拟器大小的模拟器现在都应该无关紧要,现在我有了xml file,我需要固定底部标签栏的大小,这又该怎么办?现在我面临的问题是..我必须在底部放置标签栏的空间。因此,当我在Default(WVGA800)HVGA或QVGA中运行同一应用程序时,它与选项卡栏上的Web视图重叠,因此,看起来不好,我该怎么办?我正在使用Android 1.6

<?xml version="1.0" encoding="utf-8"?>
    <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="fill_parent"   android:id="@+id/rl"
        android:layout_height="371dip">
    <!--    <WebView android:id="@+id/webviewHelp" android:layout_width="fill_parent"-->
    <!--        android:layout_height="fill_parent" />-->
    <WebView android:id="@+id/webviewHelp" android:layout_width="fill_parent"
            android:layout_height="fill_parent" />
        <Button android:id="@+id/My_btn"
            android:layout_alignParentBottom="true"
            android:layout_alignParentLeft="true" android:gravity="center" android:textSize="8px" android:text="Download this mp3 file"
    android:textColor="@color/white" 
            android:layout_width="fill_parent" android:layout_height="33dip"
            android:visibility="invisible" />
        <Button android:id="@+id/My_btn1"
            android:layout_alignParentBottom="true"
            android:layout_alignParentLeft="true" android:text="this is button !"
            android:layout_width="0dip" android:layout_height="0dip"
            android:visibility="invisible" />
    </RelativeLayout>

这是我的Tabbar活动类

final TabHost tabHost = (TabHost) getTabHost();
        try {

            //GlobalVariable.Setdownload(0);
            tabHost.addTab(createTab(myclsname.class, "Welcome",
                    "Welcome", R.drawable.tab_icon_events));
            tabHost.addTab(createTab(anotheclsname.class, ".Mp3List", ".Mp3List",
                    R.drawable.tab_icon_pitchforkfm));
            tabHost.addTab(createTab(AboutUs.class, "AboutUs", "AboutUs",
                    R.drawable.tab_icon_home));
            tabHost.addTab(createTab(ExtraInfromation.class, "ExtraInformation", "ExtraInformation",
                    R.drawable.tab_icon_tv));

            tabHost.setCurrentTab(1);
        } catch (Exception e) {
            // TODO: handle exception
        }
        tabHost.getTabWidget().getChildAt(0).getLayoutParams().width = 85;
        tabHost.getTabWidget().getChildAt(0).getLayoutParams().height=57;
        tabHost.getTabWidget().getChildAt(1).getLayoutParams().width = 85;
        tabHost.getTabWidget().getChildAt(2).getLayoutParams().width = 85;
        tabHost.getTabWidget().getChildAt(3).getLayoutParams().width = 85;
tabHost.setOnTabChangedListener(new OnTabChangeListener() {

    bla.. bla.. bla..

    private TabSpec createTab(final Class<?> intentClass, final String tag,
            final String title, final int drawable) 
    {
        final Intent intent = new Intent().setClass(this, intentClass);

        final View tab = LayoutInflater.from(getTabHost().getContext())
                .inflate(R.layout.tab, null);
        ((TextView) tab.findViewById(R.id.tab_text)).setText(title);
        ((ImageView) tab.findViewById(R.id.tab_icon))
                .setImageResource(drawable);

        return getTabHost().newTabSpec(tag).setIndicator(tab)
                .setContent(intent);
    }

我应该怎么做,上述问题将得到解决?

android screen-resolution
1个回答
0
投票

这里有几个问题:

  • 您无法获得相同的布局以在所有不同的屏幕上工作。在这里和android dev guide中已经重复了一遍。如该链接所述,您将必须为每个屏幕分辨率组设置布局文件夹,并为每个屏幕分辨率组创建具有所需大小(至少res/layout-smallres/layout-normalres/layout-large)的布局。另外,您可能需要为每个屏幕密度(至少res/drawable-hdpires/drawable-mdpires/drawable-ldpi)创建一组位图(如果有的话)。

  • 如果要在底部修复标签,请遵循以下问题的答案:How to reduce the tab bar height and display in bottom

  • 如果您使用RelativeLayout而不是RelativeLayout,则可以使用LinearLayout强制android渲染所有内容[[上方选项卡,并且不重叠

    ] >
  • 如果内容大于屏幕,请考虑将布局包括在android:layout_above="@id/tabs"中。
  • 与该问题无关,但与SO中的后续问题非常相关:请,避免发布无关的代码。 Java部分对您的问题不感兴趣。
© www.soinside.com 2019 - 2024. All rights reserved.