我在RelativeLayout
中放置了兩個按鈕prev
和next
。當我到我的應用程序的最後一頁,我禁止使用next
按鈕:當buttonB爲GONE時更改buttonA的按鈕對齊方式
next.setVisibility(View.GONE);
prev
按鈕的排列被打亂。我希望它與RelativeLayout
的中心對齊,就好像只有一個按鈕一樣。
這裏是我的代碼:
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="100dp"
android:layout_below="@+id/radgroup"
>
<Button
android:layout_marginTop="14dp"
android:layout_marginLeft="20dp"
android:text="@string/previous"
android:textAllCaps="false"
android:textSize="23dp"
android:layout_width="150dp"
android:layout_height="70dp"
android:id="@+id/prev"
android:onClick="viewPreviousQuestion"
/>
<Button
android:layout_marginTop="14dp"
android:layout_marginLeft="20dp"
android:text="@string/previous"
android:textAllCaps="false"
android:textSize="23dp"
android:layout_width="150dp"
android:layout_height="70dp"
android:layout_toRightOf="@+id/prev"
android:id="@+id/nxt"
android:onClick="viewNextQuestion"
/>
</RelativeLayout>
和onClick
事件是
public void viewNextQuestion(View view) {
if(currqstn==lastqstn){
next.setVisibility(View.GONE);
}
}
發佈您的佈局代碼... –