Java Android应用程序响应能力强(适用于所有屏幕尺寸)

Java Android应用程序响应能力强(适用于所有屏幕尺寸),java,android,layout,android-linearlayout,Java,Android,Layout,Android Linearlayout,我正在开发一个安卓应用程序,它有一个按钮和图像。我需要使它具有响应性。如果我使用更大的设备,如平板电脑,它会显示非常小的控件。当我在横向模式下使用时,它显示了一半的控件或项目。我如何克服这一问题,并使我的应用程序对所有设备做出响应。我在下面附上了我的一段XML代码 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" andro

我正在开发一个安卓应用程序,它有一个按钮和图像。我需要使它具有响应性。如果我使用更大的设备,如平板电脑,它会显示非常小的控件。当我在横向模式下使用时,它显示了一半的控件或项目。我如何克服这一问题,并使我的应用程序对所有设备做出响应。我在下面附上了我的一段XML代码

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="10dp"
android:orientation="vertical" 
>

<ImageView
    android:id="@+id/imageView1"
    android:layout_width="fill_parent"
    android:layout_height="125dp"
    android:layout_marginTop="50dp"
    android:layout_weight="0.01"
    android:adjustViewBounds="true"  
    >        
</ImageView>

 <LinearLayout
    android:id="@+id/layButtonH"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:layout_weight="0.01"
    android:layout_marginTop="20dp"
    android:gravity="center"
    android:orientation="vertical" >

    <Button 
     android:id="@+id/addnew"
     android:layout_width="wrap_content"
     android:layout_height="wrap_content"
     android:text="    ADD NEW     "
     android:background="@drawable/button_shape"
     android:textColor="#FFFFFF"/>


     <Button
         android:id="@+id/open"
         android:background="@drawable/button_shape_cancel"
         android:layout_marginTop="30dp"  
         android:layout_width="wrap_content"
         android:layout_height="wrap_content"
         android:text="        OPEN         "
         android:textColor="#FFFFFF" />
     <Button
         android:id="@+id/Register"
         android:background="@drawable/button_shape_cancel"
         android:layout_marginTop="30dp"  
         android:layout_width="wrap_content"
         android:layout_height="wrap_content"
         android:text="       LOGIN        "
         android:textColor="#FFFFFF" />


 </LinearLayout>


用于响应性设计 1) 不要给出像125dp这样的硬代码值,而不是用户包装内容或匹配父属性 2) 根据分辨率将图像置于res drawable下操作系统拍摄适合其分辨率的图像,例如,对于平板电脑设计,在res下创建drawable-sw600文件夹,并将平板电脑图像置于其下。 3) 值相同->维度创建具有特定文件夹名称的不同维度文件。e、 g值——用于平板电脑的sw600 4) 使用ScrollView控件避免在横向模式下进行屏幕切割。
有关更多详细信息和指南,请访问,您可以从下面提到的资源开始。在设计和开发应用程序时,需要考虑使应用程序适用于所有屏幕大小

您必须处理图像,使其与不同的屏幕大小保持一致。这将解决平板电脑中非常小的控件的问题

此外,在横向模式下,您的小部件似乎超出了屏幕高度。一个快速的解决方案是将
线性布局
放在
滚动视图
中,这样它在横向中滚动,您可以看到所有控件。但理想的方法是为横向和纵向模式设置不同的布局

如果使用ScrolLView,代码如下所示:

<?xml version="1.0" encoding="utf-8"?>
<ScrollView
    android:layout_height="match_parent"
    android:layout_width="match_parent"
    xmlns:android="http://schemas.android.com/apk/res/android">

<!-- Your remaining xml elements -->

</ScrollView>

参考: