4

私はroughikeのBottomBar 2.0を使用しています:https://github.com/roughike/BottomBar/Bottombarの上にスナックバーを表示するには?

私はSnackBarを表示すると、BottomBar自体に表示されます。

ボトムバーの上に描画したいです。

activity_main.xml:

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

    <RelativeLayout 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:id="@+id/here" 
     android:background="#fff"> 

     <FrameLayout 
      android:id="@+id/contentContainer" 
      android:layout_width="match_parent" 
      android:layout_height="match_parent" 
      android:layout_above="@+id/bottomBar"> 

      <TextView 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:textAppearance="?android:attr/textAppearanceLarge" 
       android:text="Three Buttons Bar" 
       android:id="@+id/textView" 
       android:layout_centerVertical="true" 
       android:layout_centerHorizontal="true" 
       android:textColor="@color/colorPrimary" 
       android:textSize="35sp" /> 

     </FrameLayout> 

     <com.roughike.bottombar.BottomBar 
      android:id="@+id/bottomBar" 
      android:layout_width="match_parent" 
      android:layout_height="60dp" 
      android:layout_alignParentBottom="true" 
      app:bb_tabXmlResource="@xml/bottombar_tabs" /> 
    </RelativeLayout> 

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

MainActivity.java:

public class MainActivity extends AppCompatActivity { 

    @Override 
    protected void onCreate(Bundle savedInstanceState) { 
     super.onCreate(savedInstanceState); 
     setContentView(R.layout.activity_main); 

     BottomBar bottomBar = (BottomBar) findViewById(R.id.bottomBar); 
     bottomBar.setOnTabSelectListener(new OnTabSelectListener() { 
      @Override 
      public void onTabSelected(int tabId) { 
       switch (tabId) { 
        case R.id.recent_item: 
         Snackbar.make(findViewById(R.id.main_activity), "Recent Item Selected", Snackbar.LENGTH_LONG).show(); 
         break; 
        case R.id.favorite_item: 
         Snackbar.make(findViewById(R.id.main_activity), "Favorite Item Selected", Snackbar.LENGTH_LONG).show(); 
         break; 
        case R.id.location_item: 
         Snackbar.make(findViewById(R.id.main_activity), "Location Item Selected", Snackbar.LENGTH_LONG).show(); 
         break; 
       } 
      } 
     }); 
    } 
} 

スクリーンショット:

BottomBar Only BottomBar hidden when SnackBar appears

レイアウトファイルに問題はありませんか?
私は何が欠けていますか? Move snackbar above the bottom bar、それは...

EDIT助けにはならなかった:

は私もこれをチェックし、私はas Abtin saidを試してみました

Snackbar.make(bottomBar, "Location Item Selected", Snackbar.LENGTH_LONG).show(); 

<com.roughike.bottombar.BottomBar 
      android:id="@+id/bottomBar" 
      android:layout_width="match_parent" 
      android:layout_height="60dp" 
      android:layout_alignParentBottom="true" 
      app:bb_tabXmlResource="@xml/bottombar_tabs" 
      app:bb_behavior="underNavbar"/> 

を今、それはあなたのようになったS:

Bottom Bar with extra space below That space filled by Snackbar

あなたが見ることができるように、私は望んでいないで、私はapp:bb_behavior="underNavbar"を設定BottomBar以下、この未使用のスペースが、あります...

答えて

0

あなたはスナックバーに渡すビューを変更してみてください。

Snackbar.make(findViewById(R.id.contentContainer), "Recent Item Selected", Snackbar.LENGTH_LONG).show();  
+0

Plsの –

0

コーディネーターのレイアウト動作は、あなたがSnackbar.make()の最初の引数に下のバーのビュー自体を渡す必要があり実装されている方法に応じて。

Snackbar.make(bottomBar, "Location Item Selected", Snackbar.LENGTH_LONG).show(); 

他の可能性はあなたがレイアウトでbottombarウィジェット上app:bb_behaviorの属性が欠落していることです。

+0

を助けにはなりませんでしたそれの上に、しかしそれの前に:( –

0

私は今では(コードの変更ofcourseの)意図したとおりに働いている... Roughike's BottomBar 1.4Roughike's BottomBar 2.0から

を切り替える。..

を私もそれがクールで意図したようにも取り組んだ、AHBottomNavigationを試してみました。..あなたはスナックバーを示すとしてCoordinatorLayoutのIDを与えることになるたいあなたは彼の下から、XMLでCoordinatorLayoutを作成する必要があります)

+0

は、どのようにそれは私があまりにもそれを使用しています?AHBottomNavigationで作業を取得しなかったが、スナックバーが表示されていないことを確認してください..私はそれを試してみましたが、それは質問を編集:( – hildegard

1

;

それが質問に答えていないので、私は、答えとしてこれをマークしていないよ

ビューのidは楽しい時に見る。スナックバーの作り方。

<android.support.design.widget.CoordinatorLayout 
     android:id="@+id/viewSnack" 
     android:layout_width="match_parent" 
     android:layout_height="100dp" 
     android:layout_alignParentBottom="true" 
     android:layout_marginBottom="50dp"/> 

Snackbar.make(findViewById(R.id.viewSnack), "Text of the SnackBar", Snackbar.LENGTH_LONG).show(); 
関連する問題