我有一个带有两个TextView和一个按钮的LinearLayout。按钮边距的问题
通过使用layout_marginTop,我将TextView的样式设置为略低于其他部分。这工作正常。
但是,我想将按钮向下移动更多,但调整layout_marginTop属性似乎没有帮助。所有其他人(如填充)都可以工作,但只有我需要的人不适合工作。
<LinearLayout
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
xmlns:android="http://schemas.android.com/apk/res/android"
android:weightSum="1">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text="The value:"
android:id="@+id/HeaderTextView"
android:layout_gravity="left|top"
android:layout_marginTop="20dip"
android:fontFamily="sans-serif-light"
android:textStyle="normal|bold"/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="-"
android:id="@+id/ValueTextView"
android:layout_below="@id/HeaderTextView"
android:layout_marginTop="10dip"
android:layout_gravity="left|center_vertical"
android:fontFamily="sans-serif-thin" />
<Button
android:background="@drawable/red_button"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Reset Alarm"
android:layout_below="@id/ValueTextView"
android:layout_marginTop="120dip"
android:id="@+id/getValueButton"
style="@style/button_text"/>
</LinearLayout>
按钮的顶部被目前针对粘它上面的TextView的底部。我为什么不能按下按钮?
layoutbelow不会在LinearLayout中工作。你必须使用相对布局..你可以更清楚你的按钮应该在哪里? – Dhina 2014-10-29 06:02:38
@Dhina按钮应该在ValueTextView下面。这现在正确显示。问题是,无论我用什么样的值layout_marginTop,Button和TextView都正好在彼此之下。虽然如果我为TextView增加layout_marginTop的值,那么TextView之间的空间会增加更多。我想设置更多的按钮(更多的边缘)按钮,但它不起作用。 – Joetjah 2014-10-29 08:49:14
添加了一个答案..试试吧。让我知道它是不是你所期望的。 – Dhina 2014-10-29 09:09:12