2015-11-13 56 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