将Tablayout放在布局的底部

来源:互联网 发布:mysql 性能测试工具 编辑:程序博客网 时间:2024/04/28 20:51

这个其实很简单,只不过我一开始直接给tablayout控件设置,gravity=bettom 发现没有任何效果,后来我就采取了另外一种比较巧妙地办法,就是随便写写,只是记录一下,下面是我的布局源码:

<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=".MainActivity"    >    <android.support.v7.widget.Toolbar        android:id="@+id/toolbar"        android:layout_width="match_parent"        android:layout_height="wrap_content"        android:background="#ff5722"        android:minHeight="50dp"        app:popupTheme="@style/ThemeOverlay.AppCompat.Light"        app:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"></android.support.v7.widget.Toolbar>    <LinearLayout        android:layout_width="match_parent"        android:layout_height="match_parent"        android:orientation="vertical"        android:layout_weight="1">        <TextView            android:layout_width="wrap_content"            android:layout_height="wrap_content"            android:gravity="center"            android:paddingBottom="@dimen/activity_vertical_margin"            android:paddingLeft="@dimen/activity_horizontal_margin"            android:paddingRight="@dimen/activity_horizontal_margin"            android:paddingTop="@dimen/activity_vertical_margin"            android:text="@string/hello_world"            android:textColor="#000"            android:textSize="20sp"            />    </LinearLayout><LinearLayout    android:layout_width="match_parent"    android:layout_height="wrap_content"    android:gravity="bottom"    android:layout_marginBottom="2dp">    <android.support.design.widget.TabLayout        android:id="@+id/tablayout"        android:layout_width="match_parent"        android:layout_height="wrap_content"        /></LinearLayout></LinearLayout>

运行效果:



0 0
原创粉丝点击