布局问题:在表的内部滚动视图,自定义对话框内 [英] Layout problem: scrollview inside a table, inside a custom dialog

查看:212
本文介绍了布局问题:在表的内部滚动视图,自定义对话框内的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有我不能修复的布局问题。我已经通过这里的许多职位看,而我似乎是唯一的,足以张贴问题。

我创建一个自定义对话框以编程方式创建一个3行的表。顶部和底部的行具有的文字,而中间行包含一个滚动型,其中包含一个的LinearLayout。这随后的LinearLayout包含了一些意见数(TextView的在这个例子中)。因为我这样做编程,看到XML伪code以下,低于实际code。

我想什么事情发生,就是当在的LinearLayout所包含内容的高度变得太大时,滚动型,它的工作,并在页眉和页脚的TextView的始终可见。

的问题是,当对话框变得足够大,滚动型出现在整个对话接手,我的页脚的TextView消失在屏幕上。
我能做些什么,以确保页脚的TextView从未消失,但滚动型仍然可以发挥作用?

请参阅下面的图片链接:

在左侧页脚可见,走在右边:

http://img690.imageshack.us/i/screenshotss.png/

 < TableLayout>
    <&的TableRow GT;
        <&TextView的GT;
    < /&的TableRow GT;
    <&的TableRow GT;
        <&滚动型GT;
            <&的LinearLayout GT;
                <的TextView />
                <的TextView />
                <的TextView />
                ...
            < / LinearLayout中>
        < /滚动型>
    < /&的TableRow GT;
    <&的TableRow GT;
        <&TextView的GT;
    < /&的TableRow GT;
< / TableLayout>

这里的code:

 公共类DialogScrollTest扩展对话框{    公共DialogScrollTest(上下文CTX){
        超(CTX);        的setTitle();
        requestWindowFeature(Window.FEATURE_NO_TITLE);        TableLayout表=新TableLayout(CTX);
        连续的TableRow;
        TextView的文本;        行=新的TableRow(CTX);
        {
            文本=新的TextView(CTX);
            text.setText(TestTop);
            row.addView(文本);
        }
        table.addView(行);        行=新的TableRow(CTX);
        {
            滚动型滚动=新的滚动型(CTX);
            {
                线性的LinearLayout =新的LinearLayout(CTX);
                linear.setOrientation(LinearLayout.VERTICAL);
                对于(INT T = 0; T< 32; ++ T){
                    文本=新的TextView(CTX);
                    text.setText(TestScroll);
                    linear.addView(文本);
                }
                scroll.addView(线性);
            }
            row.addView(滚动);
        }
        table.addView(行);        行=新的TableRow(CTX);
        {
            文本=新的TextView(CTX);
            text.setText(TestBottom);
            row.addView(文本);
        }
        table.addView(行);        this.setContentView(表);
    }
}


解决方案

你能不能用的ListView与页脚和页眉或它在一个样本数据,实际上你试图做一些更复杂?

I have a layout problem which I can't fix. I've looked through many posts on here, and mine seems to be unique enough to post a question.

I've created a custom Dialog which programmatically creates a 3 row table. The top and bottom rows have text, while the middle row contains a ScrollView, which contains a LinearLayout. That LinearLayout then contains some number of views (TextView in this example). Since I'm doing this programmatically, see the XML pseudocode below, and the actual code below that.

What I would like to happen, is that when the height of the contained content in the LinearLayout gets too big, the ScrollView does its job, and the header and footer TextView's are always visible.

The problem is that when the dialog gets big enough, the ScrollView appears to take over the whole dialog, and my footer TextView disappears off the screen. What can I do to make sure the footer TextView never disappears, but the ScrollView can still function?

See the following image links:

Footer visible on the left, gone on the right:

http://img690.imageshack.us/i/screenshotss.png/

<TableLayout>
    <TableRow>
        <TextView>
    </TableRow>
    <TableRow>
        <ScrollView>
            <LinearLayout>
                <TextView/>
                <TextView/>
                <TextView/>
                ...
            </LinearLayout>
        </ScrollView>
    </TableRow>
    <TableRow>
        <TextView>
    </TableRow>
</TableLayout>

Here's the code:

public class DialogScrollTest extends Dialog {

    public DialogScrollTest(Context ctx){
        super(ctx);

        setTitle("");
        requestWindowFeature(Window.FEATURE_NO_TITLE); 

        TableLayout table = new TableLayout(ctx);       
        TableRow row;       
        TextView text;

        row = new TableRow(ctx);
        {
            text = new TextView(ctx);
            text.setText("TestTop");
            row.addView(text);
        }
        table.addView(row);

        row = new TableRow(ctx);
        {
            ScrollView scroll = new ScrollView(ctx);
            {   
                LinearLayout linear = new LinearLayout(ctx);
                linear.setOrientation(LinearLayout.VERTICAL);
                for(int t=0; t<32; ++t){
                    text = new TextView(ctx);
                    text.setText("TestScroll");
                    linear.addView(text);                   
                }
                scroll.addView(linear);
            }       
            row.addView(scroll);
        }
        table.addView(row);

        row = new TableRow(ctx);
        {
            text = new TextView(ctx);
            text.setText("TestBottom");
            row.addView(text);
        }
        table.addView(row);

        this.setContentView(table);
    }   
}

解决方案

Could you just use ListView with footer and header or it's a sample data and in fact you trying to do something more complex ?

这篇关于布局问题:在表的内部滚动视图,自定义对话框内的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