滚动文字上面的扣子,按钮固定在底 [英] Scrolling Text Above Buttons, Buttons Fixed At Bottom

查看:61
本文介绍了滚动文字上面的扣子,按钮固定在底的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有困难得到我想要的界面布局导致一个Android应用程序。

什么,我想简要说明:

图形用户界面是包括两个TextViews和四个按钮。

的四个按钮是被横向布置,所有在同一行中,并固定在屏幕的右下角。

第一两个TextViews的是开始在屏幕的顶部,与文本内容从一行变化到许多几十行的 - 超过将适合在屏幕上不滚动。所以,滚动有时需要看到所有的内容。即使当滚动是必要的,这些按钮是不参加在滚动:它们是始终保持固定在屏幕的右下角的单个行。当滚动是必要的,滚动的文字是永远上方的按钮 - 按钮没有叠加文本

两个TextViews的第二是立即出现的第一个TextView的下方,并且通常只添加一个或两行文本的总长度。当滚动是必要的,第二个TextView的是滚动的第一个TextView的,总是立即在第一TextView的下方出现。

附加限制包括我想要的布局看起来体面以下所有Android设备中,在纵向和横向的屏幕布局:

  • 在Android 1.5的API3 MDPI QVGA(320×240)的设备
  • 在Android 1.5的API3 HVGA MDPI设备
  • 在Android 1.6的API4 QVGA LDPI设备
  • 在Android 2.3的API10 WVGA800设备
  • 在与屏幕的一切都在上面的设备之间

我会担心另一片天(如明天)。

-

我试过布局的多种不同的组合,但没有但已经非常接近这一目标。

(对于某些布局组合,我想,我可以解决在使用RelativeLayout的屏幕左下角的按钮,但一切我尝试与scolling文字总是与后面的按钮上的文本滚动结果 - 按钮覆盖文本。我还没有想出获得按钮对准右下角。)

如果有人有多达帮助我摸不着头脑,布局示例XML下面是对话的起点,但它肯定无法实现这一目标的结果,这表现在以下屏幕截图,生成使用相同的布局示例XML 。 (虽然一些屏幕截图展示了同样的问题,它们向人们显示我在哪里用不同的屏幕。)

 < XML版本=1.0编码=UTF-8&GT?;
<的LinearLayout
    的xmlns:机器人=htt​​p://schemas.android.com/apk/res/android
    机器人:方向=垂直
    机器人:layout_width =FILL_PARENT
    机器人:layout_height =WRAP_CONTENT>
    <滚动型
        机器人:layout_width =FILL_PARENT
        机器人:layout_height =WRAP_CONTENT>
        <的LinearLayout
            机器人:方向=垂直
            机器人:layout_width =FILL_PARENT
            机器人:layout_height =WRAP_CONTENT>
            <的TextView
                机器人:layout_width =FILL_PARENT
                机器人:layout_height =WRAP_CONTENT
                机器人:文本=文本视图1.文本从几行了比在屏幕上什么适合更多的线路变化滚动就要看到这一切。 />
            <的TextView
                机器人:layout_width =FILL_PARENT
                机器人:layout_height =WRAP_CONTENT
                机器人:文本=文本视图2.短文本输入坐在下面的文本视图1. />
        < / LinearLayout中>
    < /滚动型>
    <的LinearLayout
        机器人:方向=横向
        机器人:layout_width =FILL_PARENT
        机器人:layout_height =WRAP_CONTENT>
        <按钮
            机器人:ID =@ + ID / button_1
            机器人:layout_height =FILL_PARENT
            机器人:layout_width =WRAP_CONTENT
            机器人:文本=按钮1/>
        <按钮
            机器人:ID =@ + ID / button_2
            机器人:layout_height =FILL_PARENT
            机器人:layout_width =WRAP_CONTENT
            机器人:文本=按钮2/>
        <按钮
            机器人:ID =@ + ID / button_3
            机器人:layout_height =FILL_PARENT
            机器人:layout_width =WRAP_CONTENT
            机器人:文本=按钮3/>
        <按钮
            机器人:ID =@ + ID / button_4
            机器人:layout_height =FILL_PARENT
            机器人:layout_width =WRAP_CONTENT
            机器人:文本=键4/>
    < / LinearLayout中>
