Android studio 4 全屏按钮 [英] Android studio 4 Button on full screen

查看:28
本文介绍了Android studio 4 全屏按钮的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是android studio的初学者,谁能告诉我如何设计4个按钮覆盖整个屏幕

I was beginner in android studio, Can anyone show me the way how to design 4 button cover all the screen

推荐答案

尝试使用 ConstraintLayout

Try this using ConstraintLayout

<?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"
    android:orientation="vertical">

    <ImageView
        android:id="@+id/imgOne"
        android:layout_width="0dp"
        android:layout_height="0dp"
        android:background="@color/colorPrimary"
        app:layout_constraintBottom_toTopOf="@+id/imgThree"
        app:layout_constraintEnd_toStartOf="@id/imgTwo"
        app:layout_constraintHorizontal_bias="0.5"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent" />

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:padding="10dp"
        android:text="NEW ITEM"
        android:textColor="@color/colorBlack"
        app:layout_constraintBottom_toBottomOf="@id/imgOne"
        app:layout_constraintEnd_toStartOf="@id/imgTwo"
        app:layout_constraintStart_toStartOf="parent" />

    <ImageView
        android:id="@+id/imgTwo"
        android:layout_width="0dp"
        android:layout_height="0dp"
        android:background="@color/colorblue"
        app:layout_constraintBottom_toTopOf="@+id/imgFour"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintHorizontal_bias="0.5"
        app:layout_constraintStart_toEndOf="@id/imgOne"
        app:layout_constraintTop_toTopOf="parent" />

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:padding="10dp"
        android:text="NEW ITEM"
        android:textColor="@color/colorBlack"
        app:layout_constraintBottom_toBottomOf="@id/imgTwo"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="@id/imgTwo" />

    <ImageView
        android:id="@+id/imgThree"
        android:layout_width="0dp"
        android:layout_height="0dp"
        android:background="@color/colorGreen"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toStartOf="@id/imgTwo"
        app:layout_constraintHorizontal_bias="0.5"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toBottomOf="@+id/imgOne" />

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:padding="10dp"
        android:text="NEW ITEM"
        android:textColor="@color/colorBlack"
        app:layout_constraintBottom_toBottomOf="@id/imgThree"
        app:layout_constraintEnd_toStartOf="@id/imgFour"
        app:layout_constraintStart_toStartOf="parent" />

    <ImageView
        android:id="@+id/imgFour"
        android:layout_width="0dp"
        android:layout_height="0dp"
        android:background="@color/colorAccent"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintHorizontal_bias="0.5"
        app:layout_constraintStart_toEndOf="@id/imgThree"
        app:layout_constraintTop_toBottomOf="@+id/imgTwo" />

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:padding="10dp"
        android:text="NEW ITEM"
        android:textColor="@color/colorBlack"
        app:layout_constraintBottom_toBottomOf="@id/imgThree"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="@id/imgTwo" />

</androidx.constraintlayout.widget.ConstraintLayout>

这篇关于Android studio 4 全屏按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