ABOUT ME

-

Today
-
Yesterday
-
Total
-
  • linearlayout item 가운데 정렬
    Android/UI 2022. 8. 28. 19:10

    다음과 같이 view 안에 내용물은 가운데로 이동하고 싶으면 

    item을 감싸고 있는 LinearLayout에 gravity="center" 를 해주면 된다.

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:gravity="center"
        android:orientation="vertical">

     

     

    전체 xml 코드

    <?xml version="1.0" encoding="utf-8"?>
    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:app="http://schemas.android.com/apk/res-auto"
        xmlns:tools="http://schemas.android.com/tools"
        android:id="@+id/bottomSheetDashBoardLayout"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:background="@drawable/round_background"
        android:orientation="vertical"
        app:behavior_draggable="true"
        app:behavior_hideable="true"
        app:layout_behavior="com.google.android.material.bottomsheet.BottomSheetBehavior">
    
        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:gravity="center"
            android:orientation="vertical">
    
            <TextView
                android:id="@+id/dialog_update"
                android:layout_width="wrap_content"
                android:layout_height="55dp"
                android:gravity="center_vertical"
                android:letterSpacing="-0.05"
                android:text="수정"
                android:textColor="#9C27B0"
                android:textSize="20sp"
                android:textStyle="bold" />
    
    
            <!--구분선-->
            <View
                android:id="@+id/chat_underline1"
                android:layout_width="match_parent"
                android:layout_height="0.8dp"
                android:background="@color/gray" />
    
    
            <TextView
                android:id="@+id/dialog_delete"
                android:layout_width="wrap_content"
                android:layout_height="55dp"
                android:gravity="center_vertical"
                android:letterSpacing="-0.05"
                android:text="삭제"
                android:textColor="#9C27B0"
                android:textSize="20sp"
                android:textStyle="bold" />
    
        </LinearLayout>
    </LinearLayout>
Designed by Tistory.