布局、控件

1.四大布局

  LinearLayout线性布局

  RelativeLayout相对布局:
--android:layout_alignLeft--表示让一个控件的左边缘和另一个控件的左边缘对齐。

  FrameLayout帧布局

  PercentFrameLayout百分比帧布局、PercentRelativeLayout百分比相对布局
 使用前在build.gradle中添加引用
--app:layout_widthPercent=50%--高度占布局的50%

2.引入自定义布局、控件

  自定义布局--custom_layout


    
    

  引入自定义布局--
activity_main.xml


        


  自定义控件

public class CustomLayout extends LinearLayout {
    public CustomLayout(Context context, AttributeSet attrs) {
              super(context, attrs);
              LayoutInflater.from(context).inflate(R.layout.custom_layout, this);
              Button b1 = findViewById();
              Button b2 = findViewById();
         }
    }

  引入自定义控件
activity_main.xml


        

你可能感兴趣的:(布局、控件)