ツールバーの下にあるナビゲーションビューに問題があります。私はそれを正しく設定するためにそれを読んだことがありますが、アプリケーションはアクティビティの代わりにフラグメントを使用する必要がありますが、残念ながら私のケースではないと思います。特定のアクティビティでのナビゲーションビュー
(私はツールバーがxmlに追加されているので)MainActivityでNavViewをうまく動作させることができましたが、起動画面でNavViewを必要としないという問題があります。
Fragmentsに移動することなく、NavViewを1つのアクティビティに正しく追加できますか? (それは完全に働いた)
MainActivity.xml:
<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"
android:background="@drawable/bg"
tools:context="ru.asmodeoux.g_lounge.MainActivity">
<android.support.design.widget.FloatingActionButton
android:id="@+id/fab"
android:layout_width="59dp"
android:layout_height="59dp"
android:layout_gravity="top|left"
android:layout_margin="@dimen/fab_margin"
app:backgroundTint="@color/FAB_color"
app:elevation="24dp"
app:layout_anchor="@+id/include"
app:layout_anchorGravity="bottom|right"
app:srcCompat="@drawable/call" />
<android.support.design.widget.AppBarLayout
android:layout_width="match_parent"
android:layout_height="44dp"
android:theme="@style/AppTheme.AppBarOverlay">
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:elevation="0dp"
android:minHeight="0dp"
android:textAlignment="center"
app:popupTheme="@style/AppTheme.AppBarOverlay" />
</android.support.design.widget.AppBarLayout>
<include
android:id="@+id/include"
layout="@layout/content_main" />
</android.support.design.widget.CoordinatorLayout>
aboutProduct.xml(私はNavNiewを表示する必要があります):
<android.support.v4.widget.DrawerLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="false">
<android.support.design.widget.CoordinatorLayout
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"
android:background="@drawable/bg">
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:background="@drawable/bg"
android:layout_height="match_parent">
<RelativeLayout
android:layout_width="match_parent"
android:id="@+id/productRoot"
android:layout_height="wrap_content">
<ImageView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:adjustViewBounds="true"
android:id="@+id/productImg"
/>
<TextView
android:id="@+id/productDescription"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/productImg"
android:layout_marginBottom="75dp"
android:layout_marginTop="20dp"
android:paddingLeft="20dp"
android:paddingRight="20dp"
android:text="Place for product description."
android:textAlignment="textStart"
android:textColor="@color/white"
android:textSize="19sp"
android:textStyle="italic" />
</RelativeLayout>
</ScrollView>
<android.support.design.widget.FloatingActionButton
android:id="@+id/productAdd"
android:layout_width="59dp"
android:layout_height="59dp"
android:layout_gravity="bottom|end"
android:layout_margin="@dimen/fab_margin"
android:backgroundTint="@color/FAB_color"
android:elevation="24dp"
app:srcCompat="@drawable/buy" />
<TextView
android:id="@+id/productPrice"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom|start"
android:layout_marginBottom="@dimen/fab_margin"
android:background="@drawable/rectangle_rounded_some"
android:layout_marginLeft="@dimen/fab_margin"
android:paddingLeft="20dp"
android:paddingRight="20dp"
android:text="100 руб."
android:textAllCaps="false"
android:textColor="@color/black"
android:textSize="37sp" />
</android.support.design.widget.CoordinatorLayout>
<android.support.design.widget.NavigationView
android:id="@+id/navigation_view"
android:layout_width="wrap_content"
app:headerLayout="@layout/navigation_header"
android:background="@color/white"
android:layout_height="match_parent"
android:layout_gravity="start"
app:menu="@menu/drawer" />
</android.support.v4.widget.DrawerLayout>
のヘッダーレイアウト:
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/gray">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="70dp"
android:text="Что-то ещё?"
android:layout_marginStart="14dp"
android:textColor="@color/white"
android:textAlignment="textStart"
android:layout_marginBottom="8dp"
android:textSize="18sp"
android:textStyle="bold" />
</RelativeLayout>
「aboutProduct」クラスのNavViewが今見ている様子のスクリーンショットhere
そして、どのようにそれは私が最も簡単な方法は、「NoActionBar」にテーマエディタでそこにツールバーを設定し、手ですべての活動にツールバーを追加することだと思い結果here
はい、可能です。質問は何ですか? –
@PalakDarjiそれでは?事前に感謝します – asmodeoux
完璧に見えるSSを投稿しました。何が問題なの?また、ナビゲーションアクティビティを作成し、そのアクティビティに非常に同じNavigationBarを表示することで、NavigationBarをフラグメントなしのアクティビティに追加することもできます。私はそれをやって、それはうまく動作しますが、質問はそのスクリーンショットの問題は何ですか? –