android:layout_below保持重叠视图

时间:2014-01-08 09:11:16

标签: android android-layout

我的布局只是一个小问题。这是:

<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);


    }

任何建议?

1 个答案:

答案 0 :(得分:0)

在第二个TextView中只需替换

android:layout_below="@id/strip_popular" 

android:layout_below="@id/scroll_popular"