在使用Android studio 的时候,准备弄的基本的布局出来,底部按钮,按了中间会显示。
来上代码:
页面menu_main.xml
这里弄控件的浮动耗费了点我的时间。原因是因为对其各种问题,
后来发现个好用的属性
这里控件FrameLayout的属性:表示
app:layout_constraintTop_toBottomOf="@+id/relativeLayout1" 顶部对其到relativeLayout1底部
app:layout_constraintBottom_toTopOf="@+id/linearLayout2" 底部对其到linearLayout2的顶部
加上之后,每一个区域都能很好的和前后的衔接好。
<?xml version="1.0" encoding="utf-8"?> <android.support.constraint.ConstraintLayout 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=".MenuActivity"> <RelativeLayout android:id="@+id/relativeLayout1" android:layout_width="match_parent" android:layout_height="48dp"
app:layout_constraintBottom_toTopOf="@+id/linearLayout3"
app:layout_constraintEnd_toEndOf="parent" app:layout_constraintTop_toTopOf="parent" app:layout_constraintVertical_chainStyle="spread_inside"> <View android:id="@+id/view" android:layout_width="wrap_content" android:layout_height="wrap_content" android:background="@android:color/holo_green_light" /> <TextView android:id="@+id/textView2" android:layout_width="267dp" android:layout_height="53dp" android:layout_alignParentBottom="true" android:layout_alignParentStart="true" android:layout_marginStart="76dp" android:gravity="center" android:text="信息" android:textSize="30sp" /> </RelativeLayout> <FrameLayout android:id="@+id/linearLayout3" android:layout_width="match_parent" android:layout_height="0dp" android:background="@android:color/holo_purple" app:layout_constraintTop_toBottomOf="@+id/relativeLayout1" app:layout_constraintBottom_toTopOf="@+id/linearLayout2" > </FrameLayout> <LinearLayout android:id="@+id/linearLayout2" android:layout_width="match_parent" android:layout_height="56dp" android:orientation="horizontal" app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintStart_toStartOf="parent"> <TextView android:id="@+id/textView6" android:layout_width="0dp" android:layout_height="match_parent" android:layout_weight="1" android:background="@android:color/holo_blue_light" android:drawablePadding="3dp" android:gravity="center" android:text="发现" /> <TextView android:id="@+id/textView7" android:layout_width="0dp" android:layout_height="match_parent" android:layout_weight="1" android:background="@android:color/holo_blue_bright" android:drawablePadding="3dp" android:gravity="center" android:text="我的" /> <TextView android:id="@+id/textView9" android:layout_width="0dp" android:layout_height="match_parent" android:layout_weight="1" android:background="@android:color/holo_blue_bright" android:drawablePadding="3dp" android:gravity="center" android:text="我的" /> <TextView android:id="@+id/textView8" android:layout_width="0dp" android:layout_height="match_parent" android:layout_weight="1" android:background="@android:color/holo_blue_bright" android:drawablePadding="3dp" android:gravity="center" android:text="设置" /> </LinearLayout> <!-- <FrameLayout android:id="@+id/frameLayout" android:layout_width="match_parent" android:layout_height="match_parent" android:background="@android:color/holo_orange_dark"> </FrameLayout>--> </android.support.constraint.ConstraintLayout>
上面的效果图: