Android梅花布局

简介: Android梅花布局

项目目录

MainActivity.java

package top.gaojc.myplumblossom;

import androidx.appcompat.app.AppCompatActivity;

import android.os.Bundle;

public class MainActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
    }
}

activity_main.xml

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".MainActivity">

    <!-- 中间的-->
    <ImageView
        android:id="@+id/center"
        android:layout_width="200dp"
        android:layout_height="80dp"
        android:src="@drawable/three"
        android:layout_centerInParent="true"/>

    <!-- 上边-->
    <ImageView
        android:layout_width="80dp"
        android:layout_height="200dp"
        android:src="@drawable/one"
        android:layout_above="@id/center"
        android:layout_centerHorizontal="true"/>

    <!-- 左边-->
    <ImageView
        android:layout_width="80dp"
        android:layout_height="200dp"
        android:src="@drawable/two"
        android:layout_toLeftOf="@id/center"
        android:layout_centerVertical="true"/>

    <!-- 右边-->
    <ImageView
        android:layout_width="80dp"
        android:layout_height="200dp"
        android:src="@drawable/four"
        android:layout_toRightOf="@id/center"
        android:layout_centerVertical="true"/>

    <!-- 下边-->
    <ImageView
        android:layout_width="80dp"
        android:layout_height="200dp"
        android:src="@drawable/five"
        android:layout_below="@id/center"
        android:layout_centerHorizontal="true"/>

</RelativeLayout>

AndroidManifest.xml

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="top.gaojc.myplumblossom">

    <application
        android:allowBackup="true"
        android:icon="@drawable/four"
        android:label="@string/app_name"
        android:roundIcon="@drawable/four"
        android:supportsRtl="true"
        android:theme="@style/AppTheme">
        <activity android:name=".MainActivity">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>

</manifest>

页面效果

获取代码

点击下载

目录
相关文章
|
2天前
|
XML Android开发 数据格式
android点击FrameLayout、LinearLayout等父布局没响应的原因以及解决方案
android点击FrameLayout、LinearLayout等父布局没响应的原因以及解决方案
41 2
|
2天前
|
Android开发
android 布局常见调整手段,怎样查看margin,padding等等
android 布局常见调整手段,怎样查看margin,padding等等
19 0
|
7月前
|
XML 前端开发 Android开发
android 前端常用布局文件升级总结(二)
android 前端常用布局文件升级总结(二)
|
2天前
|
开发框架 搜索推荐 .NET
Android之ListActivity 布局与数据绑定
Android之ListActivity 布局与数据绑定
11 0
|
2天前
|
XML Android开发 数据格式
Android六大布局
Android六大布局
39 1
|
2天前
|
存储 传感器 Android开发
构建高效Android应用:从优化布局到提升性能
【5月更文挑战第13天】 在竞争激烈的移动应用市场中,一个高效的Android应用不仅需要具备直观的用户界面和丰富的功能,还要确保流畅的性能和快速的响应时间。本文将深入探讨如何通过优化布局设计、减少资源消耗以及利用系统提供的API来提升Android应用的性能。我们将分析布局优化的策略,讨论内存使用的常见陷阱,并介绍异步处理和电池寿命的考量。这些技术的综合运用将帮助开发者构建出既美观又高效的Android应用。
|
2天前
|
Android开发 容器
Android Layout 布局
Android Layout 布局
11 1
|
2天前
|
搜索推荐 Android开发
自定义Android标题栏TitleBar布局
自定义Android标题栏TitleBar布局
11 1
|
2天前
|
XML Android开发 数据格式
Android五大布局对象---FrameLayout,LinearLayout ,Absolute
Android五大布局对象---FrameLayout,LinearLayout ,Absolute
|
2天前
|
Android开发
Android Studio入门之常用布局的讲解以及实战(附源码 超详细必看)(包括线性布局、权重布局、相对布局、网格布局、滚动视图 )
Android Studio入门之常用布局的讲解以及实战(附源码 超详细必看)(包括线性布局、权重布局、相对布局、网格布局、滚动视图 )
172 0