안드로이드 하단 탭
조회수 3779회
몇가지 글을 찾아봤지만 해답을 얻을 수 없어서 여기에 질문올립니다. TabWidget을 화면 하단에 놓는 방법이 있나요? 있다면 어떻게 하죠?
두가지 시도를 해봤는데 둘다 동작하지 않았습니다.
1) tabwidget을 framelayout 아래로 세팅. 2) tabwidget의 gravity를 bottom으로 세팅
1 답변
-
화면 하단에 놓는 가장 간단하고 확장 가능한 해결 방법이 있습니다.
LinearLayout을 Vertical로 두시고 TabWidget위에 FrameLayout을 놓습니다.
Framelayout과 tabwidget의 layout_height을 wrap_content로 합니다. framelayout의 android:layout_weight를 1로 설정합니다.
TabWidget의 android:layout_weight은 "0"으로 설정합니다. (0 은 디폴트 값인데 강조하기 위해서 넣었습니다) TabWidget의android:layout_marginBottom을 "-4dp"로 설정합니다. (아래 구분선을 제거하기 위해서)
소스코드
<?xml version="1.0" encoding="utf-8"?> <TabHost xmlns:android="http://schemas.android.com/apk/res/android" android:id="@android:id/tabhost" android:layout_width="fill_parent" android:layout_height="fill_parent"> <LinearLayout android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent" android:padding="5dp"> <FrameLayout android:id="@android:id/tabcontent" android:layout_width="fill_parent" android:layout_height="wrap_content" android:padding="5dp" android:layout_weight="1"/> <TabWidget android:id="@android:id/tabs" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_weight="0" android:layout_marginBottom="-4dp"/> </LinearLayout> </TabHost>
댓글 입력