2015-07-12 19 views
1

我得到我的CoordinatorLayout一個怪異的行爲我有,當我在我的應用程序對於它被退回第一個項目按後退按鈕這不過調用另一個活動的活動稱爲不正確到正確的呼叫活動,但第二個項目,我必須按兩次按鈕等。繼承人我的XML文件requestLayout()由android.support.design.widget.CollapsingToolbarLayout

<android.support.design.widget.CoordinatorLayout 
    android:id="@+id/coordinativelayout" 
    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:fontFamily="http://schemas.android.com/tools"> 

    <android.support.design.widget.AppBarLayout 
     android:id="@+id/appbar" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:fitsSystemWindows="true" 
     android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"> 

     <android.support.design.widget.CollapsingToolbarLayout 
      android:id="@+id/collapsing_toolbar" 
      android:layout_width="match_parent" 
      android:layout_height="match_parent" 
      android:fitsSystemWindows="true" 
      app:contentScrim="@color/primaryColor" 
      app:expandedTitleMarginBottom="32dp" 
      app:expandedTitleMarginEnd="64dp" 
      app:expandedTitleMarginStart="48dp" 
      app:layout_scrollFlags="scroll|exitUntilCollapsed"> 

      <ImageView 
       android:id="@+id/detail_header_imageview" 
       android:layout_width="match_parent" 
       android:layout_height="300dp" 
       android:layout_alignParentTop="true" 
       android:fitsSystemWindows="true" 
       android:scaleType="centerCrop" 
       app:layout_collapseMode="parallax"/> 

      <android.support.v7.widget.Toolbar 
       android:id="@+id/detail_app_bar" 
       android:layout_width="match_parent" 
       android:layout_height="?attr/actionBarSize" 
       android:theme="@style/ThemeOverlay.AppCompat.Light"/> 
     </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:layout_gravity="fill_vertical" 
     android:layout_marginBottom="?attr/actionBarSize" 
     app:layout_behavior="@string/appbar_scrolling_view_behavior"> 

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


      <ImageView 
       android:id="@+id/poster_image_view" 
       android:layout_width="100dp" 
       android:layout_height="150dp" 
       android:layout_marginBottom="15dp" 
       android:layout_marginTop="25dp" 
       android:layout_marginLeft="15dp" 
       android:layout_marginRight="15dp"/> 

      <TextView 
       android:id="@+id/release" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:textAppearance="?android:textAppearanceLarge" 
       android:layout_marginTop="25dp" 
       android:textStyle="bold|normal" 
       android:fontFamily="sans-serif-thin" 
       android:layout_toRightOf="@id/poster_image_view" 
       android:text="@string/release_date"/> 
      <TextView 
       android:id="@+id/releaseDate" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:layout_toRightOf="@id/poster_image_view" 
       android:layout_below="@id/release" 
       android:layout_marginBottom="10dp" 
       android:layout_marginTop="5dp"/> 
      <ImageView 
       android:id="@+id/star_image_view" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:src="@drawable/star_32dp" 
       android:layout_below="@id/releaseDate" 
       android:layout_toRightOf="@id/poster_image_view" 
       /> 
      <TextView 
       android:id="@+id/rating" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:textStyle="bold|normal" 
       android:layout_toRightOf="@id/star_image_view" 
       android:layout_below="@id/releaseDate" 
       android:layout_marginLeft="5dp" 
       android:layout_marginRight="5dp"/> 

      <TextView 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:layout_toRightOf="@id/rating" 
       android:layout_marginRight="5dp" 
       android:layout_below="@id/releaseDate" 
       android:text="@string/out_of_ten"/> 

      <TextView 
       android:id="@+id/moviedescription" 
       android:layout_width="match_parent" 
       android:layout_height="match_parent" 
       android:layout_below="@id/poster_image_view" 
       android:layout_marginLeft="5dp" 
       android:layout_marginRight="5dp" 
       android:layout_marginTop="5dp" 
       android:gravity="center"/> 
     </RelativeLayout> 
    </android.support.v4.widget.NestedScrollView> 
</android.support.design.widget.CoordinatorLayout> 

繼承人的片段被充氣佈局文件

public class DetailMovieFragment extends Fragment { 

    private final String BASE_URl = "http://image.tmdb.org/t/p/w500/"; 
    private static final String BUNDLE_INT = "DetailMovie"; 
    private int mItemPosition; 
    private Format mFormatter; 


