RelativeLayout
に2つのボタンprev
とnext
を配置しました。 prev
ボタンの位置合わせが破壊されているbuttonBがGONEのときにbuttonAのボタンアライメントを変更します
next.setVisibility(View.GONE);
:私は私のアプリの最後のページに到達すると、私が使用してnext
ボタンを無効にしています。あたかもボタンが1つしかないかのように、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);
}
}
あなたのレイアウトコードを投稿してください... –