2013-12-23 58 views
0

在我的應用程序中,我想滾動TextView到ImageView,但是在我的XML Design中,ImageView背後的TextView滾動,如何滾動ImageView上的TextView,請給我解決方案。Textview在Imageview後面滾動

這是我的XML代碼。

<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
android:layout_width="match_parent"`enter code here` 
android:layout_height="match_parent" 
android:orientation="vertical" > 

    <FrameLayout 
     android:id="@+id/frame" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content"> 

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


     <ImageView 
        android:id="@+id/article_image" 
        android:layout_width="match_parent" 
        android:layout_height="250dp" 
        android:layout_gravity="top" 
        android:scaleType="fitXY" 
        android:src="@drawable/garden"/> 

      <TextView 
        android:id="@+id/image_desc" 
        android:layout_width="match_parent" 
        android:layout_height="wrap_content" 
        android:background="#77000000" 
        android:gravity="center|bottom" 
        android:padding="8dp"/> 

     </RelativeLayout> 
    </FrameLayout> 

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

      <ScrollView 
        android:layout_width="match_parent" 
        android:layout_height="match_parent" 
        android:background="#77000000"> 


      <RelativeLayout 
        android:layout_width="match_parent" 
        android:layout_height="wrap_content" 
        android:orientation="vertical" 
        android:padding="16dp" > 

      <TextView 
        android:id="@+id/article_body" 
        android:layout_width="match_parent" 
        android:layout_height="match_parent" 
        android:background="#ffffff" 
        android:text="A good practice to bring the best performance 
        for android application is to make sure your main thread does 
        the minimum amount of work. Any long running tasks or heavy 
        operations are usually performed in a different thread. 
        Typical long running tasks could be network operations, 
        reading files form memory, animations, etc. In this article, 
        we will create a simple asynchronous ListView in Android. 
        ListView with thumbnails thumbnails on each row 
        (as shows in the image below) will be loaded asynchronously 
        form server. We will populate a ListView with thumbnail images 
        downloaded from the internet using a AsyncTask.A good practice to bring the best performance 
        for android application is to make sure your main thread does 
        the minimum amount of work. Any long running tasks or heavy 
        operations are usually performed in a different thread. 
        Typical long running tasks could be network operations, 
        reading files form memory, animations, etc. In this article, 
        we will create a simple asynchronous ListView in Android. 
        ListView with thumbnails thumbnails on each row 
        (as shows in the image below) will be loaded asynchronously 
        form server. We will populate a ListView with thumbnail images 
        downloaded from the internet using a AsyncTask." /> 

      </RelativeLayout> 
     </ScrollView> 
     </RelativeLayout> 
    </RelativeLayout> 

enter image description here enter image description here

回答

2
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:id="@+id/LinearLayout1" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:background="@drawable/ic_launcher" 
    android:orientation="vertical" > 

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

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

      <TextView 
       android:id="@+id/textView1" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:layout_marginTop="100dp" 
       android:text="@string/hello_world" /> 
     </LinearLayout> 
    </ScrollView> 

</LinearLayout> 
+0

我不想使用圖像作爲佈局的背景,我想滾動textview在Imageview上像「脈衝應用程序」在android – Maheswaran

+0

http://stackoverflow.com/questions/20717445/textview-scroll -on-imageview-like-pulse-app-scroll/20717812?noredirect = 1#20717812 – Maheswaran

+0

請參閱上面的鏈接,我需要爲此解決方案 – Maheswaran

2
<FrameLayout 
    android:id="@+id/frame" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent"> 




    <ImageView 
       android:id="@+id/article_image" 
       android:layout_width="match_parent" 
       android:layout_height="250dp" 
       android:layout_gravity="top" 
       android:scaleType="fitXY" 
       android:src="@drawable/garden"/> 

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

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

     <TextView 
      android:id="@+id/textView1" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_marginTop="100dp" 
      android:text="@string/hello_world" /> 
    </LinearLayout> 
</ScrollView> 
    </FrameLayout > 

爲此,我希望這是工作。我有同樣的問題,並通過這期運用解決。

+0

對不起楊,它不工作,textview不滾動,你也給圖像高度爲250dp不變,它使不同手機尺寸的變化。 – Maheswaran