-1

ダイアログでは、WRAP_CONTENT を持つ ImageButton の左側に MATCH_PARENT EditText が必要です。これは下の図のようになります。

レイアウト図 http://goo.gl/dxuS5

この問題の解き方がわかりません!Javaだけでプログラミングする必要があります!これを XML で記述する機会はありません。

私は LinearLayout を使用しています。ただし、MATCH_PARENT は ImageButton を WRAP_CONTENT と交換します。また、私は RelativeLayout を使用していますが、これはそうではないようです。

4

2 に答える 2

0

これを試して:

<LinearLayout
    android:orientation="horizontal"
    android:layout_width="match_parent"
    android:layout_height="match_parent" />
    <ImageButton
        android:layout_gravity="right"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content" />
    <EditText
        android:layout_gravity="left"
        android:layout_width="match_parent"
        android:layout_height="wrap_content" />
</LinearLayout>
于 2012-05-12T09:51:10.577 に答える
0

これらを水平方向の LinearLayout に配置すると仮定します。

EditText temp = new EditText(this);
LinearLayout.LayoutParams params = new  LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);                            LayoutParams.WRAP_CONTENT, 1);
temp.setLayoutParams(params);

ImageView imageView = new ImageView(this);
LinearLayout.LayoutParams vp = new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
imageView.setLayoutParams(vp);        
imageView.setImageResource(id);        

someLinearLayout.addView(temp);    
someLinearLayout.addView(imageView);    
于 2012-05-12T12:18:44.657 に答える