LinearLayout : 선형 레이아웃
일반적으로 많은 컨트롤을 인터페이스에 나열 해야하는 경우 LinearLayout을 사용할 수 있습니다. LinearLayout은 수직 또는 수평 으로 하위 요소를 순서대로 정렬하는 것입니다. 각 어린이 요소는 이전 요소 다음에 있습니다. 아래에서 간단히 이해합시다.
XML 레이아웃 파일에서는 다음 단위가 발생합니다.
PX : 스크린 DP의 픽셀 포인트 : 밀도에 따른 초록 단위입니다. 화면 SP의 물리적 크기 : DP와 유사하지만 사용자의 글꼴 크기에 따라 스케일링됩니다.
XML 코드는 다음과 같습니다. 수직 방향 변경 Android : Orientation = "vertical"( 수직 )
<? xml version = "1.0"alcoding = "utf-8"?> <linearlayout xmlns : android = "http://schemas.android.com/apk/res/android"xmlns : 툴 = "http://schemas.android.com/tools : layout_width ="andlayout_width = ""http:/schemas.android.com/tools " Android : layout_height = "match_parent"Android : Orientation = "vertical"도구 : context = "com.example.administrator.adapter.mainactivity"> <TextView Android : "Text ="android : background = "#ef0808"and gravity = "center" "and textsize ="Android : "android :"android : android : android : "android : android : background ="Android : "Android :"and android : android : "android. Android : layout_height = "100dp" /> <TextView Android : Text = "Second TextView"Android : Gravity = "Center"Android : Back Android : Gravity = "Center"Android : Textsize = "18SP"Android : Background = "#ec07ca"Android : layout_width = "match_parent"Android : layout_height = "100dp" /> <TextView Android : Text = "4th TextView"Android : "Center ="Center = "Android :"18sp "and eloproid :"and and legroid : "and and legroid :"and and legroid : "18sp". Android : layout_width = "match_parent"Android : layout_height = "100dp" /> < /linearlayout>
실행 결과 : 각 텍스트 뷰는 위에서 아래로 배열됩니다.
XML 코드는 다음과 같습니다. 수평 방향 변경 Android : Orientation = "수평"( 수평 )
<? xml version = "1.0"alcoding = "utf-8"?> <linearlayout xmlns : android = "http://schemas.android.com/apk/res/android"xmlns : 툴 = "http://schemas.android.com/tools : layout_width ="andlayout_width = ""http:/schemas.android.com/tools " Android : layout_height = "match_parent"Android : Orientation = "수평"도구 : context = "com.example.administrator.adapter.mainactivity"> <TextView Android : "Text ="android : background = "#ef0808"and gravity = "center": textsize = "18sp" Android : layout_width = "100dp"Android : layout_height = "100dp" /> <TextView Android : 텍스트 = "두 번째 텍스트 뷰"Android : gravity = "center"android : background = "#31ef0b"Android : textsize = "18sp"android : layout_width = "100dp" Android : "Third TextView"Android : Gravity = "Center"Android : 텍스트 : "18sp"Android : back Android : background = "#f5d105"Android : layout_width = "100dp"Android : layout_height = "100dp" /> < /linearlayout>
실행 결과 : 각 텍스트 뷰는 왼쪽에서 오른쪽으로 가로로 배열됩니다.
이 두 선형 레이아웃의 유일한 차이점은 Android : Orientation의 값의 차이입니다.
실험 요약 :이 두 선형 레이아웃의 유일한 차이점은 Android : 방향의 값이 다르다는 것입니다. 이 실험을 통해 우리는 Android의 선형 레이아웃에 대한 예비 이해를 가지고 있습니다.
위는이 기사의 모든 내용입니다. 이 기사의 내용이 모든 사람의 연구 나 업무에 도움이되기를 바랍니다. 또한 wulin.com을 더 지원하기를 바랍니다!