我有如下视图寻呼机和页面指示器。我试图将按钮保持在视图寻呼机上方的任一侧。但是我无法在左侧和右侧获得这些按钮。有人可以帮我把这些按钮保持在适当的位置吗?

 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:local="http://schemas.android.com/apk/res-auto"
    android:orientation="vertical"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:minWidth="25px"
    android:minHeight="25px">
    <android.support.v7.widget.Toolbar
        android:id="@+id/toolbar"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:fitsSystemWindows="true"
        android:minHeight="?attr/actionBarSize"
        android:background="?attr/colorPrimary" />
  <RelativeLayout
      android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:padding="16dp"
      >
        <android.support.v4.view.ViewPager
            android:id="@+id/viewPager"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:padding="16dp" />
        <android.support.design.widget.TabLayout
            android:id="@+id/dots"
            android:layout_alignParentBottom="true"
            android:layout_width="match_parent"
            android:layout_height="10dp"
            local:tabBackground="@drawable/dot_selector"
            local:tabGravity="center"
            local:tabIndicatorHeight="0dp"
            local:tabPaddingStart="7dp"
            local:tabPaddingEnd="7dp" />
        <LinearLayout
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:orientation="horizontal"
           >
            <Button
                android:id="@+id/skipBtn"
                android:text="Skip"
                android:layout_width="0dp"
                android:layout_height="wrap_content"
                android:layout_weight="0" />
            <Button
                android:id="@+id/nextBtn"
                android:text="Next"
                android:layout_width="0dp"
                android:layout_height="wrap_content"
                android:layout_weight="0" />
        </LinearLayout>
    </RelativeLayout>
</LinearLayout>


运行此代码时,按钮不出现。

最佳答案

在两个按钮的线性布局中,使用android:layout_weight =“ 1”

这基本上将布局中两个按钮之间的大小比例指定为相等。

有关更多布局权重样式的详细信息,请参见此处:https://blog.stylingandroid.com/layout-weights-part-2/

09-05 04:15
查看更多