2013-11-26 13 views
0

試圖用Gallery組件做一個簡單的事情(系統默認提供)。我可以顯示圖像,但儘管我努力顯示沒有填充/邊距的圖庫,所以我可以在整個屏幕寬度上看到圖庫不起作用。在XML Gallery的開始處沒有空格

這是我的代碼:

  <TableRow 
       android:id="@+id/screenshotRow" 
       android:layout_width="fill_parent" 
       android:layout_height="wrap_content" 
       android:layout_gravity="left" 
       android:layout_marginBottom="10dp" 
       android:padding="0dp" > 

       <Gallery 
        android:id="@+id/screenshotGallery" 
        android:layout_width="fill_parent" 
        android:layout_height="200dp" 
        android:horizontalSpacing="5dp" 
        android:scaleType="fitXY" 
        android:spacing="3dip" 
        android:stretchMode="columnWidth" 
        android:verticalSpacing="5dp" /> 
      </TableRow> 

我不明白爲什麼這是行不通的。我也搜索了谷歌,並發現這個問題的發生,但不明白什麼是解決方案。很多人提出了一個水平滾動列表..

是否有可能擺脫android畫廊組件的開始處的空間? 謝謝。

+0

,希望我們可以在這裏接受的答案;)) – Ewoks

回答

1
  1. 圖庫是已棄用的組件。您應該使用ViewPager(它是支持庫的一部分)或類似的組件。
  2. 「fill_parent」爲android:layout_width爲不推薦參數。使用match_parent代替
  3. 我沒有得到這個「儘管我的奮鬥顯示不填充/保證金的畫廊」,然後在代碼中設置margin_bottom到10dp,horizo​​ntalSpacing到5DP,verticalSpacing到5DP,間距爲3DP ?!?有你的空間問題。 o.O

  4. 不確定爲什麼你想把圖庫放在一行!?!應該在表格內使用行,現在像這樣。相對佈局內的圖庫將全屏顯示。這是應該如何做的。在計算器我分享你Gallery inside RelativeLayout xml code here

    <Gallery 
        android:id="@+id/screenshotGallery" 
        android:layout_width="match_parent" 
        android:layout_height="match_parent" /> 
    

希望,因爲奇怪的格式錯誤,這有助於你;)乾杯

+0

THX。會嘗試。 ViewPager有min api 14 ..不太好。 – user1140656

+1

其實不是真,導致ViewPager(android.support.v4.view.ViewPager)是支持庫的一部分。我編輯了主要答案,以便您鏈接到該組件。你可以在ApiDemos中找到一個簡單的例子來看看如何使用它。 ;) – Ewoks

相關問題