开发者

Adding a scrollbar to customized panel in Android

Well, I'm trying to add a panel with a sort of map (a sort of image matrix) but the thing is that, since it won't have the same layout each time it gets created, I have no clue of how big will it be; therefore, I wanted to add scrollbars so the user could navigate through the panel yet I've tried different combinations and still I haven't found a successful one =(.

 LinearLayout platinumSeats = new LinearLayout(this);
        platinumSeats.setOrientation(LinearLayout.VERTICAL);
        platinumSeats.setBackgroundColor(Color.WHITE);
        ScrollView seatChart = new ScrollView(this);
        TextView seatsLeft = new TextView(this);
        seatsLeft.setText("Available seats");
        seatsLeft.setTextColor(Color.BLACK);

        container = new Panel(this);

        seatChart.addView(container, 200, 300);
        seatChart.setHorizontalScrollBarEnabled(true);
        seatChart.setVerticalScrollBarEnabled(true);

        platinumSeats.ad开发者_如何学运维dView(seatChart);
        platinumSeats.addView(seatsLeft);        

        setContentView(platinumSeats);

I also tried adding the setXXXXXXScrollBarEnabled features in my Panel constructor but still no luck. Any clues?

Thanks =)


Have you thought about adding your LinearLayout to a ScrollView? I see that you already have a ScrollView, but I notice that what is being added to it is 'container' is really never used anywhere. You should be able to embed the entire LinearLayout into a ScrollView to get the desired effect.

This will allow your child view(s) to scroll when they are too large for the screen. If they fit in the screen, you should notice no difference.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