gpt4 book ai didi

android - 如何在 Android 中将三个 imageview 按钮放在同一行

转载 作者:太空宇宙 更新时间:2023-11-03 11:32:03 24 4
gpt4 key购买 nike

我有三个 imageViews 我想将所有这些 ImageView 设置为一行。我在下面粘贴了我当前的 xml 代码。

    <RelativeLayout
android:id="@+id/myFragement"
android:layout_width="wrap_content"
android:layout_height="306dp"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_marginTop="44dp"
android:layout_weight="1.77"
android:orientation="horizontal" >
</RelativeLayout>

<ImageView
android:id="@+id/login_button"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:src="@drawable/login_non_click" />

<ImageView
android:id="@+id/comapre_now_button"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:src="@drawable/compare_now_non_click_state" />

<ImageView
android:id="@+id/search_button"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="@+id/comapre_now_button"
android:src="@drawable/search_non_click" />

</RelativeLayout>

在我爱过之后。发布了我的应用程序图片,我认为这对所有人都有帮助 After editing i have posted my App's image i think this is helpful

编辑后,我发布了我的应用程序的所有 Xml 代码,我认为这对所有人都有帮助。

<RelativeLayout
android:id="@+id/myFragement"
android:layout_width="wrap_content"
android:layout_height="306dp"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:layout_marginTop="44dp"
android:layout_weight="1.77"
android:orientation="horizontal" >

</RelativeLayout>

<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:orientation="horizontal"
android:weightSum="3" >
<ImageView
android:id="@+id/login_button"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"

android:src="@drawable/login_non_click" />

<ImageView
android:id="@+id/comapre_now_button"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:src="@drawable/compare_now_non_click_state" />

<ImageView
android:id="@+id/search_button"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:src="@drawable/search_non_click" />

</LinearLayout>

最佳答案

像下面这样尝试,将 ImageView 放在内部 LinearLayout 中,水平方向 :

     <LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:orientation="horizontal"
android:weightSum="3" >
<ImageView
android:id="@+id/login_button"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:src="@drawable/login_non_click" />
<ImageView
android:id="@+id/comapre_now_button"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:src="@drawable/compare_now_non_click_state" />
<ImageView
android:id="@+id/search_button"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:src="@drawable/search_non_click" />
</LinearLayout>

关于android - 如何在 Android 中将三个 imageview 按钮放在同一行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21964415/

24 4 0