2011-06-11 34 views
2

我正在開發一個android應用程序。需要相同的分辨率爲Default(WVGA800) HVGAQVGA和所有意味着模擬器的大小的模擬器應該無關緊要現在我有這xml file,我需要修復大小的底部標籤欄爲什麼這麼說呢我呢?現在我面臨的問題是..我必須把tabbar的空間放在底部。所以,當我在Default(WVGA800)HVGA或QVGA中運行這個相同的應用程序時,它與標籤欄上的webview重疊,所以它看起來不好,應該怎麼做?我使用的是Android 1.6android分辨率需要幫助

<?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

+0

在具有不同分辨率的屏幕上的分辨率相同嗎?如果它甚至可能,它會看起來非常糟糕(例如在2x上運行ipad上的iphone應用程序)。 – trutheality 2011-06-11 04:11:21

+0

查看我編輯的代碼 – Android 2011-06-11 04:28:55

回答

0

這裏有幾個問題:

  • 你不能得到相同的佈局,以在所有不同的屏幕工作。這一直在這裏重複,並在android dev guide。正如該鏈接中所述,您必須爲每個屏幕分辨率組設置佈局文件夾,併爲其中的每一個創建具有所需大小(至少爲res/layout-smallres/layout-normalres/layout-large)的佈局。此外,您可能需要爲每個屏幕密度(至少爲res/drawable-hdpi,res/drawable-mdpires/drawable-ldpi)創建一組位圖(如果有的話)。

  • 如果您想修復底部的選項卡,請按照以下問題的答案:How to reduce the tab bar height and display in bottom

  • 如果您使用的RelativeLayout代替LinearLayout,那麼你可以使用android:layout_above="@id/tabs"迫使Android的渲染上述標籤和一切不重疊他們。

  • 如果內容大於屏幕,請考慮將您的佈局包含在ScrollView之內。

  • 與此問題無關,但對於將來的問題非常相關:請儘量避免發佈不相關的代碼。 Java部分對你的問題沒有興趣。

+0

okk你的意思是說我必須爲每個解決方案創建main.xml文件? – Android 2011-06-11 06:49:06

+0

但是它怎麼能提供setcontentview?我的意思是我如何確定我要加載哪個main.xml文件? – Android 2011-06-11 06:49:49

+0

取決於設備的屏幕,它將在運行時自動確定。請**閱讀我發佈的鏈接**。我會在這裏重複它:http://developer.android.com/guide/practices/screens_support.html萬一你錯過了。 – Aleadam 2011-06-11 06:57:10