2017-08-26 2 views
0

Salut J'essaie de faire une boîte de dialogue qui apparaît à partir du bas de l'écran dans Android. En cherchant, j'ai découvert que je peux utiliser BottomSheetDialog. Maintenant, je veux une barre d'outils rétractable avec une imageview dans mon BottomSheetDialog. Je souhaite afficher les détails (comme le nom, l'information, le numéro de téléphone portable, etc. en tant que textviews simples) lorsque mon image s'effondre en faisant défiler vers le haut.
Mon problème est:
1.Lorsque j'ajoute la mise en page NestedScrollView pour afficher DETAILS, le texte chevauche initialement l'image, mais lorsque l'image est réduite, le texte ne chevauche plus l'image. La position du texte reste fixe, il ne bouge pas lorsque l'image s'effondre lors du défilement, et l'expérience de défilement est très très très mauvaise.
2. Lorsque j'ajoute une mise en page linéaire pour afficher DETAILS, le texte apparaît sur mon image de la barre d'outils escamotable.BottomSheetDialog avec barre d'outils escamotable

Voici mon fichier de mise en page pour les dialogues:

<?xml version="1.0" encoding="utf-8"?> 
    android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android" 
     xmlns:app="http://schemas.android.com/apk/res-auto" 
     xmlns:tools="http://schemas.android.com/tools" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     app:layout_behavior="android.support.design.widget.BottomSheetBehavior">

<android.support.design.widget.AppBarLayout 
     android:id="@+id/app_bar" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:fitsSystemWindows="true" 
     android:theme="@style/AppTheme.AppBarOverlay"> 

     <android.support.design.widget.CollapsingToolbarLayout 
      android:id="@+id/profile_activity_collapsing_toolbar" 
      android:layout_width="match_parent" 
      android:layout_height="match_parent" 
      android:fitsSystemWindows="true" 
      app:contentScrim="?attr/colorPrimary" 
      app:layout_scrollFlags="scroll|enterAlways|enterAlwaysCollapsed"> 

      <ImageView 
       android:id="@+id/panel_profile_picture" 
       android:layout_width="match_parent" 
       android:layout_height="400dp" 
       android:adjustViewBounds="true" 
       android:scaleType="centerCrop" 
       app:layout_collapseMode="parallax" 
       app:layout_collapseParallaxMultiplier="0.7" /> 

      <!--<android.support.v7.widget.Toolbar--> 
       <!--android:id="@+id/toolbar"--> 
       <!--android:layout_width="match_parent"--> 
       <!--android:layout_height="?attr/actionBarSize"--> 
       <!--app:layout_collapseMode="parallax"--> 
       <!--app:popupTheme="@style/AppTheme.PopupOverlay" />--> 
     </android.support.design.widget.CollapsingToolbarLayout> 
    </android.support.design.widget.AppBarLayout> 

    <!--<ADD A LAYOUT HERE TO SHOW TEXTVIEW FOR DETAILS LIKE NAME,INFORMATION ETC>--> 

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


Le bottomSheetDialog apparaît lorsqu'une carte est touché dans le activity.Here est mon code qui montre la bottomSheetDialog:

  convertView = mlayoutInflator.inflate(R.layout.panel_details_list_item, null); 
      /* setting texts in convertView */ 
      convertView.setOnClickListener(new View.OnClickListener() { 
      @Override 
      public void onClick(View view) { 
       Log.d("Card touched","Card touched at " + position); 
       mBottomSheetDialog = new BottomSheetDialog(mContext); 
       bottomSheetView = mlayoutInflator.inflate(R.layout.panel_more_detail_item,null); 
       mBottomSheetDialog.setContentView(bottomSheetView); 
       mbottomSheetBehavior = BottomSheetBehavior.from((View) bottomSheetView.getParent()); 
       bottomSheetInterviewerImage = bottomSheetView.findViewById(R.id.panel_profile_picture); 
       bottomSheetInterviewerImage.setImageDrawable(drawableList.get(position)); 
       mBottomSheetDialog.show(); 
      } 
     }); 

Que dois-je utiliser pour montrer mes DÉTAILS sans compromettre avec la barre d'outils escamotable? Je veux que lorsque mon image s'effondre et se déplace, les textures apparaissent et aussi se déplacer vers le haut lorsque vous faites défiler vers le haut. PS: Veuillez commenter si quelque chose de pas clair ou plus de code lié doit être posté. TIA

Répondre

0

J'ai trouvé quelque chose qui sert mes purpose.I je utilise FrameLayout avec le comportement de l'application comme app:layout_behavior="@string/appbar_scrolling_view_behavior"
Ainsi, lorsque vous touchez votre image et défiler vers le haut, l'image s'effondre, et les détails déplacer vers le haut sur le défilement. Cependant, l'image ne peut pas être réduite en touchant la disposition des détails et en la faisant défiler vers le haut. Il faut toucher l'image et faire défiler vers le haut. Jusqu'à ce qu'une meilleure solution soit trouvée, cela sert mon but.
donc mon fichier de mise en page pour dialogue feuille inférieure est comme:

<?xml version="1.0" encoding="utf-8"?> 
    <android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android" 
     xmlns:app="http://schemas.android.com/apk/res-auto" 
     xmlns:tools="http://schemas.android.com/tools" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     app:layout_behavior="android.support.design.widget.BottomSheetBehavior"> 


    <android.support.design.widget.AppBarLayout 
     android:id="@+id/app_bar" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:fitsSystemWindows="true" 
     android:theme="@style/AppTheme.AppBarOverlay"> 

     <android.support.design.widget.CollapsingToolbarLayout 
      android:id="@+id/profile_activity_collapsing_toolbar" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:fitsSystemWindows="true" 
      app:contentScrim="?attr/colorPrimary" 
      app:layout_scrollFlags="scroll|enterAlways|enterAlwaysCollapsed"> 

      <ImageView 
       android:id="@+id/panel_profile_picture" 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content" 
       android:adjustViewBounds="true" 
       android:scaleType="centerCrop" 
       app:layout_collapseMode="parallax" 
       app:layout_collapseParallaxMultiplier="0.7" /> 

      <!--<android.support.v7.widget.Toolbar--> 
       <!--android:id="@+id/toolbar"--> 
       <!--android:layout_width="match_parent"--> 
       <!--android:layout_height="?attr/actionBarSize"--> 
       <!--app:layout_collapseMode="parallax"--> 
       <!--app:popupTheme="@style/AppTheme.PopupOverlay" />--> 
     </android.support.design.widget.CollapsingToolbarLayout> 
    </android.support.design.widget.AppBarLayout> 
    <FrameLayout 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     app:layout_behavior="@string/appbar_scrolling_view_behavior"> 
     <LinearLayout 
      android:layout_width="match_parent" 
      android:layout_height="300dp" 
      android:orientation="vertical"> 
      <TextView 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content" 
       android:text="This is detial 1" 
       android:padding="20dp" 
       android:gravity="center"/> 

      <TextView 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content" 
       android:text="This is detial 2" 
       android:padding="20dp" 
       android:gravity="center"/> 

      <TextView 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content" 
       android:text="This is detial 3" 
       android:padding="20dp" 
       android:gravity="center"/> 

     </LinearLayout> 

    </FrameLayout> 

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

`