마스터Q&A 안드로이드는 안드로이드 개발자들의 질문과 답변을 위한 지식 커뮤니티 사이트입니다. 안드로이드펍에서 운영하고 있습니다. [사용법, 운영진]

listview의 headerview를 고정하고 싶습니다.

0 추천
listview에 addHeaderView를 이용해서 헤더를 추가 시킨 상태입니다.

HorizontalScrollView라서 레이아웃을 따로 분리시키는건 아닌것 같아서 추가시킨 HeaderView를 제일 상단에 고정시키고 listView만 상하로 스크롤 하고 싶은데 방법이 있을까요?
익명사용자 님이 2019년 5월 24일 질문

1개의 답변

0 추천
<LinearLayout
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_weight="0.4"
        android:orientation="vertical"
        android:weightSum="1">
        <ListView
            android:id="@+id/replyList"
            android:layout_width="match_parent"
            android:layout_height="0dp"
            android:layout_weight="0.8"
            android:focusable="true"/>
        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="horizontal"
            android:layout_weight="0.1"
            android:weightSum="1">
            <EditText
                android:id="@+id/commentEditText"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:hint="댓글 쓰기"
                android:layout_weight="0.85"/>
            <Button
                android:id="@+id/commentButton"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="확인"
                android:layout_weight="0.15"/>
        </LinearLayout>
        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_weight="0.1"
            android:orientation="horizontal"
            android:weightSum="1">

            <Button
                android:id="@+id/modifyButton"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_weight="0.5"
                android:text="수정" />
            <Button
                android:id="@+id/deleteButton"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_weight="0.5"
                android:text="삭제" />
        </LinearLayout>
    </LinearLayout>

이 코드 참고해보세요.

리스튜 밑에 에딧텍스트 고정시켜둔건데

이런 형식으로 짜고 리스트뷰 위에 레이아웃 추가하시면 될거 같네요.

rhaps20 (6,010 포인트) 님이 2019년 5월 24일 답변
...