2017-01-02 4 views
0

Fragmentの画像を上に配置し、視差効果をスクロールダウンして画像を追加したいと考えています。私はCollapsible Toolbarを使ってこれをやってみましたが、画像がCollapsible Toolbarを満たしていないので、視差が働いていません。長い画像をCollapsibleToolbarに収める方法

私はこの

のような何かをしたいしかし、これは私が今までに達成するものです。

But this is what I achieved till now.

 <?xml version="1.0" encoding="utf-8"?> 
    <android.support.v4.widget.DrawerLayout 
    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" 
    xmlns:card_view="http://schemas.android.com/tools" 
    android:id="@+id/drawerlayout1"> 

<android.support.design.widget.CoordinatorLayout 
    android:id="@+id/coordinatorlayout" 
    android:layout_width="fill_parent" 
    android:layout_height="match_parent" 
    app:expandedTitleMarginStart="70dp"> 

    <android.support.design.widget.AppBarLayout 
     android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar" 
     android:layout_width="fill_parent" 
     android:id="@+id/actionbarlayout" 
     android:layout_height="207dp"> 

     <android.support.design.widget.CollapsingToolbarLayout 
      android:id="@+id/CollapsingToolbarLayout1" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      app:contentScrim="@color/colorPrimary" 
      app:layout_scrollFlags="scroll|exitUntilCollapsed" 
      > 

      <ImageView 
       android:layout_width="match_parent" 
       android:layout_height="match_parent" 
       android:scaleType="centerCrop" 
       android:id="@+id/details_Image" 
       app:layout_collapseMode="parallax" 
       /> 

      <android.support.v7.widget.Toolbar 
       android:id="@+id/toolbar1" 
       android:layout_width="match_parent" 
       android:layout_height="?attr/actionBarSize" 
       app:popupTheme="@style/ThemeOverlay.AppCompat.Light" 
       app:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar" 
       app:layout_collapseMode="pin" 
       android:minHeight="?attr/actionBarSize"/> 

     </android.support.design.widget.CollapsingToolbarLayout> 

    </android.support.design.widget.AppBarLayout> 

    <android.support.v4.widget.NestedScrollView 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:fillViewport="true" 
     app:layout_behavior="@string/appbar_scrolling_view_behavior"> 



     <LinearLayout 
      android:layout_width="fill_parent" 
      android:layout_height="wrap_content" 
      android:orientation="vertical"> 

      <android.support.v7.widget.CardView 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content" 
       card_view:cardElevation="3dp" 
       card_view:cardCornerRadius="7dp" 
       android:layout_margin="5dp" 
       android:id="@+id/new_order" 
       card_view:cardBackgroundColor="@color/cardview_shadow_end_color" 
       > 

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

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

         <LinearLayout 
          android:layout_width="match_parent" 
          android:layout_height="wrap_content" 
          android:gravity="center" 
          android:orientation="horizontal" 
          android:layout_marginTop="15dp"> 

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

           <ImageButton 
            android:layout_width="wrap_content" 
            android:layout_height="wrap_content" 
            android:id="@+id/download" 
            android:background="@null" 
            android:src="@drawable/ic_action_ic_file_download_white_36dp" 
            android:layout_centerInParent="true" 
            /> 

          </RelativeLayout> 
          <RelativeLayout 
           android:layout_width="match_parent" 
           android:layout_height="match_parent" 
           android:layout_weight="1"> 

           <ImageView 
            android:layout_width="wrap_content" 
            android:layout_height="wrap_content" 
            android:id="@+id/favourite" 
            android:layout_centerInParent="true" 
            /> 

          </RelativeLayout> 
          <RelativeLayout 
           android:layout_width="match_parent" 
           android:layout_height="match_parent" 
           android:layout_weight="1"> 


           <ImageButton 
            android:layout_width="wrap_content" 
            android:layout_height="wrap_content" 
            android:id="@+id/zoom" 
            android:background="@null" 
            android:src="@drawable/ic_action_ic_zoom_out_map_white_36dp" 
            android:layout_centerInParent="true" 
            /> 

          </RelativeLayout> 



         </LinearLayout> 

        </RelativeLayout> 

        <ScrollView 
         android:layout_width="match_parent" 
         android:layout_height="wrap_content" 
         android:layout_margin="20dp"> 

         <TextView 
          android:layout_width="match_parent" 
          android:layout_height="wrap_content" 
          android:id="@+id/imageDescription" 
          android:text="keckwcbjbewbcbcbcwjbejwkbcwkbcbwjc" 

          /> 



        </ScrollView> 

       </LinearLayout> 

      </android.support.v7.widget.CardView> 

     </LinearLayout> 

    </android.support.v4.widget.NestedScrollView> 

    <ImageView 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_gravity="center" 
     android:visibility="gone" 
     android:id="@+id/fullimage"/> 

