gpt4 book ai didi

android - Android应用程序中图像按钮的UI问题

转载 作者:行者123 更新时间:2023-11-30 04:37:36 24 4
gpt4 key购买 nike

在我的应用程序中,我在页面底部放置了 4 个图像按钮。但根据我的布局,图像在每个设备上看起来都不同。我希望图像在所有设备中都相同。

下面是我的图片按钮的布局

 <LinearLayout android:layout_height="wrap_content" android:id="@+id/tabLayout" android:layout_width="match_parent" 
android:background="@drawable/tab_bar" android:orientation="horizontal" android:layout_weight="0.1">
<RelativeLayout android:id="@+id/relativeLayout1" android:layout_height="match_parent" android:layout_width="match_parent">
<ImageButton android:layout_marginLeft="35dip" android:layout_height="wrap_content" android:id="@+id/homeBtn" android:background="@drawable/home" android:layout_width="wrap_content" android:layout_gravity="center"></ImageButton>
<ImageButton android:layout_marginLeft="35dip" android:layout_toRightOf="@+id/homeBtn" android:layout_height="wrap_content" android:id="@+id/addBtn" android:background="@drawable/add" android:layout_width="wrap_content" android:layout_gravity="center"></ImageButton>
<ImageButton android:layout_marginLeft="35dip" android:layout_toRightOf="@+id/addBtn" android:layout_height="wrap_content" android:id="@+id/srchBtn" android:background="@drawable/search" android:layout_width="wrap_content" android:layout_gravity="center"></ImageButton>
<ImageButton android:layout_marginLeft="35dip" android:layout_toRightOf="@+id/srchBtn" android:layout_height="wrap_content" android:id="@+id/helpBtn" android:background="@drawable/help" android:layout_width="wrap_content" android:layout_gravity="center"></ImageButton>
</RelativeLayout>

以下是我的布局图像。我希望我的布局与 image1 中的一样,而 image2 是我目前正在获取的图像。

enter image description here

如何在所有 Android 设备中获得与图像 1 一样的效果。请帮助我的 friend

最佳答案

正如其他人提到的最好使用线性布局,但您还需要做的是为线性布局提供填充,我猜 5dp 应该看起来不错。

这是它的样子:

enter image description here

下面是相同的代码

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent" android:orientation="horizontal"
android:padding="5dp" android:background="#a0a0a0"
android:layout_height="wrap_content">
<Button android:text="Button" android:id="@+id/button2"
android:layout_width="0dp" android:layout_weight="1"
android:layout_height="wrap_content"></Button>
<Button android:text="Button" android:id="@+id/button1"
android:layout_width="0dp" android:layout_weight="1"
android:layout_height="wrap_content"></Button>
<Button android:text="Button" android:id="@+id/button3"
android:layout_width="0dp" android:layout_weight="1"
android:layout_height="wrap_content"></Button>
<Button android:text="Button" android:id="@+id/button4"
android:layout_width="0dp" android:layout_weight="1"
android:layout_height="wrap_content"></Button>

</LinearLayout>

关于android - Android应用程序中图像按钮的UI问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6580238/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com