2014-10-01 40 views
0

我有一個佈局是這樣的:Android的滾動視圖吃了添加布局

<RelativeLayout 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_gravity="center" 
    android:layout_marginBottom="10dp" 
    android:background="#ff303f" 
    android:id="@+id/layout"> 
    <ImageView 
     android:id="@+id/picture" 
     android:layout_width="300dp" 
     android:layout_height="300dp" 
     android:layout_centerInParent="true"/> 
    <Button 
     android:id="@+id/cancel" 
     android:layout_width="45dp" 
     android:layout_height="45dp" 
     android:layout_alignRight="@id/picture" 
     android:background="@drawable/cross_out"/> 
</RelativeLayout> 

我使用正常的佈局充氣服務,設置一些功能按鈕,給ImageView的圖像(所有圖像它充氣具有相同的尺寸和長寬比)。

在那之後,我加入這個觀點我片段的佈局,也不過是滾動型這是一個家長,它有一個我稱之爲「地圖」,並簡單地把它添加到地圖一個孩子的線性佈局。

預期:增加的佈局應該得到適當補充,我可以通過它滾動。實際:如果添加了2個以上,第一個會被吃掉。我可以看到它一半或有時它完全吃掉了。 :\

任何想法什麼回事?非常感謝您的時間。

編輯:這裏的佈局文件I添加膨脹佈局成:

<?xml version="1.0" encoding="utf-8"?> 
<ScrollView 
     xmlns:android="http://schemas.android.com/apk/res/android" 
     android:id="@+id/scrollView" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:background="#f6ff45"> 
     <LinearLayout 
      android:id="@+id/map" 
      android:layout_width="fill_parent" 
      android:layout_height="wrap_content" 
      android:background="#43ff44" 
      android:orientation="vertical" 
      android:layout_margin="10dp" 
      android:layout_gravity="center" 
      android:layout_marginTop="15dp"> 

</LinearLayout> 
</ScrollView> 

我還忘了提及,添加3個或更多這些佈局後,我意識到有一個在端不必要空的空間。 :\

+0

Java代碼中定義滾動視圖你能提供的代碼,您實際上添加的看法?如果向ScrollView添加許多相同的視圖,ListView可能更有效。 – dharms 2014-10-01 20:45:09

+0

需要了解如何在代碼中添加視圖。 – uDevel 2014-10-01 20:58:59

回答

0

嘗試從像

//Initialize the TextView for vertical scrolling 
    output = (TextView) findViewById(R.id.textView); 
    output.setMovementMethod(new ScrollingMovementMethod()); 
+0

其膨脹的佈局。我應該在佈局中找到每個單獨的視圖,併爲它們設置setMovementMethod? – 2014-10-01 20:53:07

+0

我覺得你誤解了我的問題,沒有任何的TextView在此。佈局我添加(這是ImageView的和按鈕的組合),啓動去滾動視圖以上,像滾動視圖有點兒吃起來。 – 2014-10-01 20:54:24

+0

哦sorry.but你可以嘗試設置的運動方法把它們yes.let我知道,如果它的工作原理 – gas 2014-10-01 21:03:53