2013-08-26 21 views
0

我的應用程序在手機上工作正常,但是當我將它運行到TAB時,界面變得太小。但我希望UI的大小與設備的大小有關。我需要在清單.Whats添加任何東西錯了,我doing.Here是我的XML所有設備的常見用戶界面無論大小

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
android:layout_width="fill_parent" 
android:layout_height="fill_parent" 
android:orientation="vertical"> 

<TextView 
    android:id="@+id/textView1" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:text="Select The Game Level" /> 

<Button 
    android:id="@+id/button1" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:text="Level1" /> 

<Button 
    android:id="@+id/button2" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:text="level2" /> 

<Button 
    android:id="@+id/button3" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:text="level3" /> 
</LinearLayout> 
Handset UI appearence 

Handset UI appearence

Tablet UI appearence 

Tablet UI appearence

+0

沒有ü德興其他佈局該尺寸呢? – KOTIOS

+0

與選項卡用戶界面,你的意思是平板電腦的用戶界面?平板電腦的解決方案是什麼? – Raptor

+0

@ MT8N0目前我只有一個佈局..我剛開始工作。但在這個階段,只有我遇到了這個問題。 –

回答

1

讓我們嘗試和探索這裏的推定:

  1. 您的按鈕大小設置爲「wrap_content」。這意味着它取決於它所包裝文本的大小。

  2. 您希望您的按鈕根據顯示應用的屏幕的可視大小更改視覺大小。

  3. 因此:你基本上期望字體大小根據你的設備的屏幕而改變。

我不覺得這是實現你想要的正確方法。有幾個工具可以幫助你在這裏,讓我們來看看一:權重屬性:What does android:layout_weight mean?

這裏是按鈕的排列,這將看任何屏幕上視覺上相似的例子(強調的是「相似」在這裏但這是你想要什麼來實現):

<LinearLayout 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" > 

     <Button 
      android:id="@+id/btnMainMenuTestUSB" 
      android:layout_width="0dp" 
      android:layout_height="wrap_content" 
      android:layout_weight="1" 
      android:text="Button1" /> 

     <Button 
      android:id="@+id/btnMainMenuSetLocationNew" 
      android:layout_width="0dp" 
      android:layout_height="wrap_content" 
      android:layout_weight="1" 
      android:text="Button2" /> 
    </LinearLayout> 

    <LinearLayout 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" > 

     <Button 
      android:id="@+id/btnLineOfSight" 
      android:layout_width="0dp" 
      android:layout_height="wrap_content" 
      android:layout_weight="1" 
      android:text="Button3" /> 

       <Button 
      android:id="@+id/btnTargetScreen" 
      android:layout_width="0dp" 
      android:layout_height="wrap_content" 
      android:layout_weight="1" 
      android:text="Button4" /> 
    </LinearLayout> 
+0

THANKs。但是如果複雜的UI有文本,按鈕,微調器,嵌套佈局,那麼在這種情況下,重量參數可能無法在那裏工作 –

+0

再次 - 你想在這裏實現什麼? 如果你想要文字改變大小,你需要一個不同的風格xml每個密度/ screensize /等。嵌套旋鈕和某些佈局可以設置爲「match_parent」,因此它們只會顯示更多項目。複雜的佈局可能需要從頭開始佈置以明智地處理空間變化。恕我直言,這不是一個「適合所有人」的問題。 – Vaiden

+0

總之 - 我與zapl在這... – Vaiden

相關問題