【发布时间】:2016-11-01 17:19:41
【问题描述】:
这是我的布局。现在我有了我的工作工具栏,但按钮在工具栏下方。我尝试在这里和那里添加一些边距,但由于某种原因,一个按钮总是与其他按钮不对齐,即使我总是使用相同的 MarginTop。我该如何解决这个问题?
<android.support.v7.widget.Toolbar
android:id="@+id/my_toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="?attr/colorPrimary"
android:theme="@style/ThemeOverlay.AppCompat.ActionBar"
app:popupTheme="@style/ThemeOverlay.AppCompat.Light"/>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Start"
android:id="@+id/button"
android:layout_alignTop="@+id/buttonP"
android:layout_centerHorizontal="true"
app:layout_widthPercent="40%"
app:layout_marginTopPercent="2%"/>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="<<"
android:id="@+id/buttonP"
android:layout_alignParentLeft="true"
app:layout_widthPercent="30%"
app:layout_marginTopPercent="2%"/>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text=">>"
android:id="@+id/buttonN"
android:layout_above="@+id/custom_list"
android:layout_alignRight="@+id/custom_list"
app:layout_widthPercent="30%"
app:layout_marginTopPercent="2%"/>
<ListView
android:id="@+id/custom_list"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:dividerHeight="1dp"
android:layout_weight="0.5"
android:layout_below="@+id/button" />
</android.support.percent.PercentRelativeLayout>
【问题讨论】:
标签: android xml android-layout android-actionbar