Home | 简体中文 | 繁体中文 | 杂文 | Github | 知乎专栏 | Facebook | Linkedin | Youtube | 打赏(Donations) | About
知乎专栏

114.8. 替换 FrameLayout

屏某个区域布局

			
    <FrameLayout
        android:id="@+id/controller"
        android:layout_width="409dp"
        android:layout_height="681dp"
        tools:layout_editor_absoluteX="1dp"
        tools:layout_editor_absoluteY="49dp"
        tools:ignore="MissingConstraints">

    </FrameLayout>			
			
		

点击事件 android:onClick="hotelMenuClick"

			
		<androidx.cardview.widget.CardView
             android:layout_width="match_parent"
             android:layout_height="match_parent"
             android:layout_weight="1"
             android:onClick="hotelMenuClick"
             app:cardCornerRadius="10dp"
             app:cardElevation="0dp">

             <ImageView
                 android:id="@+id/imageView4"
                 android:layout_width="wrap_content"
                 android:layout_height="wrap_content"
                 android:layout_weight="1"
                 android:scaleType="fitXY"
                 app:srcCompat="@drawable/bg_tavern_menu" />
         </androidx.cardview.widget.CardView>			
			
		

事件响应

			
    public void hotelMenuClick(View v) {

        getSupportFragmentManager()
                .beginTransaction()
                .replace(R.id.controller, new HotelFragment(), null)
                .addToBackStack(null)
                .commit();

    }