2017-02-15 41 views
0

嘿傢伙我有這種佈局,有從互聯網上加載的觸摸圖像視圖,當手機處於肖像模式時一切正常,但在風景中的中間部分圖像出現(我有向上滾動才能看到它從一開始)怎麼可能向上滾動編程如何查看圖像視圖的內容從頂部

這裏是我的佈局:

<?xml version="1.0" encoding="utf-8"?> 
<android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android" 
android:id="@+id/drawer_layout" 
android:layout_width="match_parent" 
android:layout_height="match_parent" 
android:fitsSystemWindows="true"> 

<RelativeLayout 
    android:id="@+id/rlContent" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:animateLayoutChanges="true" 
    android:background="@drawable/bg"> 

    <include 
     android:id="@+id/top" 
     layout="@layout/top_bar" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" /> 

    <include 
     android:id="@+id/title_top" 
     layout="@layout/title_top_bar" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:layout_below="@+id/top" 
     android:layout_margin="10dp" /> 



    <RelativeLayout 
     android:id="@+id/spinnerIndicatorlayout" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:layout_below="@+id/title_top" 
     android:layout_margin="6dp" 
     android:visibility="gone" 
     android:background="@color/spinner_background" 
     android:gravity="center_horizontal"> 


     <Spinner 
      android:id="@+id/spinnerIndicators" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:layout_alignParentStart="true" 
      android:layout_centerInParent="true" 
      android:layout_margin="2dp" 
      android:background="@android:color/transparent" 
      android:gravity="center_horizontal" /> 

     <ImageView 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_alignParentEnd="true" 
      android:layout_centerVertical="true" 
      android:layout_marginLeft="10dp" 
      android:layout_marginRight="10dp" 
      android:src="@drawable/arrow" /> 
    </RelativeLayout> 


    <RelativeLayout 
     android:id="@+id/spinnerCountrylayout" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:layout_below="@+id/spinnerIndicatorlayout" 
     android:layout_margin="6dp" 
     android:background="@color/spinner_background" 
     android:gravity="center_horizontal"> 


     <Spinner 
      android:id="@+id/spinnerCountries" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:layout_alignParentStart="true" 
      android:layout_centerInParent="true" 
      android:layout_margin="2dp" 
      android:background="@android:color/transparent" 
      android:gravity="center_horizontal" /> 

     <ImageView 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_alignParentEnd="true" 
      android:layout_centerVertical="true" 
      android:layout_marginLeft="10dp" 
      android:layout_marginRight="10dp" 
      android:src="@drawable/arrow" /> 
    </RelativeLayout> 


    <ids.undp.classes.TouchImageView 
     android:id="@+id/ivInfographics" 
     android:layout_width="match_parent" 
     android:visibility="invisible" 
     android:layout_height="match_parent" 
     android:layout_below="@+id/spinnerCountrylayout" 
     android:layout_margin="6dp" 

     android:layout_gravity="end" 
     android:adjustViewBounds="true" 
     android:padding="5dp" 
     android:scaleType="centerCrop" 
     android:src="@drawable/defaultbg" /> 

    <ProgressBar 
     android:id="@+id/progress" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:visibility="gone" 
     android:layout_centerInParent="true" /> 


</RelativeLayout> 


<android.support.design.widget.NavigationView 
    android:id="@+id/nav_view" 
    android:layout_width="wrap_content" 
    android:layout_height="match_parent" 
    android:layout_gravity="end" 
    android:background="@drawable/drawer_bg" 
    android:fitsSystemWindows="false"> 

    <LinearLayout 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:background="@drawable/drawer_bg" 
     android:orientation="vertical"> 
     <ListView 
      android:id="@+id/lst_menu_items" 
      android:layout_width="match_parent" 
      android:layout_height="match_parent" 
      android:background="@android:color/transparent" 
      android:divider="@android:color/transparent" /> 
    </LinearLayout> 
</android.support.design.widget.NavigationView> 

+0

這是一個觸摸圖像視圖,它可以滾動,我不需要滾動視圖 –

回答

0

嘗試使用setScrollPosition:

public void setScrollPosition(float focusX, float focusY) { 
     setZoom(normalizedScale, focusX, focusY); 
    } 
+0

當我作爲風景輸入它工作正常,但是當我輸入作爲protrait,然後更改爲風景它不滾動所有我甚至試圖通過負值作爲參數,它沒有奏效 –