Android XML: Multiple button layout

The layout :

Snipaste_2022-07-27_08-08-47

The xml code : 😃
(before using this code, you should create your drawable xml file for background )

<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <LinearLayout
        android:id="@+id/linearLayout_button"
        android:layout_width="362dp"
        android:layout_height="263dp"
        android:layout_gravity="center"
        android:orientation="vertical"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent">


        <Button
            android:id="@+id/button_f"
            android:layout_width="112dp"
            android:layout_height="90dp"
            android:layout_gravity="center"
            android:layout_margin="5dp"
            android:layout_weight="2"
            android:background="@drawable/button_selector"
            android:text="@string/f"
            android:textSize="20sp"
            android:textStyle="bold" />

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="90dp"
            android:gravity="center_horizontal"
            android:orientation="horizontal">

            <Button
                android:id="@+id/button_l"
                android:layout_width="wrap_content"
                android:layout_height="match_parent"
                android:layout_margin="5dp"
                android:layout_weight="2"
                android:background="@drawable/button_selector"
                android:text="@string/l"
                android:textSize="20sp"
                android:textStyle="bold" />

            <Button
                android:id="@+id/button_s"
                android:layout_width="wrap_content"
                android:layout_height="match_parent"
                android:layout_margin="5dp"
                android:layout_weight="2"
                android:background="@drawable/button_selector"
                android:text="@string/s"
                android:textColor="@android:color/holo_red_dark"
                android:textSize="20sp"
                android:textStyle="bold" />

            <Button
                android:id="@+id/button_r"
                android:layout_width="wrap_content"
                android:layout_height="match_parent"
                android:layout_margin="5dp"
                android:layout_weight="2"
                android:background="@drawable/button_selector"
                android:text="@string/r"
                android:textSize="20sp"
                android:textStyle="bold" />

        </LinearLayout>

        <Button
            android:id="@+id/button_b"
            android:layout_width="113dp"
            android:layout_height="90dp"
            android:layout_gravity="center"
            android:layout_margin="5dp"
            android:layout_weight="2"
            android:background="@drawable/button_selector"
            android:text="@string/b"
            android:textSize="20sp"
            android:textStyle="bold" />
    </LinearLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
posted @   litecdows  阅读(48)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 物流快递公司核心技术能力-地址解析分单基础技术分享
· .NET 10首个预览版发布:重大改进与新特性概览!
· 单线程的Redis速度为什么快?
· 展开说说关于C#中ORM框架的用法!
· Pantheons:用 TypeScript 打造主流大模型对话的一站式集成库
点击右上角即可分享
微信分享提示