我正在参与「兔了个兔」创意投稿大赛,概况请看:「兔了个兔」创意投稿大赛
前言
没想到写这篇是掐着活动终究时间写的,所以我就以一副对联收尾,也算是为本次活动喝彩了,下面咱们来看看如何完成这副对联的展现的。
正篇
完成方法
首要,咱们先增加一个线性布局,设置竖直方向特点以及背景色彩设置为赤色,然后为其内部增加子布局,第一个是TextView,作为横幅,首要宽高内容大小自适应,然后布局居中。
接着咱们去规划左右竖着的上下联,咱们采用FrameLayout帧布局,然后内部写子布局TextView别离start和end,且宽度设置为40dp,正好一字一行构成竖着写的款式,当然为了让对联更紧凑,咱们设置了layout_marginEnd和layout_marginStart特点,让上下联挨近。终究咱们在中间加一张福的图片就功德圆满!
代码如下:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout 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"
android:orientation="vertical"
tools:context=".RabbitSecond">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:background="@color/red"
android:text="@string/rabbit_h"
android:textSize="25sp"
android:textStyle="bold"/>
<FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:layout_width="40dp"
android:layout_height="wrap_content"
android:text="@string/rabbit_1"
android:background="@color/red"
android:textSize="25sp"
android:textStyle="bold"
android:layout_marginStart="20dp"
android:gravity="center"/>
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@mipmap/rabbit_fu"
android:layout_gravity="center|top"/>
<TextView
android:layout_width="40dp"
android:layout_height="wrap_content"
android:layout_gravity="end"
android:layout_marginEnd="20dp"
android:text="风调雨顺颂华年"
android:background="@color/red"
android:textSize="25sp"
android:textStyle="bold"
android:gravity="center"/>
</FrameLayout>
</LinearLayout>
终究效果
终究咱们看到构成贴在门上的对联款式,中间还有一个福:
总结
很简单的布局效果,也是最简单完成的效果了,比起在web上写对联,我感觉简单了许多,这便是熟练与否的效果,所以后续我还会继续操练web开发。