<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="wrap_content"
android:layout_height="match_parent" >
<LinearLayout
android:id="@+id/buttons"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true" >
<Button
android:id="@+id/insertButtonVIEW"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="insert" />
<Button
android:id="@+id/removeButtonVIEW"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="remove" />
</LinearLayout>
</RelativeLayout>
場合によっては、メソッドを使用して removeButtonVIEW を隠しているsetVisibility(View.INVISIBLE);
ことがあります。その場合、insertButtonVIEW が画面の幅全体を占めるようにします (2 つが存在する場合、それぞれが画面の 50% を占めます)。
これは起こるかもしれないし起こらないかもしれないので、私はこれらの変更をプログラムで行っています。
私は次の方法を試してみましたが、画面上のすべての場所が混在しているため、すべてのインターフェースがジャンボマンボになります。
modifyButton.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT));
ヒントはありますか?
回答を適用した後の更新 1: 次のコードを使用して、ボタンを非表示に設定しています。
Bundle extras;
extras = getIntent().getExtras();
String answer = extras.getString("answer");
if(answer.equalsIgnoreCase("yes")
{
insertButton.setEnabled(true);
insertButton.setText("INSERT");
removeButton.setVisibility(View.INVISIBLE);
}
else
{
//whatever
}