gpt4 book ai didi

android - RelativeLayout 或 TableLayout Android 3 按钮

转载 作者:行者123 更新时间:2023-11-29 17:30:01 25 4
gpt4 key购买 nike

我想做一些简单的事情,1 列中的 3 个按钮,响应式,就像在屏幕上一样。

我应该像在我的代码中那样在 RelativeLayout 上创建它,还是 TableLayout 更好?

如何将 RelativeLayout 链接到顶部和底部,以确保最后一个按钮永远不会超出屏幕底部?

<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
android:paddingBottom="@dimen/activity_vertical_margin"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
tools:showIn="@layout/activity_main"
tools:context=".MainActivity"
android:background="@color/green"
>
<ImageButton
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="NAGRAJ"
android:id="@+id/nagraj"
android:src="@drawable/button_sos"
android:scaleType="fitStart"
android:layout_alignParentTop="true"
android:adjustViewBounds="true"
android:background="@null"
android:layout_marginBottom="25px"
android:tag="nagraj"
/>

<ImageButton
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="112"
android:id="@+id/zadzwon"
android:layout_below="@+id/nagraj"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true"
android:src="@drawable/button_112"
android:scaleType="fitStart"
android:background="@null"
android:adjustViewBounds="true"
android:layout_marginBottom="25px"/>

<ImageButton
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="ZDJECIE"
android:id="@+id/foto"
android:layout_below="@+id/zadzwon"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true"
android:src="@drawable/button_foto"
android:scaleType="fitStart"
android:background="@null"
android:adjustViewBounds="true"
/>
</RelativeLayout>

enter image description here

最佳答案

像这样同时使用 RelativeLayout 和 LinearLayout

RelativeLayout

LinearLayout (orientation:vertical && weightsum = 3)

ImageView (weightsum = 1)

ImageView (weightsum = 1)

ImageView (weightsum = 1)

LinearLayout

Button (align to the bot of the above LinearLayout and android:layout_alignParentBottom="true")

RelativeLayout

关于android - RelativeLayout 或 TableLayout Android 3 按钮,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33350093/

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