我有一些垂直列出的开关。但我不知道如何调整它们。我可以使用约束在一台设备上手动对齐右边界,但是当我更换设备时,它们不会再次对齐。
===================更改设备后下面的结果不好===============
那么我怎样才能将第一张图像作为我使用的设备实现?
答案 0 :(得分:0)
You would better use below properties for supporting better alignments in any device
android:layout_alignStart="@id/aboveItem"
android:layout_below="@id/aboveItem"
Example:
@+id/dispcount is already having absolute position which is First Item.
<Button
android:id="@+id/btnstart"
android:layout_width="wrap_content"
android:layout_height="50dp"
android:text="@string/btnStart"
android:visibility="visible"
android:layout_below="@id/dispcount"
android:layout_alignStart="@id/dispcount"
/>
<Button
android:id="@+id/stop"
android:layout_width="wrap_content"
android:layout_height="50dp"
android:text="@string/btnStop"
android:visibility="visible"
android:layout_below="@id/btnstart"
android:layout_alignStart="@id/btnstart"
/>
Above Example display vertically same alignment. Here example type is button, in your case its switch. xml attributes applies same for all alignments. take your own width & height.
通过添加类似于您的xml文件,它将自动调整所有设备。