Android XML: Multiple button layout
The layout :
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>
本文来自博客园,作者:litecdows,作者在其他博客平台均使用此昵称!
转载请注明原文链接:https://www.cnblogs.com/litecdows/p/16523386.html
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 物流快递公司核心技术能力-地址解析分单基础技术分享
· .NET 10首个预览版发布:重大改进与新特性概览!
· 单线程的Redis速度为什么快?
· 展开说说关于C#中ORM框架的用法!
· Pantheons:用 TypeScript 打造主流大模型对话的一站式集成库