安卓同屏分辨率

发布于 2024-11-14 17:33:31 字数 3459 浏览 5 评论 0原文

在 Android 中,我需要相同的分辨率 Default(WVGA800) HVGA QVGA 和所有模拟器,这意味着模拟器的大小现在应该不重要,我有这个 xml 文件,我需要修复大小底部标签栏我该怎么办?现在我面临的问题是..我必须在底部为标签栏留出空间。因此,当我在默认(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>

这是我的选项卡栏活动类,

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

我应该做什么,以上问题会解决吗?

In Android, I need same resolution for Default(WVGA800)
HVGA QVGA and all emulator that mean emulator's size should not matter right now I've this xml file and I'll need fix size for the bottom tab bar for that also what should I do? right now I am facing problem is.. I've to put space for tabbar at the bottom. so, when I'am run this same application in the Default(WVGA800) HVGA or QVGA it overlaps the webview on the tab bar so, it looks bad what should I do? I am using 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>

this is my tabbar activity class

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

what should I do so, above problem will be solve?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

别理我 2024-11-21 17:33:31

这里存在几个问题:

  • 您无法在所有不同的屏幕上使用相同的布局。此处以及 Android 开发指南 中已多次重复这一点。如该链接中所述,您必须为每个屏幕分辨率组设置布局文件夹,并为每个屏幕分辨率组创建具有所需尺寸的布局(至少为 res/layout-smallres/layout-normalres/layout-large)。此外,您可能需要为每个屏幕密度(res/drawable-hdpires/drawable-mdpi 和< code>res/drawable-ldpi 至少)。

  • 如果您想修复底部的选项卡,请按照以下问题的答案进行操作:如何降低标签栏高度并显示在底部.

  • 如果您使用RelativeLayout 而不是 LinearLayout,那么您可以使用 android:layout_above="@id/tabs" 强制 android 渲染选项卡上方的所有内容和不重叠它们。

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

  • 与这个问题不相关,但与SO中未来的问题非常相关:请尽量避免发布不相关的代码。 Java 部分对你的问题没有兴趣。

There are several issues here:

  • You can't get the same layout to work in all the different screens. This has been repeated over and over here, and in the android dev guide. As explained in that link, you'll have to set up layout folders for each screen resolution group and create layouts for each one of them with the required sizes (at least res/layout-small, res/layout-normal and res/layout-large). Also, you will probably need to create a set of bitmaps (if you have any) for each screen density (res/drawable-hdpi, res/drawable-mdpi and res/drawable-ldpi at least).

  • If you want to fix the tab at the bottom, follow the answers to this question: How to reduce the tab bar height and display in bottom.

  • If you use a RelativeLayout instead of a LinearLayout, then you can use android:layout_above="@id/tabs" to force android to render everything above the tabs and not overlapping them.

  • If the content is bigger than the screen, then consider including your layout inside a ScrollView.

  • Not relevant to this question, but very relevant for future questions in SO: please, try to avoid posting irrelevant code. The Java part has no interest in your question.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文