Android如何在所有分辨率的布局中设置按钮

萨钦c

我已在10.1“分辨率的线性布局中设置按钮为1280x800,其设置正确,但未为7”分辨率1024x600设置。有人可以建议如何为所有分辨率设置此按钮吗?

这是我的xml文件设置背景:

<?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" 
android:background="@drawable/kids">

 <Button
    android:id="@+id/kids_first"
    android:layout_width="120dp"
    android:layout_height="120dp"
    android:text="Button"
    android:layout_gravity="right" />

<Button
    android:id="@+id/kids_second"
    android:layout_width="120dp"
    android:layout_height="120dp"
    android:text="Button" 
    android:layout_gravity="right"
    android:layout_marginTop="240dp"/>

<Button
    android:id="@+id/kids_third"
    android:layout_width="120dp"
    android:layout_height="120dp"
    android:text="Button" 
    android:layout_gravity="center"
    android:layout_marginLeft="10dp"
    android:layout_marginTop="-110dp"/>

</LinearLayout>
啦啦队

使用此代码进行布局

<?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"
android:weightSum="1" >

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="0dp"
    android:layout_weight="0.6"
    android:gravity="right" >

    <Button
        android:id="@+id/kids_first"
        android:layout_width="120dp"
        android:layout_height="120dp"
        android:text="Button" />
</LinearLayout>

<FrameLayout
    android:layout_width="match_parent"
    android:layout_height="0dp"
    android:layout_weight="0.4" >

    <Button
        android:id="@+id/kids_second"
        android:layout_width="120dp"
        android:layout_height="120dp"
        android:layout_gravity="right"
        android:text="Button" />

    <Button
        android:id="@+id/kids_third"
        android:layout_width="120dp"
        android:layout_height="120dp"
        android:layout_gravity="center_horizontal"
        android:text="Button" />
</FrameLayout>

</LinearLayout>

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章

如何在所有屏幕分辨率下测试自适应设计?

如何在多显示器设置中获取所有显示器的尺寸(分辨率)

按钮不会在所有分辨率上向左对齐

在所有分辨率下全屏设置“视频宽度”和“高度”

如何在Debian中设置登录屏幕分辨率

将模态放置在所有分辨率的底部

如何在python中获得我所有系统支持的屏幕分辨率

如何使背景图像的位置在所有分辨率上保持不变?

如何在Android Studio的布局编辑器中使用自定义分辨率?

如何在VMware Player中在Android-x86上设置自定义分辨率

Android 所有分辨率的通用高度和宽度

如何在不同分辨率的一行中对齐文本和按钮

如何为所有分辨率制作全屏图像

如何使所有分辨率的右侧边距相等?

我如何从高分辨率图像android获取所有dpi图像

为什么Android总是在APK下载和安装中包含所有分辨率?

如何在igraph中为Louvain模块化设置分辨率参数?

如何在笔记本中设置最大分辨率?

如何在Debian上的xfce中设置持久分辨率

如何在Mac上的R中设置png的分辨率

窗口在所有分辨率下滚动到页脚时的事件 - jquery

密度像素(dp)在所有分辨率下均无法正常工作

如何自动调整网格中内容的大小,使其适合所有分辨率

使网页适合所有分辨率

如何在具有良好分辨率的Excel图表中插入MathType方程?

Android Things:设置屏幕分辨率

设备屏幕分辨率如何在CSS中缩放?

如何在Java中获得屏幕分辨率?

如何在Sketchup中更改圆的分辨率