AndroidStdio FrameLayout 帧布局实现一个引导界面
先看效果图:
引导界面分为三个部分,最下面的图片区,左边的文本框,右下角的进入按钮。完整代码放在最后,下面简单说一下FrameLayout帧布局。
概览
FrameLayout(帧布局)可以说是五大布局中最为简单的一个布局,这个布局会默认把控件放在屏幕上的左上角的区域,后续添加的控件会覆盖前一个,如果控件的大小一样大的话,那么同一时刻就只能看到最上面的那个控件
简单示例
引导界面代码
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout
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=".SplashActivity">
<ImageView
android:id="@+id/imageView2"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scaleType="fitXY"
app:srcCompat="@drawable/splash" />
<TextView
android:id="@+id/textView9"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textSize="20dp"
android:layout_marginTop="40dp"
android:layout_marginLeft="25dp"
android:text="为你\n\n我用了半年的积蓄\n\n漂洋过海的来看你\n\n为了这次相聚\n\n我连见面时的呼吸\n\n都曾反复练习\n\n言语从来没能将我的情意\n\n表达千万分之一\n\n为了这个遗憾\n\n我在夜里想了又想\n\n不肯睡去"
android:inputType="textMultiLine" />
<Button
android:id="@+id/button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom|right"
android:background="@color/colorsplash"
android:textColor="@color/colorsplashtext"
android:textSize="20dp"
android:text="点击进入" />
</FrameLayout>
dp"
android:text=“点击进入” />