1

Androidでプログラムで以下の行をコーディングしたいと思います。誰かがそれを解決するのを手伝ってください.私はそれを検索しましたが、正確な解決策を得ることができませんでした.
事前にサンクス。

android:layout_marginRight="30dp"
4

2 に答える 2

3
 Try this, you can do that in code like following

TextView forgot_pswrd = (TextView) findViewById(R.id.ForgotPasswordText);
LinearLayout.LayoutParams llp = new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
llp.setMargins(0, 0, 30, 0); // llp.setMargins(left, top, right, bottom);
forgot_pswrd.setLayoutParams(llp);

注: 上記のコードは、LinearLayout を使用している場合に有効です。RelativeLayout または FrameLayout を使用している場合は、それに応じて使用してください。この追加メモについては、クレジットは biovamp に送られます。

于 2012-08-30T06:13:59.960 に答える
1

あなたはこのようにすることができます

TextView tv;

tv=(TextView)findViewById(R.id.YourTextViewID);

tv..setOnTouchListener(this);

 LinearLayout.LayoutParams llp = new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT,       LayoutParams.WRAP_CONTENT);

llp.setMargins(50, 0, 0, 0); // llp.setMargins(left, top, right, bottom);

forgot_pswrd.setLayoutParams(llp);
于 2012-08-30T06:35:37.877 に答える