Android 我怎样才能开始实施这个屏幕设计?需要屏幕兼容性

Android 我怎样才能开始实施这个屏幕设计?需要屏幕兼容性,android,android-layout,android-constraintlayout,Android,Android Layout,Android Constraintlayout,我想在我的android应用程序中实现如下所示的屏幕设计。我已经想出了这个设计,它在我的手机和宽度大于480dp的设备上看起来不错。然而,我希望能够在更小的屏幕上产生类似的结果。我已经尝试过使用layout-sw480dp进行此操作。让我困惑的是,我如何能够在不使用硬编码尺寸值的情况下为LinearLayouts的宽度和高度生成类似的结果 我是如何实现屏幕的,我基本上在dp中创建了五个固定宽度和高度值的LinearLayout,并使用ConstraintLayout作为根布局,以屏幕大小的50%

我想在我的android应用程序中实现如下所示的屏幕设计。我已经想出了这个设计,它在我的手机和宽度大于
480dp
的设备上看起来不错。然而,我希望能够在更小的屏幕上产生类似的结果。我已经尝试过使用
layout-sw480dp
进行此操作。让我困惑的是,我如何能够在不使用硬编码尺寸值的情况下为
LinearLayout
s的宽度和高度生成类似的结果

我是如何实现屏幕的,我基本上在
dp
中创建了五个固定宽度和高度值的
LinearLayout
,并使用
ConstraintLayout
作为根布局,以屏幕大小的50%创建
ConstraintGuide
(垂直),然后,我将前两个
LinearLayout
s约束到该导向线的左侧和右侧

我还在60%的屏幕上使用了一个
ConstraintGuide
(水平),并将前两个布局约束在该准则之上,其余三个布局约束在该准则之下。我还以水平链样式约束了三个
Linearlayout
s

另一个复杂性是
LinearLayout
s中的
TextView
s不在一行中。第一个
TextView
有两行

我将如何在考虑到屏幕兼容性的情况下实施这个屏幕设计,并紧跟设计


你在找这样的东西吗

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

 <LinearLayout
     android:orientation="vertical"
     android:layout_width="match_parent"
     android:layout_height="match_parent">

     <!--- First pink half -->
     <LinearLayout
         android:layout_width="match_parent"
         android:background="#ff00ff"
         android:layout_height="match_parent"
         android:layout_weight="1">
     </LinearLayout>

     <!--- Second half -->
     <LinearLayout
         android:orientation="vertical"
         android:layout_width="match_parent"
         android:layout_height="match_parent"
         android:layout_weight="1">

         <!--- Layout for 2 Buttons -->
         <LinearLayout
             android:layout_width="match_parent"
             android:layout_height="match_parent"
             android:layout_weight="1"
             android:gravity="center"
             android:background="#00ffff"
             android:orientation="horizontal">
             <LinearLayout
                 android:layout_width="wrap_content"
                 android:layout_height="wrap_content"
                 android:orientation="horizontal">
                 <Button
                 android:layout_width="wrap_content"
                 android:layout_height="wrap_content"
                 android:text="Button1"/>
                 <Button
                     android:layout_width="wrap_content"
                     android:layout_height="wrap_content"
                     android:text="Button2"/>
             </LinearLayout>
         </LinearLayout>

         <!--- Layout for 3 Buttons -->
         <LinearLayout
             android:layout_width="match_parent"
             android:layout_height="match_parent"
             android:layout_weight="1"
             android:gravity="center"
             android:background="#0000ff"
             android:orientation="horizontal">
             <LinearLayout
                 android:layout_width="wrap_content"
                 android:layout_height="wrap_content"
                 android:orientation="horizontal">
                 <Button
                     android:layout_width="wrap_content"
                     android:layout_height="wrap_content"
                     android:text="Button3"/>
                 <Button
                     android:layout_width="wrap_content"
                     android:layout_height="wrap_content"
                     android:text="Button4"/>
                 <Button
                     android:layout_width="wrap_content"
                     android:layout_height="wrap_content"
                     android:text="Button5"/>
             </LinearLayout>
         </LinearLayout>

         <!--- Layout for round Button -->
         <LinearLayout
             android:layout_width="match_parent"
             android:layout_height="match_parent"
             android:layout_weight="1"
             android:gravity="center"
             android:background="#00ff00"
             android:orientation="horizontal">
             <Button
                 android:layout_width="wrap_content"
                 android:layout_height="wrap_content"
                 android:text="Round Button"/>
         </LinearLayout>
     </LinearLayout>
 </LinearLayout>
</LinearLayout>

结果如下所示:


是的,类似于此,但是
按钮上的文本长度不同。有些文字有两行。另外,如果后半部分的三个按钮不适合宽度,我认为第三个
线性布局的高度会增加,这不是必需的功能。您可以在单独的layout.xml文件中设计按钮布局,并添加clickable=true属性。而不是在@K.Dexter的答案中包含布局,而不是按钮。当然,按钮应该只作为您设计的按钮的占位符,而这些按钮(正如Johannes所提到的)应该设计在额外的布局中。对于设计两行的按钮:这两个字符串分别用于第1行和第2行,或者这仅仅是一个字符串,而您使用了一个文本视图和多行?