如何prevent其他浏览被推出来的画面 [英] How to prevent other View being pushed out of the screen

查看:265
本文介绍了如何prevent其他浏览被推出来的画面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是示例XML

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical" android:layout_width="fill_parent"
    android:layout_height="fill_parent">
    <LinearLayout android:layout_width="match_parent"
        android:layout_height="wrap_content" android:orientation="vertical"
        android:layout_margin="5dip" android:background="#FF992222">
        <ScrollView android:layout_height="wrap_content"
            android:layout_width="fill_parent">
            <LinearLayout android:layout_height="wrap_content"
                android:orientation="vertical" android:layout_width="fill_parent">
                <TextView android:layout_width="wrap_content" android:text="TextView"
                    android:layout_height="wrap_content" android:textSize="24dip"></TextView>
            </LinearLayout>
        </ScrollView>
    </LinearLayout>
    <LinearLayout android:layout_width="match_parent"
        android:layout_height="wrap_content" android:orientation="vertical"
        android:layout_margin="5dip" android:background="#FF555555">
        <TextView android:layout_width="wrap_content" android:text="TextView"
            android:layout_height="wrap_content" android:textSize="24dip"></TextView>
    </LinearLayout>
</LinearLayout>

结果是这样的:

The result is like this :

如果你注意到,在上LinerLayout文本被包裹在的LinearLayout和滚动型。

If you notice, the text in upper LinerLayout are wrapped in LinearLayout and ScrollView.

如果上面的内容不断增加,它会看起来像这样

If the upper content keep added, it will look like this

底部的LinearLayout会被排挤出屏幕前的滚动型变得活跃,使第一个内容变成可滚动的....我不希望被发生了......

Bottom Linearlayout will be pushed out of the screen before the ScrollView become active and make the first content become scrollable.... And I don't want that to be happened...

我应该怎么做才能让滚动型底部查看被推前了画面是这样的:

What should I do to make the Scrollview before the bottom View being pushed out of the screen like this :

(这是编辑的图像,而不是由Android的布局编辑器创建)

(this is edited image and not created by Android Layout editor)

希望这个问题不够清楚..谢谢:)

Hope the question clear enough.. Thanks :)

推荐答案

嗯,如果我理解你清楚的问题,你想在灰色的TextView中保持不动,而在红色textViews可以卷屏,如果我指正敢错在这里。如果这是你想要的东西,那么你可以使用RelativeLayout的实现这一目标。以下是code,生产等的输出:
http://imageshack.us/photo/my-images/836/device20111011012652。 PNG /
ListView控件项是滚动的,而按钮(在你的情况下,它应该是一个TextView)保持它在哪里。

Well, if I understand you question clearly, you want the TextView in grey to remain stationary, while the textViews in red can be scrolled around, correct me if I'm wrong here. If thats what you want, then you can use RelativeLayout to achieve that. Following is the code to produce an output like:
http://imageshack.us/photo/my-images/836/device20111011012652.png/
The ListView entries are scrollable while the button(in your case it should be a TextView) stays where it is.

code:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent">

<ListView android:id="@android:id/list"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="@+id/newtask" android:layout_alignParentTop="true">
</ListView>

<Button android:layout_width="fill_parent" 
android:id="@+id/newtask" 
android:layout_height="wrap_content" 
android:text="Add New Task" android:layout_alignParentBottom="true">
</Button>
</RelativeLayout>  

只要改变底部按钮,一个TextView,它将匹配你想要的。

Just change the bottom button to a TextView and it would match what you wanted.

这篇关于如何prevent其他浏览被推出来的画面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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