2017-09-17 52 views
0

試圖做一個移動應用程序。但當程序在手機上運行時,圖片不會顯示在手機上。並且scrollview不滾動。您的幫助將受到高度讚賞。非常感謝您的寶貴時間。圖片不顯示,ScrollView不滾動在Android中

This is the output that I want. The picture part is the yellow box with text, the one with the id "header". Thank you.

<ScrollView xmlns:android="http://schemas.android.com/apk/res/android" 
xmlns:app="http://schemas.android.com/apk/res-auto" 
xmlns:tools="http://schemas.android.com/tools" 
android:id="@+id/activity_car_matcher" 
android:layout_width="fill_parent" 
android:layout_height="fill_parent" 
android:orientation="vertical" 
android:paddingBottom="0dp" 
android:paddingLeft="0dp" 
android:paddingRight="0dp" 
android:paddingTop="0dp" 
android:fillViewport="true" 
tools:context="ph.com.steamrise.goodrides.CarMatcherActivity" 
android:background="@drawable/carmatcher"> 


    <LinearLayout 
     android:layout_width="fill_parent" 
     android:layout_height="fill_parent" 
     android:orientation="vertical"> 

     <LinearLayout 
      android:layout_width="match_parent" 
      android:layout_height="140dp"> 

      <ImageView 
       android:layout_width="match_parent" 
       android:layout_height="140dp" 
       app:srcCompat="@drawable/header" 
       android:id="@+id/imageView" 
       /> 


     </LinearLayout> 
     <LinearLayout 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:background="#80ffffff" 
      android:orientation="vertical" 
      > 
      <TextView 
       android:text="1. What's your ideal vacation?" 
       android:layout_width="190dp" 
       android:layout_height="wrap_content" 
       android:textColor="#FF000000"/> 
      <RadioGroup 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content"> 

       <RadioButton 
        android:text="Climbing the rocky mountains" 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:id="@+id/radioButton11" 
        android:layout_weight="1" 
        android:textSize="12dp"/> 
       <RadioButton 
        android:text="Road trip at the city with family" 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:id="@+id/radioButton12" 
        android:textSize="12dp"/> 
       <RadioButton 
        android:text="Enjoying the view on top of the mountain with friends" 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:id="@+id/radioButton13" 
        android:textSize="12dp"/> 
       <RadioButton 
        android:text="Explore random places alone or with my partner" 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:id="@+id/radioButton14" 
        android:textSize="12dp"/> 
      </RadioGroup> 
     </LinearLayout> 

     <LinearLayout 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:orientation="vertical" 
      android:background="#80FFFFFF"> 
      <TextView 
       android:text="2. How would you describe your style?" 
       android:layout_width="250dp" 
       android:layout_height="wrap_content" 
       android:textColor="#FF000000"/> 
      <RadioGroup 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content"> 

       <RadioButton 
        android:text="Sporty" 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:id="@+id/radioButton15" 
        android:layout_weight="1" 
        android:textSize="12dp"/> 
       <RadioButton 
        android:text="Casual" 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:id="@+id/radioButton16" 
        android:textSize="12dp"/> 
       <RadioButton 
        android:text="Elegant" 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:id="@+id/radioButton17" 
        android:textSize="12dp"/> 
       <RadioButton 
        android:text="Free-spirited" 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:id="@+id/radioButton18" 
        android:textSize="12dp"/> 
      </RadioGroup> 
     </LinearLayout> 

     <LinearLayout 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:orientation="vertical" 
      android:background="#80FFFFFF"> 
      <TextView 
       android:text="2. How are you with money?" 
       android:layout_width="250dp" 
       android:layout_height="wrap_content" 
       android:textColor="#FF000000"/> 
      <RadioGroup 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content"> 

       <RadioButton 
        android:text="Really Careful- I prefer cheap stuff as long is it is usable" 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:id="@+id/radioButton19" 
        android:layout_weight="1" 
        android:textSize="12dp"/> 
       <RadioButton 
        android:text="I'm saving every penny and cutting corners where I can. Wait.. are you going to throw that empty can out? " 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:id="@+id/radioButton20" 
        android:textSize="12dp"/> 
       <RadioButton 
        android:text="I’m more of a 「spend now, regret later」 person. What’s the point of having money if you’re not going to spend it? " 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:id="@+id/radioButton21" 
        android:textSize="12dp"/> 
       <RadioButton 
        android:text="d) I’m a little risky with my money. I love playing stock market- and don’t worry, those pumpkin stocks will go up any time now" 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:id="@+id/radioButton22" 
        android:textSize="12dp"/> 
      </RadioGroup> 

     </LinearLayout> 



    </LinearLayout> 

回答

0

你的第一個的LinearLayout(必須是滾動型的獨生子女)必須高度WRAP_CONTENT,所以它可以比滾動

<LinearLayout 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:orientation="vertical"> 
更大

而你的頭ImageView使用android:src =「@ drawable/header」而不是app:srcCompat =「@ drawable/header」