2013-05-02 89 views
3

是否有可能在Android上創建liquid/elastic屏幕布局,並調整大小以適應所有屏幕尺寸?爲Android創建單個彈性/液體佈局屏幕

目前我正在爲小,中,大,xlarge等不同的佈局玩耍,但我真正需要的只是一個適合縮放的單一佈局。

例如,基於百分比的佈局。

我創建的應用程序並不特別需要利用更大的屏幕來利用空間。

主屏幕只有2個圖像,一堆按鈕和一個廣告在底部,我只希望廣告保持在底部,而其他一切因素都會根據屏幕大小而相應地增加。

看起來非常複雜,必須爲一個非常簡單的界面生成4個不同的佈局。

建議非常感謝!

+0

http://developer.android.com/guide/practices/screens_support.html。我不認爲它可能 – Raghunandan 2013-05-02 06:16:15

+0

請添加布局截圖,以便我可以幫助您的佈局。 – 2013-05-02 06:20:23

+0

這是我們想要使用的佈局模型http://www.pixelkicks.co.uk/_download/Sample-Android-Layout.jpg – pixelkicks 2013-05-02 09:34:57

回答

1

您可以使用RelativeLayout

佈局與重量一樣

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

    <LinearLayout 
     android:layout_width="match_parent" 
     android:layout_height="0dp" 
     android:layout_weight="1" > 

     <ImageView 
      android:id="@+id/imageView1" 
      android:layout_width="0dp" 
      android:layout_height="match_parent" 
      android:layout_weight="2" 
      android:scaleType="fitXY" 
      android:src="@drawable/ic_launcher" /> 

     <ImageView 
      android:id="@+id/imageView2" 
      android:layout_width="0dp" 
      android:layout_height="match_parent" 
      android:layout_weight="2" 
      android:scaleType="fitXY" 
      android:src="@drawable/ic_launcher" /> 

     <LinearLayout 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:orientation="vertical" > 

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

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

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

    <TextView 
     android:id="@+id/textView1" 
     android:layout_width="match_parent" 
     android:layout_height="70dp" 
     android:gravity="center" 
     android:text="ADV" /> 

</LinearLayout>