2015-10-01 29 views
0

我試圖向所有屏幕顯示圖片,當它不在scrollView中時一切正常,但是當我將imageview設置爲滾動視圖時,它們顯示爲60-80%的屏幕。如何在scrollview中顯示imageview到所有屏幕

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:app="http://schemas.android.com/apk/res-auto" 

    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:background="@color/Background"> 



    <include layout="@layout/toolbar" 
     android:id="@+id/toolbar" /> 

    <ScrollView 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:id="@+id/scrollView7" 
     android:layout_below="@+id/toolbar" 
     android:fillViewport="true"> 

     <RelativeLayout 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:layout_below="@+id/scrollView7"> 

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

       <ImageView 
        android:layout_width="match_parent" 
        android:layout_height="match_parent" 
        android:id="@+id/asana_image" 
        android:scaleType="centerCrop" 
        android:background="@color/Transparent" 
        android:src="@drawable/noimage" 
        android:layout_centerInParent="true" 
        android:adjustViewBounds="false" /> 

       <ImageButton 
        android:layout_width="60dp" 
        android:layout_height="60dp" 
        android:id="@+id/videoplay_but" 
        android:background="@drawable/blue_corn_bg" 
        android:src="@drawable/video" 
        android:layout_alignParentTop="true" 
        android:layout_alignParentLeft="true" 
        android:layout_alignParentStart="true" 
        android:layout_marginLeft="29dp" 
        android:layout_marginStart="29dp" 
        android:layout_marginTop="27dp" 
        android:scaleType="centerInside" 
        android:padding="18dp" /> 

       <ImageButton 
        android:layout_width="60dp" 
        android:layout_height="60dp" 
        android:id="@+id/sound_but" 
        android:src="@drawable/sound_image" 
        android:background="@drawable/blue_corn_bg" 
        android:layout_alignTop="@+id/videoplay_but" 
        android:layout_toRightOf="@+id/videoplay_but" 
        android:layout_toEndOf="@+id/videoplay_but" 
        android:layout_marginLeft="29dp" 
        android:layout_marginStart="29dp" 
        android:scaleType="centerInside" 
        android:padding="18dp" /> 
      </RelativeLayout> 

      <RelativeLayout 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:layout_below="@+id/"> 

       <TextView 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:text="New Text" 
        android:id="@+id/textView55" 
        android:layout_alignParentTop="true" 
        android:layout_alignParentLeft="true" 
        android:layout_marginTop="17dp" /> 

       <TextView 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:text="New Text" 
        android:id="@+id/textView56" /> 

       <TextView 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:text="New Text" 
        android:id="@+id/textView57" 
        android:layout_below="@+id/textView55" 
        android:layout_alignParentLeft="true" 
        android:layout_alignParentStart="true" /> 

      </RelativeLayout> 

     </RelativeLayout> 
    </ScrollView> 

    <RelativeLayout 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:layout_below="@+id/toolbar" 
     android:id="@+id/VideoLay" 
     android:visibility="invisible"> 

     <VideoView 
      android:layout_width="fill_parent" 
      android:layout_height="fill_parent" 
      android:id="@+id/videoAsana" 
      android:visibility="visible" 
      android:layout_centerHorizontal="true" 
      android:layout_alignParentTop="true" /> 
    </RelativeLayout> 



</RelativeLayout> 

和片段:

if(imgFile.exists()){ 

      Bitmap myBitmap = BitmapFactory.decodeFile(imgFile.getAbsolutePath()); 

      asana_image.setImageBitmap(myBitmap); 


     } 

哪裏是我的錯? 謝謝!

截圖: When no image When image exist

回答

0

第一件事情是你的親戚佈局滾動視圖裏面,所以你不應該給的屬性android:layout_below="@+id/scrollView7"你的相對佈局。

下一個是你應該像所有好給match_parent您滾動型,而不是wrap_content

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:app="http://schemas.android.com/apk/res-auto" 

    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:background="@color/Background"> 



    <include layout="@layout/toolbar" 
     android:id="@+id/toolbar" /> 

    <ScrollView 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:id="@+id/scrollView7" 
     android:layout_below="@+id/toolbar" 
     android:fillViewport="true"> 

     <RelativeLayout 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:layout_below="@+id/scrollView7"> 

      <RelativeLayout 
       android:id="@+id/relative1" 
       android:layout_width="match_parent" 
       android:layout_height="match_parent"> 

       <ImageView 
        android:layout_width="match_parent" 
        android:layout_height="match_parent" 
        android:id="@+id/asana_image" 
        android:scaleType="centerCrop" 
        android:background="@color/Transparent" 
        android:src="@drawable/noimage" 
        android:layout_centerInParent="true" 
        android:adjustViewBounds="false" /> 

       <ImageButton 
        android:layout_width="60dp" 
        android:layout_height="60dp" 
        android:id="@+id/videoplay_but" 
        android:background="@drawable/blue_corn_bg" 
        android:src="@drawable/video" 
        android:layout_alignParentTop="true" 
        android:layout_alignParentLeft="true" 
        android:layout_alignParentStart="true" 
        android:layout_marginLeft="29dp" 
        android:layout_marginStart="29dp" 
        android:layout_marginTop="27dp" 
        android:scaleType="centerInside" 
        android:padding="18dp" /> 

       <ImageButton 
        android:layout_width="60dp" 
        android:layout_height="60dp" 
        android:id="@+id/sound_but" 
        android:src="@drawable/sound_image" 
        android:background="@drawable/blue_corn_bg" 
        android:layout_alignTop="@+id/videoplay_but" 
        android:layout_toRightOf="@+id/videoplay_but" 
        android:layout_toEndOf="@+id/videoplay_but" 
        android:layout_marginLeft="29dp" 
        android:layout_marginStart="29dp" 
        android:scaleType="centerInside" 
        android:padding="18dp" /> 
      </RelativeLayout> 

      <RelativeLayout 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:layout_below="@+id/relative1"> 

       <TextView 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:text="New Text" 
        android:id="@+id/textView55" 
        android:layout_alignParentTop="true" 
        android:layout_alignParentLeft="true" 
        android:layout_marginTop="17dp" /> 

       <TextView 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:text="New Text" 
        android:id="@+id/textView56" /> 

       <TextView 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:text="New Text" 
        android:id="@+id/textView57" 
        android:layout_below="@+id/textView55" 
        android:layout_alignParentLeft="true" 
        android:layout_alignParentStart="true" /> 

      </RelativeLayout> 

     </RelativeLayout> 
    </ScrollView> 

    <RelativeLayout 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:layout_below="@+id/toolbar" 
     android:id="@+id/VideoLay" 
     android:visibility="invisible"> 

     <VideoView 
      android:layout_width="fill_parent" 
      android:layout_height="fill_parent" 
      android:id="@+id/videoAsana" 
      android:visibility="visible" 
      android:layout_centerHorizontal="true" 
      android:layout_alignParentTop="true" /> 
    </RelativeLayout> 



</RelativeLayout> 
+0

,但現在滾動不工作( – Roman

+0

添加機器人:layout_above =「@ + ID/VideoLay」給你scrollview – Aakash

+0

用這個我只能看到VideoLay。 – Roman