1
<?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"
android:id="@+id/parentLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
tools:context="">
<include android:id="@+id/contentLayout" layout="@layout/content_our_story" />
</android.support.design.widget.CoordinatorLayout>
content_our_story.xml동적으로 현재 내부 클래스 캐스트 예외를
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout 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="@string/appbar_scrolling_view_behavior"
tools:context=""
android:layout_margin="5dp"
tools:showIn="@layout/activity_our_story">
</RelativeLayout>
설정 레이아웃 PARAM 코드를 보여주는 파일을 포함 상대 레이아웃 레이아웃 매개 변수를 설정할 수 없습니다 :
contentLayout = (RelativeLayout) findViewById(R.id.contentLayout);
RelativeLayout.LayoutParams param=new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.MATCH_PARENT, RelativeLayout.LayoutParams.MATCH_PARENT);
param.setMargins(0,0,0,0);
contentLayout.setLayoutParams(param);
내가의 LayoutParams을 설정하려고 "contentLayout"이라는 ID를 사용하여 클래스 캐스트 예외를 표시하고이를 코디네이터 레이아웃으로 간주합니다. 그러나 위의 그림과 같이 상대적 레이아웃이 포함되어 있습니다. 제안하십시오.
CoordinatorLayout.LayoutParams PARAM = 새로운 CoordinatorLayout.LayoutParams (CoordinatorLayout.LayoutParams.MATCH_PARENT, CoordinatorLayout.LayoutParams.MATCH_PARENT); –