First . File -> Project Structure -> CardView(come.android.cardview:v7.25.0.0;
Second. drawable -> right click on the folder -> and then select batch drawable importer.-> rename target name;
Third . new layout resource .named fragment_cake. rewrite the root element android.support.v7.widget.CardView
Fourth. xmlns:card_view = "http://schemas.android.com/apk/res-auto" .cardview = CornerRadius = "4dp"
Fifth . Creat FragmentCake.class,
public FragmentCake extends Fragment{
public FragmentCake(){
}
@Nullable
@override
public View onCreatView(LayoutInflater inflater ,@Nullable viewGroup container,@Nullable Bundle saveInstancestate){
return inflater.inflate(R.layout.fragment_cake,container,false);
}
}
Six. Rewrite activity_main.xml
<fragment
tools:layout = "@layout/fragment_cake"
android:id = "@+id/fragmen"
android:name = "com.bodor.fragmentcake"
android:layout_width = "match_parent"
android:layout_height = "wrap_content"