2014-01-08 112 views
0

我只是對我的佈局有點問題。在這裏它是:android:layout_below保持重疊視圖

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
xmlns:tools="http://schemas.android.com/tools" 
android:layout_width="match_parent" 
android:layout_height="match_parent" 
android:background="@color/Beige" 
tools:context=".HomeActivity" > 

<TextView 
    android:id="@+id/strip_popular" 
    style="@style/StripsHome" 
    android:layout_width="match_parent" 
    android:text="@string/home_popular" > 
</TextView> 

<HorizontalScrollView 
    android:id="@+id/scroll_popular" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:layout_below="@id/strip_popular" > 

    <LinearLayout 
     android:id="@+id/popular_layout" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:orientation="horizontal" > 
    </LinearLayout> 
</HorizontalScrollView> 

<TextView 
    android:id="@+id/strip_latestreviews" 
    style="@style/StripsHome" 
    android:layout_width="match_parent" 
    android:layout_below="@id/strip_popular" 
    android:text="@string/home_latestreviews"> 
</TextView> 

<HorizontalScrollView 
    android:id="@+id/scroll_latestreviews" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:layout_below="@id/strip_latestreviews" > 

    <LinearLayout 
     android:id="@+id/latestreviews_layout" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:orientation="horizontal" > 
    </LinearLayout> 
</HorizontalScrollView> 

我的問題是,第二TextView的完全重疊,而不是出現在水平滾動視圖下方的第一個,。

在我的代碼中插入這樣的圖像:

LinearLayout popular = (LinearLayout) findViewById(R.id.popular_layout); 

Integer[] mThumbIds = { 
      R.drawable.first, R.drawable.second,  
      R.drawable.third, R.drawable.fourth}; 


    for(Integer i : mThumbIds){ 

     ImageView imageView = new ImageView(getApplicationContext()); 
     imageView.setLayoutParams(new LinearLayout.LayoutParams(220, 220)); 
     imageView.setScaleType(ImageView.ScaleType.CENTER_CROP); 
     imageView.setImageResource(i); 

     popular.addView(imageView); 


    } 

什麼建議嗎?

+0

你的android:layout_below = 「@ ID/strip_popular」 在滾動視圖和TextView的。 – Nfear

回答

0

在第二的TextView只需更換

android:layout_below="@id/strip_popular" 

android:layout_below="@id/scroll_popular" 
+0

它不會改變 – Tunarock

+0

@Tunarock其實你想第二個TextView出現在滾動視圖右下方。滾動查看ID是「scroll_popular」。所以,你必須爲第二個TextView放置scroll_popular的layout_below。 – user543

+0

我已經這樣做了,但結果是一樣的,並且設置水平卷軸的高度也不會改變任何內容。我無法理解這件事發生在哪個視圖或什麼屬性上。 – Tunarock