ABOUT ME

-

Today
-
Yesterday
-
Total
-
  • linearlayout 오른쪽 정렬 , 오른쪽으로 이동
    Android/UI 2022. 8. 28. 18:35

    원래는 이런 디자인

     

     

    하지만 메뉴모양을 오른쪽으로 이동하고 싶다.

     

    위젯과 위젯사이에 다음과 같은 코드를 추가하자.

    <View
        android:layout_width="0dp"
        android:layout_height="0dp"
        android:layout_weight="1" />

    그리고 오른쪽으로 이동하고 싶은 위젯에

            android:layout_gravity="right"

     

    전체 xml 코드

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="horizontal">
        <ImageView
            android:layout_marginLeft="5dp"
            android:id="@+id/commnet_userimage"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:src="@drawable/ic_baseline_face_24"/>
    
        <TextView
        android:layout_marginLeft="5dp"
        android:layout_marginTop="2dp"
        android:id="@+id/comment_username"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="닉네임"
        android:textSize="11sp"
        android:textColor="@color/black"
        android:letterSpacing="-0.05"
        android:layout_marginBottom="8dp"/>
    
        <View
            android:layout_width="0dp"
            android:layout_height="0dp"
            android:layout_weight="1" />
    
        <ImageView
            android:layout_marginRight="5dp"
            android:layout_gravity="right"
            android:id="@+id/commnet_more"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:src="@drawable/ic_baseline_more_horiz_24"/>
    
    </LinearLayout>
Designed by Tistory.