简体   繁体   English

布局不支持所有屏幕

[英]Layout not supporting in all screens

I am new to android , i am developing registration screen I have used scroll view to support in smaller screens, but when it comes to larger screens 7 inches layout is not fitting . 我是android的新手,正在开发注册屏幕,我已经使用滚动视图在较小的屏幕中支持,但是在较大的屏幕上,7英寸的布局不适合。

I don't know how to make this layout fit in all screens such that in small screens it should be scrollable I have searched in internet but it is of no use, so please help me on how to make my screen adaptable to all screens of android.` Here is the code i am using: 我不知道如何使这种布局适合所有屏幕,因此在小屏幕上应该可以滚动浏览,但是我没有用,所以请帮助我如何使我的屏幕适合所有屏幕。 android.`这是我正在使用的代码:

` `

<LinearLayout
    android:id="@+id/LinearLayout1"
    android:layout_width="match_parent"
    android:layout_height="338dp"
    android:orientation="vertical"
    android:padding="20dp" >

    <EditText
        android:hint="@string/phoneno"
        android:id="@+id/usr_reg_et_phoneno"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:background="@drawable/style_edittext"
        android:textAppearance="?android:attr/textAppearanceSmall" >
        <requestFocus />
    </EditText>

    <EditText
        android:id="@+id/usr_reg_et_name"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginTop="10dp"
        android:ems="10"
        android:hint="@string/name"
        android:inputType="textPersonName"
        android:background="@drawable/style_edittext"
        android:textAppearance="?android:attr/textAppearanceSmall" >

    </EditText>

    <EditText
        android:id="@+id/usr_reg_et_email"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginTop="10dp"
        android:ems="10"
        android:hint="@string/email"
        android:inputType="textEmailAddress"
        android:background="@drawable/style_edittext"
        android:textAppearance="?android:attr/textAppearanceSmall" />

    <EditText
        android:id="@+id/usr_reg_et_pwd"
        android:hint="@string/password"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginTop="10dp"
        android:ems="10"
        android:inputType="textPassword"
        android:background="@drawable/style_edittext"
        android:textAppearance="?android:attr/textAppearanceSmall" />

    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_marginTop="10dp"
        android:layout_weight="0.22" >

        <ToggleButton
            android:id="@+id/toggle_gender"
            android:layout_width="60dp"
            android:layout_height="40dp"
            android:layout_alignParentTop="true"
            android:layout_centerHorizontal="true"
            android:background="@drawable/gender_check"
            android:focusable="false"
            android:focusableInTouchMode="false" 
            android:checked="true"/>

        <TextView
            android:id="@+id/textView2"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignBaseline="@+id/toggle_gender"
            android:layout_alignBottom="@+id/toggle_gender"
            android:layout_alignParentLeft="true"
            android:layout_marginLeft="18dp"
            android:text="@string/gender"
            android:textAppearance="?android:attr/textAppearanceSmall"
            android:textColor="#818080" />

        <ToggleButton
            android:layout_marginTop="8dp"
            android:id="@+id/toggle_user"
            android:layout_width="60dp"
            android:layout_height="40dp"
            android:layout_alignLeft="@+id/toggle_gender"
            android:layout_below="@+id/toggle_gender"
            android:background="@drawable/user_check"
            android:focusable="false"
            android:focusableInTouchMode="false" />

        <TextView
            android:id="@+id/login_et_phoneno"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignBaseline="@+id/toggle_user"
            android:layout_alignBottom="@+id/toggle_user"
            android:layout_alignLeft="@+id/textView2"
            android:text="@string/role"
            android:textAppearance="?android:attr/textAppearanceSmall"
            android:textColor="#818080" />

    </RelativeLayout>

    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content" >

        <TextView
            android:id="@+id/textview1"
            android:layout_width="250dp"
            android:layout_height="100dp"
            android:layout_alignParentLeft="true"
            android:layout_alignParentRight="true"
            android:layout_alignParentTop="true"
            android:layout_margin="10dp"
            android:text="@string/tc"
            android:textAppearance="?android:attr/textAppearanceSmall" />

<ProgressBar
    android:id="@+id/progressBar1"
    android:visibility="gone"
    android:background="@drawable/radar"
    android:indeterminateDrawable="@drawable/progressbar3" 
    android:minHeight="48dp"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentBottom="true"
    android:layout_centerHorizontal="true"
    android:layout_marginBottom="100dp" />

<Button
    android:id="@+id/usr_reg_bt_register"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:layout_alignBottom="@+id/textview1"
    android:layout_alignParentLeft="true"
    android:textColor="#ffffff"
    android:background="@drawable/style_button"
    android:text="@string/register" />

<TextView
    android:id="@+id/usr_reg_tv_tc"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_above="@+id/usr_reg_bt_register"
    android:layout_alignRight="@+id/textview1"
    android:layout_marginBottom="17dp"
    android:layout_marginRight="48dp"
    android:text="@string/tclink"
    android:textAppearance="?android:attr/textAppearanceSmall"
    android:textColor="#336600" />

    </RelativeLayout>
</LinearLayout>

` `

Please refer these link: 请参考以下链接:

http://developer.android.com/guide/practices/screens_support.html http://developer.android.com/guide/practices/screens_support.html

For Different screen size, The following is a list of resource directories in an application that provides different layout designs for different screen sizes and different bitmap drawables for small, medium, high, and extra high density screens.You still need to edit the layout resource to fit better 对于不同的屏幕尺寸,以下是应用程序中的资源目录列表,该应用程序为不同的屏幕尺寸提供了不同的布局设计,并为小,中,高和超高密度屏幕提供了不同的位图可绘制对象。您仍然需要编辑布局资源更好地适合

res/layout/my_layout.xml             // layout for normal screen size ("default")
  res/layout-small/my_layout.xml       // layout for small screen size
  res/layout-large/my_layout.xml       // layout for large screen size
  res/layout-xlarge/my_layout.xml      // layout for extra large screen size
  res/layout-xlarge-land/my_layout.xml // layout for extra large in landscape orientation

  res/drawable-mdpi/my_icon.png        // bitmap for medium density
  res/drawable-hdpi/my_icon.png        // bitmap for high density
  res/drawable-xhdpi/my_icon.png       // bitmap for extra high density

The following code in the Manifest supports all dpis. 清单中的以下代码支持所有dpi。

<supports-screens android:smallScreens="true" 
      android:normalScreens="true" 
      android:largeScreens="true"
      android:xlargeScreens="true"
      android:anyDensity="true" />

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

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