[LinearLayout] 오른쪽 정렬하기.!
[LinearLayout] 을 사용하던 중,
아래의 그림처럼 Text는 왼쪽, ImageButton은 가장 오른쪽으로 두고 싶은 상황이 생겼다.
이런 때에
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="left"
/>
<ImageButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="right"
android:src="@drawable/ic_menu_camera" />
이런 코드를 생각하겠지만, 내가 원하던대로 나오지 않는다.😭
아래의 그림처럼 나올뿐.!!
이런 때에,
TextView, ImgeButton 사이에 View를 집어넣으면 원하는 모양으로 나온다.!
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="left" />
<View
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_weight="1" />
<ImageButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="right"
android:src="@drawable/ic_menu_camera" />
이렇게.! 이렇게 하면 원하는대로 나온다.🤗 👏👏👏!!!