【发布时间】:2018-08-02 22:53:26
【问题描述】:
标题可能有误,抱歉。 我使用底部导航视图。当我单击一个图标时,我想打开一个不同的活动。我的部分代码如下,这段代码运行良好。
mainactiyity.java
case R.id.navigation_home:
Intent Intent = new Intent(getApplicationContext(), SetData.class);
startActivity(Intent);
return true;
SetData.java
super.onCreate(savedInstanceState);
setContentView(R.layout.set_data);
但我想在 BottomNavigationView 下打开新活动。新活动覆盖了整个屏幕,我看不到导航栏。我该如何解决?
activity.main
<android.support.constraint.ConstraintLayout
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:id="@+id/container"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="oww.MainActivity">
<android.support.design.widget.BottomNavigationView
android:id="@+id/navigation"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginEnd="0dp"
android:layout_marginStart="0dp"
android:background="?android:attr/windowBackground"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:menu="@menu/navigation" />
</android.support.constraint.ConstraintLayout>
设置数据
<android.support.percent.PercentRelativeLayout
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="@color/colorAccent"
tools:context=".SetData">
</android.support.percent.PercentRelativeLayout>
【问题讨论】:
标签: android android-layout android-fragments layout bottomnavigationview