How to put a scroll inside tabHost (asbas) on Android?

1

I have a code that creates tabs on the screen as needed, the problem is that when I create many tabs they will be "squeezed" on the screen and cut the rest on the tabs. I'm doing this all via Java, without using xml so I'm not able to make my scroll work, does anyone know how I can do this? Thank you in advance.

My short code:

My class inherits from a TabActivity I'm not using hs = new HorizontalScrollView(this); on the first line within the code. I tried to use more did not work.

public void adicionaAbas(String texto) {

    hs = new HorizontalScrollView(this);

    TabHost th = getTabHost();

    th.setBackgroundColor(Color.WHITE);

    TabSpec ts = th.newTabSpec(texto);
    // nome da aba
    ts.setIndicator(texto);


    th.addTab(ts);

    setContentView(th);
}
    
asked by anonymous 09.11.2015 / 15:28

1 answer

0

I believe you should adjust the size of the ScrollView.

ViewGroup.LayoutParams params = new ViewGroup.LayoutParams(
                    ViewGroup.LayoutParams.MATCH_PARENT,
                    ViewGroup.LayoutParams.MATCH_PARENT);
hs.setLayoutParams(params);
    
09.11.2015 / 19:25