的LinearLayout水平超过小屏幕 [英] LinearLayout horizontal exceeds small screen

查看:841
本文介绍了的LinearLayout水平超过小屏幕的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有两个DatePickers,相映成趣。
它的工作原理很好的大屏幕上,但是当我在较小的设备上运行我的应用程序,我只看到第一个,其他的将被截断。

我想在第一个底部的第二的DatePicker被淹没时,有屏幕上没有足够的空间。

是否有可能避免编程方式并做到这一点在XML文件中?

这是我的code的片段。它嵌套在另一个LinearLayout中。

 <的LinearLayout
        机器人:layout_width =FILL_PARENT
        机器人:layout_height =FILL_PARENT
        机器人:方向=横向>        <的DatePicker
            机器人:ID =@ + ID / DATE_START
            机器人:layout_width =WRAP_CONTENT
            机器人:layout_height =WRAP_CONTENT
            机器人:calendarViewShown =FALSE/>        <的DatePicker
            机器人:ID =@ + ID / DATE_END
            机器人:layout_width =WRAP_CONTENT
            机器人:layout_height =WRAP_CONTENT
            机器人:calendarViewShown =FALSE/>
    < / LinearLayout中>


解决方案

您可以创建一个文件夹布局大 RES 和移动这个code那里。然后你可以改变这个code是你想怎么一个较小的屏幕上。当大屏幕的应用程序将使用布局大,并使用布局文件夹时,在较小的屏幕。

您将只需要改变这个code使用的垂直定位,也许调整部分这取决于它的外观在小屏幕上的其他属性。

使用布局预选赛

只是一个供参考,的LinearLayout 有一个定位 横向默认情况下,这样不需要财产,但不伤害,无论是。我只是想指出这一点,因为它可能在未来需要了解的。

I have two DatePickers, side by side. It works good on larger screen, but when I run my application on smaller devices, I only see the first one, the other is truncated.

I'd like the second DatePicker being drown at the bottom of the first one when there's no enough space on the screen.

Is it possible avoiding programmatically ways and do it in the XML file?

This is the fragment of my code. It's nested in another LinearLayout.

<LinearLayout
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:orientation="horizontal" >

        <DatePicker
            android:id="@+id/date_start"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:calendarViewShown="false" />

        <DatePicker
            android:id="@+id/date_end"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:calendarViewShown="false" />
    </LinearLayout>

解决方案

You can create a folder layout-large in res and move this code there. Then you can change this code to be how you want on a smaller screen. When on larger screens your app will use the layout-large and use the layout folder when on smaller screens

You would simply need to change this code to use an orientation of vertical and maybe adjust some other properties depending on how it will look on smaller screens.

Using Layout qualifiers

Just an FYI, LinearLayout has an orientation of horizontal by default so that property isn't needed but doesn't hurt, either. I just like to point that out because it may be useful to know in the future.

这篇关于的LinearLayout水平超过小屏幕的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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