2015-11-13 52 views
0

所以我想有一个像在图像上的布局: Desired layout 一个图像在左边,那么标题,然后在那些文本的下方。 我似乎无法做到这一点,而滚动视图!如何在滚动视图中获取此布局?

所以这是我的代码,而没有使用滚动视图:

<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
android:layout_width="match_parent" 
android:layout_height="match_parent"> 

<ImageView 
    android:id="@+id/imageViewH" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_alignParentTop="true" 
    android:layout_centerHorizontal="true" 
    android:src="@drawable/header" /> 

      <TextView 
       android:id="@+id/textViewIntroText" 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content" 
       android:layout_alignParentLeft="true" 
       android:layout_below="@+id/imageView1" 
       android:text="@string/intro" /> 

      <ImageView 
       android:id="@+id/imageViewLOGO" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:layout_alignParentLeft="true" 
       android:layout_centerVertical="true" 
       android:src="@drawable/klein" /> 

      <ImageView 
       android:id="@+id/imageViewBlock" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:layout_centerVertical="true" 
       android:layout_marginLeft="19dp" 
       android:layout_toRightOf="@+id/imageView3" 
       android:src="@drawable/block" /> 

      <TextView 
       android:id="@+id/textViewBMWText" 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content" 
       android:layout_alignParentLeft="true" 
       android:layout_below="@+id/imageView3" 
       android:text="@string/bmwtext" /> 

      <TextView 
       android:id="@+id/textViewBMWTitle" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:layout_below="@+id/textViewIntroText" 
       android:layout_toRightOf="@+id/imageView2" 
       android:text="@string/bmw" /> 

我如何达到同样的效果,但有一个滚动视图?

无论如何,感谢您的时间!我感谢每一个回答/评论!

+0

创建[MCVE](http://stackoverflow.com/help/mcve)总是一个好主意。这个问题有一堆多余的代码,甚至没有尝试复制这个问题。这就像是一个拥有一辆完美的汽车的机械师,向他展示给他,然后问他他家破车的问题。 – tachyonflux

回答

1

我没有我尽量靠近我,但你可以用这个请尝试:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
android:layout_width="match_parent" 
android:layout_height="match_parent"> 

<ScrollView 
android:layout_height="match_parent" 
android:layout_width="match_parent"> 

<RelativeLayout 
android:layout_height="match_parent" 
android:layout_height="match_parent"> 

//all your xml here 

</RelativeLayout> 
</ScrollView> 
+0

谢谢!有用! – DyRight

+0

greaaaaaaat! :D – Coeus

0

设置RelativeLayoutwrap_content。如果子视图的大小与ScrollView相同,显然它不会滚动。

<ScrollView xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent"> 
    <RelativeLayout 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content"> 

    </RelativeLayout> 
</ScrollView> 
+0

虽然我不想让整个页面成为一个滚动视图,但这是我以后肯定会用到的东西!谢谢! – DyRight