< / LinearLayout中>  

1.5_API3_HVGA_Horizo​​ntal_MDPI - short_text:
1.5_API3_HVGA_Horizo​​ntal_MDPI

问题:按键应对准屏幕的右下角

-

1.5_API3_HVGA_Vertical_MDPI - short_text:
1.5_API3_HVGA_Vertical_MDPI

问题:按键应对准屏幕的右下角

-

1.5_API3_QVGA_240x320_MDPI - short_text:
1.5_API3_QVGA_240x320_MDPI

问题:第四按钮被砸坏。对前三个按钮preFER文字,必要时,留出足够的空间来显示4键换行。

-

1.5_API3_QVGA_320x240_MDPI - short_text:
1.5_API3_QVGA_320x240_MDPI

问题:按键应对准屏幕的右下角

-

1.6_API4_QVGA_Horizo​​ntal_LDPI - long_text:
1.6_API4_QVGA_Horizo​​ntal_LDPI

问题:当文​​本几乎填满整个屏幕,按键的排得到砸了。按钮行不应被砸碎,并将其固定在屏幕的右下角。案文应滚动上方的按钮。

-

1.6_API4_QVGA_Horizo​​ntal_LDPI - short_text:
1.6_API4_QVGA_Horizo​​ntal_LDPI

问题:按键应对准屏幕的右下角

-

1.6_API4_QVGA_Horizo​​ntal_LDPI - very_long_text,滚动条上方:
1.6_API4_QVGA_Horizo​​ntal_LDPI

问题:这些按钮是不是在屏幕上。它们应固定在屏幕的右下角。

-

1.6_API4_QVGA_Horizo​​ntal_LDPI - very_long_text,滚动条底部:
1.6_API4_QVGA_Horizo​​ntal_LDPI

问题:这些按钮可以找到任何地方,但文本滚动条的底部。它们应固定在屏幕的右下角。

-

1.6_API4_QVGA_Vertical_LDPI - short_text:
1.6_API4_QVGA_Vertical_LDPI

问题:按键应对准屏幕的右下角

-

任何意见?

-

附加信息:当我尝试使用RelativeLayout的,并固定在屏幕底部的按钮与安卓layout_alignParentBottom =真正的,那么我的问题是,我不知道如何解决与按键顶部的滚动视图的底部。使用安卓layout_alignBottom =@ ID /按钮只对准按键底部的滚动视图的底部,但随后的按钮叠加文本,就像这样:

-

更新:固定所述按钮的右下角,与上面的按钮滚动文字得以解决的问题

下面是改变布局XML,到目前为止,工程(如果您想看到的滚动粘贴多个文本到文本视图1):<?pre> &LT; XML版本=1.0编码=UTF-8&GT?; &LT;的LinearLayout     的xmlns:机器人=htt​​p://schemas.android.com/apk/res/android     机器人:方向=垂直     机器人:layout_width =FILL_PARENT     机器人:layout_height =FILL_PARENT&GT;     &LT;滚动型         机器人:layout_width =FILL_PARENT         机器人:layout_height =0dp         机器人:layout_weight =1&GT;         &LT;的LinearLayout             机器人:方向=垂直             机器人:layout_width =FILL_PARENT             机器人:layout_height =WRAP_CONTENT&GT;             &LT;的TextView                 机器人:layout_width =FILL_PARENT                 机器人:layout_height =WRAP_CONTENT                 机器人:文本=文本视图1.文本从几行了比在屏幕上什么适合更多的线路变化滚动就要看到这一切。 /&GT;             &LT;的TextView                 机器人:layout_width =FILL_PARENT                 机器人:layout_height =WRAP_CONTENT                 机器人:文本=文本视图2.短文本输入坐在下面的文本视图1. /&GT;         &LT; / LinearLayout中&GT;     &LT; /滚动型&GT;     &LT;的LinearLayout         机器人:方向=横向         机器人:layout_width =FILL_PARENT         机器人:layout_height =WRAP_CONTENT         机器人:重力=权与GT;         &LT;按钮             机器人:ID =@ + ID / button_1             机器人:layout_height =FILL_PARENT             机器人:layout_width =WRAP_CONTENT             机器人:文本=按钮1/&GT;         &LT;按钮             机器人:ID =@ + ID / button_2             机器人:layout_height =FILL_PARENT             机器人:layout_width =WRAP_CONTENT             机器人:文本=按钮2/&GT;         &LT;按钮             机器人:ID =@ + ID / button_3             机器人:layout_height =FILL_PARENT             机器人:layout_width =WRAP_CONTENT             机器人:文本=按钮3/&GT;         &LT;按钮             机器人:ID =@ + ID / button_4             机器人:layout_height =FILL_PARENT             机器人:layout_width =WRAP_CONTENT             机器人:文本=键4/&GT;     &LT; / LinearLayout中&GT; &LT; / LinearLayout中&GT;

