2014-01-08 209 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