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

안드로이드 tabhost 질문

0 추천

제가 배달앱을 만들고있는데 tabhost를 이용해 탭에 한식 분식 중국집 카페 등등 넣어줄려고하는데 

총 6개의 탭을 넣으니 아래 사진과 같이 글자가 2줄 ~3줄로 넘칩니다 .

horizontalScrollView로 처리하면된다고 글을 봐서 했는데 안되서 질문드립니다 

 

kane9529 (1,110 포인트) 님이 2019년 9월 3일 질문
tabhost.xml
<?xml version="1.0" encoding="utf-8"?>


<TabHost xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:id="@+id/tabhost">
    <HorizontalScrollView
        android:id="@+id/imageViewHorizontalScroll"
        android:background="#00FFFFFF"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:scrollbars="horizontal"
        android:scrollbarAlwaysDrawHorizontalTrack="true"
        android:addStatesFromChildren="true"
        android:fillViewport="true">

    <TabWidget
        android:id="@+id/tabs"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:background="#FF383838"
        android:weightSum="4"
        android:minWidth="600px"/>
    </HorizontalScrollView>
    <FrameLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent">

        <ListView
            android:id="@+id/koreafood"
            android:layout_width="match_parent"
            android:layout_height="match_parent">

        </ListView>

        <ListView
            android:id="@+id/china"
            android:layout_width="match_parent"
            android:layout_height="match_parent">

        </ListView>

        <ListView
            android:id="@+id/chiken"
            android:layout_width="match_parent"
            android:layout_height="match_parent">

        </ListView>

        <ListView
            android:id="@+id/pizza"
            android:layout_width="match_parent"
            android:layout_height="match_parent">

        </ListView>

        <ListView
            android:id="@+id/submenu"
            android:layout_width="match_parent"
            android:layout_height="match_parent">

        </ListView>

        <ListView
            android:id="@+id/coffee"
            android:layout_width="match_parent"
            android:layout_height="match_parent">

        </ListView>

        <ListView
            android:id="@+id/fastfood"
            android:layout_width="match_parent"
            android:layout_height="match_parent">

        </ListView>
    </FrameLayout>
</TabHost>
tabhost.java
public class foodtabhost extends TabActivity {
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        TabHost tabHost = getTabHost();
        TabWidget widget=(TabWidget)findViewById(R.id.tabs);
        LayoutInflater.from(this).inflate(R.layout.foodtabhost, tabHost.getTabContentView(), true);

        tabHost.addTab(tabHost.newTabSpec("한식")
                .setIndicator("한식")
                .setContent(R.id.koreafood));
        tabHost.addTab(tabHost.newTabSpec("중국집")
                .setIndicator("중국집")
                .setContent(R.id.china));
        tabHost.addTab(tabHost.newTabSpec("피자")
                .setIndicator("피자")
                .setContent(R.id.pizza));
        tabHost.addTab(tabHost.newTabSpec("분식")
                .setIndicator("분식")
                .setContent(R.id.submenu));
        tabHost.addTab(tabHost.newTabSpec("카페")
                .setIndicator("카페")
                .setContent(R.id.coffee));

        tabHost.addTab(tabHost.newTabSpec("치킨")
                .setIndicator("치킨")
                .setContent(R.id.chiken));
        tabHost.addTab(tabHost.newTabSpec("패스트 푸드")
                .setIndicator("패스트 푸드")
                .setContent(R.id.fastfood));
    }

답변 달기

· 글에 소스 코드 보기 좋게 넣는 법
· 질문에 대해 추가적인 질문이나 의견이 있으면 답변이 아니라 댓글로 달아주시기 바랍니다.
표시할 이름 (옵션):
개인정보: 당신의 이메일은 이 알림을 보내는데만 사용됩니다.
스팸 차단 검사:
스팸 검사를 다시 받지 않으려면 로그인하거나 혹은 가입 하세요.
...