</android.support.design.widget.CoordinatorLayout> 

答えて

0

<android.support.design.widget.CoordinatorLayout 
    android:id="@+id/coordinatorlayout" 
    android:layout_width="fill_parent" 
    android:layout_height="match_parent" 
    app:expandedTitleMarginStart="70dp"> 

    <android.support.design.widget.AppBarLayout 
     android:id="@+id/actionbarlayout" 
     android:layout_width="fill_parent" 
     android:layout_height="207dp" 
     android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"> 

     <android.support.design.widget.CollapsingToolbarLayout 
      android:id="@+id/CollapsingToolbarLayout1" 
      android:layout_width="match_parent" 
      android:layout_height="match_parent" 
      app:contentScrim="@color/colorPrimary" 
      app:layout_scrollFlags="scroll|exitUntilCollapsed"> 

      <ImageView 
       android:id="@+id/details_Image" 
       android:layout_width="match_parent" 
       android:layout_height="match_parent" 
       android:scaleType="centerCrop" 
       android:background="@color/colorAccent" 
       app:layout_collapseMode="parallax" /> 


      <android.support.v7.widget.Toolbar 
       android:id="@+id/toolbar1" 
       android:layout_width="match_parent" 
       android:layout_height="?attr/actionBarSize" 
       android:minHeight="?attr/actionBarSize" 
       app:layout_collapseMode="pin" 
       app:popupTheme="@style/ThemeOverlay.AppCompat.Light" 
       app:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar" /> 

     </android.support.design.widget.CollapsingToolbarLayout> 

    </android.support.design.widget.AppBarLayout> 

    <android.support.v4.widget.NestedScrollView 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:fillViewport="true" 
     app:layout_behavior="@string/appbar_scrolling_view_behavior"> 


     <LinearLayout 
      android:layout_width="fill_parent" 
      android:layout_height="wrap_content" 
      android:orientation="vertical"> 

      <android.support.v7.widget.CardView 
       android:id="@+id/new_order" 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content" 
       android:layout_margin="5dp" 
       card_view:cardBackgroundColor="@color/cardview_shadow_end_color" 
       card_view:cardCornerRadius="7dp" 
       card_view:cardElevation="3dp"> 

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

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

         <LinearLayout 
          android:layout_width="match_parent" 
          android:layout_height="wrap_content" 
          android:layout_marginTop="15dp" 
          android:gravity="center" 
          android:orientation="horizontal"> 

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

           <ImageButton 
            android:id="@+id/download" 
            android:layout_width="wrap_content" 
            android:layout_height="wrap_content" 
            android:layout_centerInParent="true" 
            android:src="@drawable/ic_action_ic_file_download_white_36dp" 
            android:background="@null" /> 

          </RelativeLayout> 

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

           <ImageView 
            android:id="@+id/favourite" 
            android:layout_width="wrap_content" 
            android:layout_height="wrap_content" 
            android:layout_centerInParent="true" /> 

          </RelativeLayout> 

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


           <ImageButton 
            android:id="@+id/zoom" 
            android:layout_width="wrap_content" 
            android:layout_height="wrap_content" 
            android:layout_centerInParent="true" 
            android:src="@drawable/ic_action_ic_zoom_out_map_white_36dp" 
            android:background="@null" /> 

          </RelativeLayout> 


         </LinearLayout> 

        </RelativeLayout> 

        <ScrollView 
         android:layout_width="match_parent" 
         android:layout_height="wrap_content" 
         android:layout_margin="20dp"> 

         <TextView 
          android:id="@+id/imageDescription" 
          android:layout_width="match_parent" 
          android:layout_height="wrap_content" 
          android:text="keckwcbjbewbcbcbcwjbejwkbcwkbcbwjc" 

          /> 


        </ScrollView> 

       </LinearLayout> 

      </android.support.v7.widget.CardView> 

     </LinearLayout> 

    </android.support.v4.widget.NestedScrollView> 

    <ImageView 
     android:id="@+id/fullimage" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_gravity="center" 
     android:visibility="gone" /> 

</android.support.design.widget.CoordinatorLayout> 

これであなたのコードを置き換えます。

+0

ありがとうございますが、動作していない、すべてが同じです。 – User9132

+0

折りたたみツールバーの高さの幅を親に合わせて変更していますか? –

+0

そしてandroid:scaleType = "fitXY" –

関連する問題