    @Override 
    public void onCreate(Bundle savedInstanceState) { 
     super.onCreate(savedInstanceState); 
     mItemPosition = getArguments().getInt(DetailMovieActivity.BUNDLE_ARGS); 
    } 

    @Override 
    public View onCreateView(LayoutInflater inflater, ViewGroup container, 
          Bundle savedInstanceState) { 

     View view = inflater.inflate(R.layout.fragment_detail_movie, container, false); 
     Toolbar toolbar = (Toolbar) view.findViewById(R.id.detail_app_bar); 
     ((AppCompatActivity) getActivity()).setSupportActionBar(toolbar); 

     //TextView represents the Synopsis of the Movie 
     TextView plot = (TextView) view.findViewById(R.id.moviedescription); 

     //poster 
     ImageView poster = (ImageView) view.findViewById(R.id.poster_image_view); 

     TextView releaseDate = (TextView) view.findViewById(R.id.releaseDate); 
     TextView rating = (TextView) view.findViewById(R.id.rating); 


     CollapsingToolbarLayout collapsingToolbarLayout = (CollapsingToolbarLayout) view.findViewById(R.id.collapsing_toolbar); 
     final CollapsingToolbarLayout templayout = collapsingToolbarLayout; 
     collapsingToolbarLayout.setTitle(MovieDataList.get(getActivity()).getSingleResultByPosition(mItemPosition).getOriginal_title()); 
     mFormatter = new SimpleDateFormat("yyyy-MM-dd"); 
     final Window window = getActivity().getWindow(); 

     //backDrop Poster 
     final ImageView imageView = (ImageView) view.findViewById(R.id.detail_header_imageview); 
     String header_image = MovieDataList.get(getActivity()).getSingleResultByPosition(mItemPosition).getBackdrop_path(); 
     Picasso.with(getActivity()).load(BASE_URl + header_image).into(imageView, new Callback() { 
      @Override 
      public void onSuccess() { 
       Bitmap bmap = ((BitmapDrawable) imageView.getDrawable()).getBitmap(); 
       Palette.Builder builder = new Palette.Builder(bmap); 
       Palette palette = builder.generate(); 

       //Extracting Colors from the Image to set The ToolBar Color and status bar Color 
       int darkVibrantColor = palette.getDarkVibrantColor(R.color.darkPrimaryColor); 
       int vibrantColor = palette.getVibrantColor(R.color.primaryColor); 
       templayout.setContentScrimColor(vibrantColor); 

       if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { 
        window.setStatusBarColor(darkVibrantColor); 
        window.setNavigationBarColor(vibrantColor); 
       } 
      } 

      @Override 
      public void onError() { 

      } 
     }); 
     collapsingToolbarLayout = templayout; 

     rating.setText(String.valueOf(MovieDataList.get(getActivity()).getSingleResultByPosition(mItemPosition).getVote_average())); 
     //using MVC Pattern to get Poster Url and then Loading in ImageView 
     Picasso.with(getActivity()).load("http://image.tmdb.org/t/p/w185" + MovieDataList.get(getActivity()).getSingleResultByPosition(mItemPosition).getPoster_path()).into(poster); 

     releaseDate.setText(MovieDataList.get(getActivity()).getSingleResultByPosition(mItemPosition).getRelease_date()); 

     plot.setText(MovieDataList.get(getActivity()).getSingleResultByPosition(mItemPosition).getOverview()); 

     return view; 
    } 
} 

赫雷什堆棧跟蹤

07-12 21:25:08.406 31106-31106/COM .example.prathamesh.popmovies W /檢視:requestLayout()由android.support.v7.widget.Toolbar {3d069b8f VE不當稱爲.... ...... ID 0,0-720,112#7f0e0070應用程式:ID/detail_app_bar}佈局過程:在運行的第二佈局傳遞
07-12 21:25:08.429 31106-31106/com.example.prathamesh.popmovies W /檢視:requestLayout()由android.support.design.widget.CollapsingToolbarLayout {1ecffe1c V.ED ....不當稱爲.. ...... 0,0-720,600#7f0e006e應用程式:ID/collapsing_toolbar}第二佈局傳遞期間:發佈信息有下一幀
07-12 21:25:08.432 31106-31106/com.example.prathamesh.popmovies我/時間線:時間線:Activity_idle ID:[email protected]時間:54288775

回答

0

固定它實際上我是用onIntereceptTouch監聽器在我recyclerview 這是不正確實施 繼承人的鏈接以便正確地實現它

RecyclerView onClick

相關問題