简体   繁体   English

尽管屏幕不同,如何使视图覆盖屏幕

[英]How to make a view to cover your screen despite different screens

I have one layout in which there is one relative layout inside main layout.This layout is displayed in center of the main layout.In some device it is covering most part(having some widgets above and below it).I tested it with different emulators.In some mulator it is not covering that much are.I want it should cover same portion in every screen(ie in every emulator).Can i use Layout:weight ? 我有一个布局,其中在主布局内部有一个相对布局。此布局显示在主布局的中心。在某些设备中,它覆盖了大部分(上面和下面都有一些小部件)。我用不同的模拟器对其进行了测试在某些模拟器中,它覆盖的范围不是很多。我希望它在每个屏幕(即每个模拟器)中覆盖相同的部分。我可以使用Layout:weight吗? any better idea ? 还有更好的主意吗?

<LinearLayout
  xmlns:android="http://schemas.android.com/apk/res/android" 
  style="@style/ViewScreenTheme"
  android:orientation="vertical"
  android:background="@drawable/background"
  android:layout_width="fill_parent"
  android:layout_height="fill_parent">

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
  android:orientation="vertical"
  android:layout_width="fill_parent"
  android:layout_height="fill_parent">
  <RelativeLayout android:id="@+id/header" 
    android:orientation="horizontal"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:gravity="center_horizontal"
    android:paddingTop="10dp"
    android:paddingBottom="10dp">

    <Button android:id="@+id/help_button" 
      android:layout_alignParentRight="true"
      style="@style/ButtonText"
      android:layout_margin="1dp"
      android:layout_height="wrap_content" 
      android:layout_width="wrap_content"
      android:background="@drawable/help_button"
      android:paddingLeft="10px"
      android:paddingRight="10px"
      android:layout_marginRight="10px"/>
  </RelativeLayout>
  <RelativeLayout android:id="@+id/root" 
    android:orientation="horizontal"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:gravity="center_horizontal"
    android:layout_below="@+id/header"
    android:layout_marginTop="2dp"
    android:layout_marginBottom="0dp"
    android:paddingTop="10dp"
    android:paddingBottom="10dp">
    <RelativeLayout
      android:orientation="vertical"
      android:layout_width="fill_parent"
      android:layout_height="384dp"
      android:background="#0fff"
      android:id="@+id/canvas_layout">
    </RelativeLayout>
  </RelativeLayout>
</RelativeLayout>
</LinearLayout>

I want canvas_layout which is last relative layout to cover some part in every screen. 我希望canvas_layout是最后一个相对布局,以覆盖每个屏幕的某些部分。

In my opinion the best way to deal with screen sizes (if I understand correctly your question) is to use the resource qualifier to provide resources. 我认为处理屏幕尺寸的最佳方法(如果我对您的问题理解正确的话)是使用资源限定符提供资源。 You can find some guideline here . 您可以在此处找到一些指南。

You, then, have to specify the varoius layout for the sizes you will need. 然后,您必须为所需的尺寸指定varoius布局。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM