开发者

Android same screen resolution

开发者 https://www.devze.com 2023-03-12 08:18 出处:网络
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

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"开发者_JAVA百科 />
        <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?


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号