2013-07-02 58 views
0

我正在嘗試使用此代碼製作圖庫http://developer.android.com/training/animation/zoom.html我正在嘗試使3橫跨和6下來,但其他圖像過去的第一行是遠離屏幕的權利。任何建議,以獲得第一行下的其他圖像。Android圖庫,圖片方式

代碼:

<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" 
android:id="@+id/container" 
android:layout_width="match_parent" 
android:layout_height="match_parent"> 

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

    <TextView style="?android:textAppearanceSmall" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:text="@string/message_zoom_touch_expand" /> 

    <!-- This is an example layout containing thumbnail image buttons that, when pressed, 
     zoom in to show more detail. All of the zooming and animation logic is in 
     the ZoomActivity class. --> 
    <LinearLayout 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_marginTop="16dp" 
     android:orientation="horizontal"> 

     <!-- These buttons don't have any decorations (3D bevel, etc.), but it's still 
      important to show feedback on touch or focus. The custom 
      "ToughHighlightImageButton" ImageButton subclass helps achieve this by drawing 
      the standard system "pressed" and "focused" overlay upon user interaction. --> 

     <com.example.android.animationsdemo.TouchHighlightImageButton 
      android:id="@+id/thumb_button_1" 
      android:layout_width="100dp" 
      android:layout_height="75dp" 
      android:layout_marginRight="1dp" 
      android:src="@drawable/thumb1" 
      android:scaleType="centerCrop" 
      android:contentDescription="@string/description_image_1" /> 

     <com.example.android.animationsdemo.TouchHighlightImageButton 
      android:id="@+id/thumb_button_2" 
      android:layout_width="100dp" 
      android:layout_height="75dp" 
      android:src="@drawable/thumb2" 
      android:scaleType="centerCrop" 
      android:contentDescription="@string/description_image_2" /> 
    <com.example.android.animationsdemo.TouchHighlightImageButton 
      android:id="@+id/thumb_button_3" 
      android:layout_width="100dp" 
      android:layout_height="75dp" 
      android:src="@drawable/thumb2" 
      android:scaleType="centerCrop" 
      android:contentDescription="@string/description_image_2" /> 

          <LinearLayout 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_marginTop="300dp" 
     android:orientation="horizontal"> 
        <com.example.android.animationsdemo.TouchHighlightImageButton 
      android:id="@+id/thumb_button_4" 
      android:layout_width="100dp" 
      android:layout_height="75dp" 
      android:src="@drawable/thumb2" 
      android:scaleType="centerCrop" 
      android:contentDescription="@string/description_image_2" /> 
        <com.example.android.animationsdemo.TouchHighlightImageButton 
      android:id="@+id/thumb_button_5" 
      android:layout_width="100dp" 
      android:layout_height="75dp" 
      android:src="@drawable/thumb2" 
      android:scaleType="centerCrop" 
      android:contentDescription="@string/description_image_2" /> 
        <com.example.android.animationsdemo.TouchHighlightImageButton 
      android:id="@+id/thumb_button_5" 
      android:layout_width="100dp" 
      android:layout_height="75dp" 
      android:src="@drawable/thumb2" 
      android:scaleType="centerCrop" 
      android:contentDescription="@string/description_image_2" /> 
    </LinearLayout> 
    </LinearLayout> 

</LinearLayout> 

<!-- This initially-hidden ImageView will hold the expanded/zoomed version of the 
    images above. Without transformations applied, it takes up the entire screen. 
    To achieve the "zoom" animation, this view's bounds are animated from the 
    bounds of the thumbnail buttons above, to its final laid-out bounds. The implementation 
    of this animation is in the ZoomActivity class. --> 
<ImageView 
    android:id="@+id/expanded_image" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:visibility="invisible" 
    android:contentDescription="@string/description_zoom_touch_close" /> 

回答

1

你的水平LinearLayouts嵌套,他們應該是兄弟姐妹:

<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" 
android:id="@+id/container" 
android:layout_width="match_parent" 
android:layout_height="match_parent"> 

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

    <TextView style="?android:textAppearanceSmall" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:text="@string/message_zoom_touch_expand" /> 

    <!-- This is an example layout containing thumbnail image buttons that, when pressed, 
     zoom in to show more detail. All of the zooming and animation logic is in 
     the ZoomActivity class. --> 
    <LinearLayout 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_marginTop="16dp" 
     android:orientation="horizontal"> 

     <!-- These buttons don't have any decorations (3D bevel, etc.), but it's still 
      important to show feedback on touch or focus. The custom 
      "ToughHighlightImageButton" ImageButton subclass helps achieve this by drawing 
      the standard system "pressed" and "focused" overlay upon user interaction. --> 

     <com.example.android.animationsdemo.TouchHighlightImageButton 
      android:id="@+id/thumb_button_1" 
      android:layout_width="100dp" 
      android:layout_height="75dp" 
      android:layout_marginRight="1dp" 
      android:src="@drawable/thumb1" 
      android:scaleType="centerCrop" 
      android:contentDescription="@string/description_image_1" /> 

     <com.example.android.animationsdemo.TouchHighlightImageButton 
      android:id="@+id/thumb_button_2" 
      android:layout_width="100dp" 
      android:layout_height="75dp" 
      android:src="@drawable/thumb2" 
      android:scaleType="centerCrop" 
      android:contentDescription="@string/description_image_2" /> 
    <com.example.android.animationsdemo.TouchHighlightImageButton 
      android:id="@+id/thumb_button_3" 
      android:layout_width="100dp" 
      android:layout_height="75dp" 
      android:src="@drawable/thumb2" 
      android:scaleType="centerCrop" 
      android:contentDescription="@string/description_image_2" /> 
    </LinearLayout> 
    <LinearLayout 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_marginTop="300dp" 
     android:orientation="horizontal"> 
        <com.example.android.animationsdemo.TouchHighlightImageButton 
      android:id="@+id/thumb_button_4" 
      android:layout_width="100dp" 
      android:layout_height="75dp" 
      android:src="@drawable/thumb2" 
      android:scaleType="centerCrop" 
      android:contentDescription="@string/description_image_2" /> 
        <com.example.android.animationsdemo.TouchHighlightImageButton 
      android:id="@+id/thumb_button_5" 
      android:layout_width="100dp" 
      android:layout_height="75dp" 
      android:src="@drawable/thumb2" 
      android:scaleType="centerCrop" 
      android:contentDescription="@string/description_image_2" /> 
        <com.example.android.animationsdemo.TouchHighlightImageButton 
      android:id="@+id/thumb_button_5" 
      android:layout_width="100dp" 
      android:layout_height="75dp" 
      android:src="@drawable/thumb2" 
      android:scaleType="centerCrop" 
      android:contentDescription="@string/description_image_2" /> 
    </LinearLayout> 
</LinearLayout> 

<!-- This initially-hidden ImageView will hold the expanded/zoomed version of the 
    images above. Without transformations applied, it takes up the entire screen. 
    To achieve the "zoom" animation, this view's bounds are animated from the 
    bounds of the thumbnail buttons above, to its final laid-out bounds. The implementation 
    of this animation is in the ZoomActivity class. --> 
<ImageView 
    android:id="@+id/expanded_image" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:visibility="invisible" 
    android:contentDescription="@string/description_zoom_touch_close" /> 

</FrameLayout> 

你也可以考慮使用GridView代替。

+0

那我該怎麼做? – user2407147

+0

那麼,你可以開始嘗試我提供的固定佈局... – kabuko

+0

我已經改變了它,但仍然看起來一樣。代碼對我來說看起來是一樣的。對不起,作爲一個新手:S – user2407147