Androidでプログラムで以下の行をコーディングしたいと思います。誰かがそれを解決するのを手伝ってください.私はそれを検索しましたが、正確な解決策を得ることができませんでした.
事前にサンクス。
android:layout_marginRight="30dp"
Androidでプログラムで以下の行をコーディングしたいと思います。誰かがそれを解決するのを手伝ってください.私はそれを検索しましたが、正確な解決策を得ることができませんでした.
事前にサンクス。
android:layout_marginRight="30dp"
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 に送られます。
あなたはこのようにすることができます
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);