android - xamarin android 中的按钮对齐

标签 android xamarin xamarin.android

我有如下所示的 View 寻呼机和页面指示器。我试图将按钮保留在它两侧的 View 寻呼机上方。但我无法在左侧和右侧获得这些按钮。谁能帮我把这些按钮保持在正确的位置。

 <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/

关于android - xamarin android 中的按钮对齐,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52827845/

相关文章:

c# - 如何使用Mono for Android模仿Android/IOS的联系人

android - 如何在用户使用Android应用程序发布到Facebook墙时添加应用程序 Logo

android - 如何使用 AndroidViewClient 找出复选框的状态

java - Android MediaPlayer 播放通过有线耳机断断续续,而不是通过蓝牙

dependency-injection - 带有 NullReferenceException 的 Xamarin 跨平台中的 Ninject 实现

visual-studio - 警告主要版本 52 比该编译器支持的最高主要版本 51 更新

Android getIntent() 返回第一个 Intent

android - 推送 apk 文件时出现错误 JAR_SIG_NO_MANIFEST : Missing META-INF/MANIFEST. MF

c# - 我可以强制 .NET XmlDocument 实例尽快释放它占用的内存吗?

Xamarin.Forms 自定义 Android NavigationPageRenderer 标题和副标题