我有一个剩余的问题,我会发布一个新的问题

解决方案

设置你的滚动型的layout_height到0dp并设置其layout_weight为1。这应该按按钮在屏幕的底部,但没有进一步的。

I'm having difficulty getting the GUI layout results I want in an Android app.

A brief description of what I want:

The GUI is to include two TextViews and four Buttons.

The four Buttons are to be laid out horizontally, all in the same row, and fixed at the bottom-right of the screen.

The first of the two TextViews is to start at the top of the screen, with text contents varying from one line to many dozens of lines - more than will fit on the screen without scrolling. So, scrolling is sometimes necessary to see all of the contents. Even when scrolling is necessary, the buttons are not to participate in the scrolling: they are to always remain fixed in a single row at the bottom-right of the screen. When scrolling is necessary, the scrolling text is to always be above the buttons - the buttons are not to overlay the text.

The second of the two TextViews is to appear immediately beneath the first TextView, and will normally only add one or two lines to the total length of text. When scrolling is necessary, the second TextView is to scroll with the first TextView, always appearing immediately beneath the first TextView.

Additional constraints include that I want the layout to look decent on all of the following Android devices, in both vertical and horizontal screen layouts:

  • Android 1.5 API3 QVGA MDPI (320x240) devices
  • Android 1.5 API3 HVGA MDPI devices
  • Android 1.6 API4 QVGA LDPI devices
  • Android 2.3 API10 WVGA800 devices
  • Everything with screens in between the above devices

I'll worry about tablets another day (like tomorrow).

--

I've tried many different combinations of Layouts, but nothing yet has come very close to the goal.

