Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/xml/13.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 在不同屏幕上固定按钮位置_Android_Xml_Android Studio_Android Layout - Fatal编程技术网

Android 在不同屏幕上固定按钮位置

Android 在不同屏幕上固定按钮位置,android,xml,android-studio,android-layout,Android,Xml,Android Studio,Android Layout,如何使0-9按钮不在不同屏幕上移动?我希望它在不同屏幕上的固定位置 您可以使用两种不同的方式制作版面:一种是使用xml,另一种是使用程序文件。在xml中,您可以在一个线性版面中拍摄所有图像和版面,并将该版面划分为“版面权重”=“数字” 如果您必须在一行中显示两个图像,则采取 给定宽度以匹配父级和布局\权重=1给定宽度以匹配父级和布局\权重=1 //在图像中,如果您想在全屏上显示布局,请将宽度指定为matchParent,否则可以将布局宽度指定为wrapContent 检查此代码 <Lin

如何使0-9按钮不在不同屏幕上移动?我希望它在不同屏幕上的固定位置


您可以使用两种不同的方式制作版面:一种是使用xml,另一种是使用程序文件。在xml中,您可以在一个线性版面中拍摄所有图像和版面,并将该版面划分为“版面权重”=“数字”

如果您必须在一行中显示两个图像,则采取

给定宽度以匹配父级和布局\权重=1给定宽度以匹配父级和布局\权重=1

//在图像中,如果您想在全屏上显示布局,请将宽度指定为matchParent,否则可以将布局宽度指定为wrapContent

检查此代码

<LinearLayout
    android:layout_width="fill_parent"
    android:layout_height="wrap_content">

<Button
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:layout_weight="1"
    android:text="1" />

<Button
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:layout_weight="3"
    android:text="2" />

<Button
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:layout_weight="1"
    android:text="3" />

</LinearLayout>


post your layout xml看看这个库,如果我们想要的大小是14dp,那么就使用大小-2.12以获得更好的效果。@Atifabasi哇,谢谢!它并不完美,但很有效!