如何制作初始屏幕以适应每个移动屏幕或支持多屏幕

时间:2016-04-13 08:48:44

标签: android

我正在开发一个Android项目。我的第一个屏幕包含一个图像视图和三个文本视图当移动设备垂直放置时,如果移动设备水平放置,则一切都清晰可见,然后一些文本视图不可见如何使我的应用程序适合屏幕并支持所有位置(垂直/水平)。 this is the screen shot 谢谢。

3 个答案:

答案 0 :(得分:0)

您需要在布局中添加ScrollView。在横向中,屏幕高度会降低,因此显示较小的区域以显示元素。

ScrollView将为您管理所有事情。如果可用空间小于所需空间,则不显示滚动条。

答案 1 :(得分:0)

如果您确定它适合任何屏幕尺寸,请考虑使用RelativeLayout,您可以随时说明它需要在屏幕上对齐的位置。当然,如果它可以溢出而不是使用Scrollview是一个更安全的选择。

答案 2 :(得分:0)

您可以使用滚动视图来适应屏幕的长度,也可以使用PercentRelativeLayout。

如何使用滚动视图:

<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:fillViewport="true">
    <TableLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:stretchColumns="1">

        <--yourcodehere-->

        </TableLayout>
</ScrollView>

将此添加到您的gradle以使用PercentRelativeLayout:

compile 'com.android.support:percent:23.2.0'

然后你可以像这样使用它:

<Button
    android:text="@string/Tesksten"
    android:id="@+id/btContent"
    android:layout_below="@+id/searchView"
    android:drawableTop="@drawable/ic_menu"
    android:layout_width="0dp"
    android:layout_height="0dp"
    app:layout_heightPercent="16%"
    app:layout_widthPercent="100%"
    android:padding="10dp"
    android:textColor="#000000"
    android:background="#f0f0f0"
    android:textStyle="bold"
    android:alpha="0.65"
    android:layout_marginBottom="10dp"/>

现在这个按钮的外观如下,请注意有更多行可以获取我的特定布局,如果需要可以删除。确保你把宽度和高度设置为0,然后使用百分比,我有一些问题,一开始就搞清楚。古德勒克:

Example

或者,如果您想完全关闭屏幕旋转,请将此添加到您不希望旋转的清单活动中:

android:screenOrientation="portrait"
相关问题