android解析需要帮助

时间:2011-06-11 04:07:54

标签: android screen-resolution

我正在开发一个Android应用程序。需要Default(WVGA800)的相同分辨率 HVGA QVGA和所有表示模拟器大小的模拟器现在无关紧要我已经xml file而且我需要底部标签栏的固定大小,这也是我做的事情?现在我面临的问题是..我要在底部放置tabbar的空间。所以,当我在默认(WVGA800)HVGA或QVGA中运行相同的应用程序时,它与标签栏上的webview重叠,所以看起来很糟糕我该怎么办?我正在使用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);

    }
我应该怎么做,上面的问题会解决吗?提前谢谢:Pragna

1 个答案:

答案 0 :(得分:0)

这里有几个问题:

  • 您无法在所有不同的屏幕中使用相同的布局。这一直在这里和android dev guide一遍又一遍地重复。如该链接所述,您必须为每个屏幕分辨率组设置布局文件夹,并为每个屏幕分辨率组创建所需大小的布局(至少res/layout-smallres/layout-normal和{{1 }})。此外,您可能需要为每个屏幕密度创建一组位图(如果有的话)(至少res/layout-largeres/drawable-hdpires/drawable-mdpi)。

  • 如果您想修复底部的标签,请按照此问题的答案进行操作:How to reduce the tab bar height and display in bottom

  • 如果您使用的是RelativeLayout而不是res/drawable-ldpi,那么您可以使用LinearLayout强制Android将所有内容呈现在上方 不重叠他们。

  • 如果内容大于屏幕,请考虑将您的布局包含在ScrollView内。

  • 与此问题无关,但与SO中的未来问题非常相关:请尽量避免发布不相关的代码。 Java部分对您的问题不感兴趣。