반응형
Android : LinearLayout 내의 모든 요소를 동일한 크기로 만드는 방법은 무엇입니까?
비디오 제목과 태그를 표시하는 대화 상자를 만들고 싶습니다. 텍스트 아래에보기, 편집 및 삭제 버튼을 추가하고 추가 할 요소의 크기를 동일하게 만들고 싶습니다. 누구든지 LinearView 내부의 요소를 동일한 크기로 만들기 위해 .xml 레이아웃 파일을 수정하는 방법을 알고 있습니까?
현재 레이아웃 파일은 다음과 가변합니다.
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/txtTitle" android:text="[Title]" >
</TextView>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/txtTags"
android:text="[Tags]" >
</TextView>
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/btnPlay"
android:text="View">
</Button>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/btnEdit"
android:text="Edit">
</Button>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/btnDelete"
android:text="Delete">
</Button>
</LinearLayout>
</LinearLayout>
거기에 넣은 파일 내용을 수정하여 솔루션을 보여줄 수 있습니다 감사하겠습니다.
감사합니다!
사용 android:layout_width="0px"
및 android:layout_weight="1"
세 Button
s. 즉, 버튼은 0 픽셀 이하를 차지해야하지만 세 개는 버튼 사이에 추가 공간을 분할해야합니다. 원하는 시각 효과를 얻을 수 있습니다.
다른 방법은 또 만드는을 구석으로입니다 android:layout_width="fill_parent"
및 android:layout_weight="1"
을 구석으로 이것은 또한 잘 작동합니다!
원하는 weightSum 과 함께 LinearLayout 을 사용 하고 동일한 layout_weight 요소를 만듭니다 . 여기에 예가 있습니다 ...
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:weightSum="5">
<ImageView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:src="@drawable/ic_share_white_36dp"/>
<ImageView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:src="@drawable/ic_search_white_36dp"/>
<ImageView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:src="@drawable/ic_event_note_white_36dp"/>
<ImageView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:src="@drawable/ic_brush_white_36dp"/>
<ImageView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:src="@drawable/ic_menu_white_36dp"/>
</LinearLayout>
따라서 모든 요소의 가중치 합계는 5입니다. 여기 스크린 샷이 있습니다.
그 주, 구글 소재 디자인 아이콘이 사용됩니다. 이것이 도움이되기를 바랍니다.
반응형
'ProgramingTip' 카테고리의 다른 글
브라우저의 디버거 자체에서 동적으로로드 JavaScript (jQuery 사용)를 사용하는 방법은 무엇입니까? (0) | 2020.10.13 |
---|---|
Android가 선택한 라디오 버튼에서 값을 가져 오기 (0) | 2020.10.13 |
super ()는 언제 사용합니까? (0) | 2020.10.13 |
MySQL : Curdate () 대 Now () (0) | 2020.10.13 |
Ajax 요청을 통해 JSON과 함께 Select2를 사용하는 방법은 무엇입니까? (0) | 2020.10.13 |