LinearLayout (비디오 버튼 컨테이너)과 이미지 버튼이 자식입니다. 해당 비디오 버튼을 오른쪽 정렬해야하므로 layout_gravity="right"
으로 지정했습니다.Android 선형 레이아웃 방향이 레이아웃 중력에 미치는 영향은 무엇입니까?
내가 원하는 것은 이것이다 :
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context=".MainActivity" >
<!-- VIDEO BUTTON CONTAINER -->
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:background="#000000"
android:layout_gravity="top">
<!-- VIDEO BUTTON -->
<ImageButton
android:id="@+id/button_video"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="right"
android:background="?android:attr/selectableItemBackground"
android:contentDescription="@string/desc"
android:paddingBottom="@dimen/controls_button_padding"
android:paddingTop="@dimen/controls_button_padding"
android:src="@drawable/ic_action_video" />
</LinearLayout>
<!-- some FrameLayout and another LinearLayout -->
</LinearLayout>
그것은이 생산
를 내가 얻을 변경하여 비디오 버튼 컨테이너의 android:orientation="horizontal"
android:orientation="vertical"
에가. 무슨 일이 있었습니까? 컨테이너의 수평 방향으로 작동하지 않는 이유는 무엇입니까?
안녕하세요! 그래도 방향 속성은 어떤 역할을합니까? 내가 '세로'에서 '가로'로 갈 때 레이아웃에 어떤 변화도 없었습니다 ... 고마워요! –