2017-09-17 55 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”