关于设置布局的宽高,比如线性布局的宽高

 <LinearLayout 
   android:id = "@+id/ll_a"
   android:layout_height = "wrap_content"
   android:layout_width = "wrap_content">

 <LinearLayout 
   android:id = "@+id/ll_b"
   android:layout_height = "wrap_content"
   android:layout_width = "wrap_content">

   <FrameLayout
   android:id = "@+id/fl_a"
   android:layout_height = "wrap_content"
   android:layout_width = "wrap_content">
   
	<LinearLayout 
   	android:id = "@+id/ll_c"
   	android:layout_height = "wrap_content"
  	android:layout_width = "wrap_content">

	</LinearLayout>


   </FrameLayout>
</LinearLayout>
</LinearLayout>

  

关于动态设置布局需要注意:
如果给a布局设置宽高,那么a的父布局不能是别的类型,否则报类型转换异常
比如给id为ll_c 的设置
LayoutParams timeParams = (LayoutParams) ll_title_custom.getLayoutParams();

timeParams.width = mDisplayMetrics2.widthPixels /4;//屏幕宽度的四分之一


ll_c.setLayoutParams(new LinearLayout.LayoutParams(timeParams.width,LayoutParams.WRAP_CONTENT));
就会错,


LayoutParams timeParams = (LayoutParams) ll_title_custom.getLayoutParams();

timeParams.width = mDisplayMetrics2.widthPixels /4;//屏幕宽度的四分之一

ll_b.setLayoutParams(new LinearLayout.LayoutParams(timeParams.width,LayoutParams.WRAP_CONTENT));
就不会错,因为ll_b是线性布局,他的父布局也是线性布局ll_a 所以设置成功。像ll_c的外面就是Framelayout,这就属于类型转换异常