(With some of the layout combinations I tried, I can fix the buttons at the bottom-left of the screen with RelativeLayout, but everything I try with the scolling text always results with the text scrolling behind the buttons - the buttons overlay the text. I haven't figured out getting the buttons to align to the bottom-right.)

If anyone is up for helping me figure this out, the layout example xml below is a conversation starting point, but it definately fails to achieve the goal result, as demonstrated in the following screen shots, generated using this same layout example xml. (While some of the screen shots demonstrate the same problem, they help to show where I'm at with the different screens.)

<?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="wrap_content">
    <ScrollView
        android:layout_width="fill_parent"
        android:layout_height="wrap_content">
        <LinearLayout
            android:orientation="vertical"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content">
            <TextView
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:text="Text View 1.  Text varies from a few lines to many more lines than what fits on the screen.  Scrolling is necessary to see it all." />
            <TextView
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:text="Text View 2.  Short text entry sits below Text View 1." />
        </LinearLayout>
    </ScrollView>
    <LinearLayout
        android:orientation="horizontal"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content">
        <Button
            android:id="@+id/button_1"
            android:layout_height="fill_parent"
            android:layout_width="wrap_content"
            android:text="Button 1" />
        <Button
            android:id="@+id/button_2"
            android:layout_height="fill_parent"
            android:layout_width="wrap_content"
            android:text="Button 2" />
        <Button
            android:id="@+id/button_3"
            android:layout_height="fill_parent"
            android:layout_width="wrap_content"
            android:text="Button 3" />
        <Button
            android:id="@+id/button_4"
            android:layout_height="fill_parent"
            android:layout_width="wrap_content"
            android:text="Button 4" />
    </LinearLayout>
</LinearLayout>

1.5_API3_HVGA_Horizontal_MDPI - short_text:

Issue: The buttons should align with the bottom-right of the screen.

--

1.5_API3_HVGA_Vertical_MDPI - short_text:

Issue: The buttons should align with the bottom-right of the screen.

--

1.5_API3_QVGA_240x320_MDPI - short_text:

Issue: 4th Button is smashed. Prefer text on first three buttons to wrap when necessary, leaving enough room to display 4th button.

--

1.5_API3_QVGA_320x240_MDPI - short_text:

Issue: The buttons should align with the bottom-right of the screen.

--

1.6_API4_QVGA_Horizontal_LDPI - long_text:

Issue: When the text almost fills the screen, the row of buttons get smashed. The row of buttons should not be smashed, and should be fixed at the bottom-right of the screen. The text should scroll above the buttons.

--

1.6_API4_QVGA_Horizontal_LDPI - short_text:

Issue: The buttons should align with the bottom-right of the screen.

--

1.6_API4_QVGA_Horizontal_LDPI - very_long_text, scrollbar at top:

Issue: The buttons are not on the screen. They should be fixed at the bottom-right of the screen.

--

1.6_API4_QVGA_Horizontal_LDPI - very_long_text, scrollbar at bottom:

Issue: The buttons are no where to be found, though the text scrollbar is at the bottom. They should be fixed at the bottom-right of the screen.

--

1.6_API4_QVGA_Vertical_LDPI - short_text:

Issue: The buttons should align with the bottom-right of the screen.

--

Any advice?

--

Additional Info: When I try to use RelativeLayout, and fix the buttons at the bottom of the screen with android:layout_alignParentBottom="true", then my problem is that I don't know how to fix the bottom of the scroll view with the top of the buttons. Using android:layout_alignBottom="@id/buttons" just aligns the bottom of the scroll view with the bottom of the buttons, but then the buttons overlay the text, like this:

--

Update: The problem of fixing the buttons to the bottom-right, with the scrolling text above the buttons is resolved.

Here's the changed layout XML that works so far (paste more text into text view 1 if you want to see the scrolling):

<?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">
    <ScrollView
        android:layout_width="fill_parent"
        android:layout_height="0dp"
        android:layout_weight="1">
        <LinearLayout
            android:orientation="vertical"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content">
            <TextView
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:text="Text View 1.  Text varies from a few lines to many more lines than what fits on the screen.  Scrolling is necessary to see it all." />
            <TextView
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:text="Text View 2.  Short text entry sits below Text View 1." />
        </LinearLayout>
    </ScrollView>
    <LinearLayout
        android:orientation="horizontal"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:gravity="right">
        <Button
            android:id="@+id/button_1"
            android:layout_height="fill_parent"
            android:layout_width="wrap_content"
            android:text="Button 1" />
        <Button
            android:id="@+id/button_2"
            android:layout_height="fill_parent"
            android:layout_width="wrap_content"
            android:text="Button 2" />
        <Button
            android:id="@+id/button_3"
            android:layout_height="fill_parent"
            android:layout_width="wrap_content"
            android:text="Button 3" />
        <Button
            android:id="@+id/button_4"
            android:layout_height="fill_parent"
            android:layout_width="wrap_content"
            android:text="Button 4" />
    </LinearLayout>
</LinearLayout>

I have a remaining problem for which I'll post a new question.

解决方案

Set your ScrollView's layout_height to 0dp and set its layout_weight to 1. That should push the buttons to the bottom of the screen but no further.

这篇关于滚动文字上面的扣子,按钮固定在底的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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