如何设置我的Andr​​oid布局中的所有设备?我的、布局、如何设置、设备

2023-09-03 22:37:10 作者:寂寞的诱惑

我写一个应用程序,它只能在中小型设备的设置,不能适合在平板电脑这不是看起来很不错。我如何能在所有设备配合我的应用程序的布局提高了我的用户界面。

I write an app which only can set in small and medium devices and can't fit in tablet which is not looking good. How can I improve my UI by fitting my app layout in all devices.

下面是我的布局codeI正在提交唯一一个布局(XML code),这样我可以按照相同的步骤,以在app.Please其他屏幕帮助我。

Here is my layout code.I am submitting only one layout (xml code) so that i can follow the same procedure to other screens in app.Please help me.

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context="info.taramt.com.tmtsars.HomeScreen$PlaceholderFragment" 
android:background="@drawable/android">

  <TextView
      android:id="@+id/name"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:layout_alignParentTop="true"
      android:layout_marginBottom="15dp"
      android:layout_marginLeft="20dp"
      android:layout_marginTop="5dp"
      android:layout_toRightOf="@+id/profilePic"
      android:textSize="20sp"
      android:maxLines="1"
      android:text="Name" />

  <TextView
      android:id="@+id/email"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:layout_below="@+id/name"
      android:layout_alignLeft="@+id/name"
      android:layout_alignBaseline="@+id/profilePic"
      android:textSize="15sp"
      android:text="Email" />

  <TextView android:id="@+id/date"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:layout_marginTop="5dp"
      android:layout_below="@+id/email"
      android:layout_alignLeft="@+id/name"
      android:textSize="15sp"
      />

  <ImageView
      android:id="@+id/profilePic"
      android:layout_width="120dp"
      android:layout_height="120dp"
      android:layout_alignParentLeft="true"
      android:layout_alignParentTop="true"
      android:adjustViewBounds="true"
       />

  <TextView
      android:id="@+id/hours"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:layout_below="@+id/profilePic"
      android:layout_centerHorizontal="true"
      android:layout_centerVertical="true"
      android:layout_gravity="center"
      android:layout_marginTop="30dp"
      android:text="Time Log"
      android:textSize="20sp" />

<Chronometer 
    android:format="%s"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"

    android:layout_margin="10dp"
    android:padding="2dp"
    android:id="@+id/timer"
    android:textSize="80sp"
  android:gravity="center"
    android:background="@drawable/round_rect"
    android:layout_gravity="center"
     android:layout_below="@+id/hours"
       android:layout_centerHorizontal="true"
            android:layout_centerVertical="true"    
     />
<TextView android:id="@+id/fetchInfo"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_gravity="center"
    android:textSize="20sp"
    android:layout_below="@+id/timer"
    android:layout_marginTop="30dp"
    android:layout_centerHorizontal="true"
    android:layout_centerVertical="true"

    />

推荐答案

将在项目中的/ res文件夹下的文件夹的main.xml中的布局。

Put your main.xml layout in following folders in the /res folder of your project.

1) main.xml in layout

2) main.xml in layout-large

3) main.xml in layout-small

4) main.xml in layout-xlarge

请注意:只有名称必须是相同的,但里面的内容可以是不同的。

Note: only name must be same, but inside content can be different.