It is necessary to make arbitrary complexity a dynamic interface. I tried this:
TextView.setLeft(int) does not exit if the item is inside framelayay.
Nowhere on this topic can I find a clear answer.
It is necessary to make arbitrary complexity a dynamic interface. I tried this:
TextView.setLeft(int) does not exit if the item is inside framelayay.
Nowhere on this topic can I find a clear answer.
FrameLayout.LayoutParams layoutParams = new FrameLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT); Next, in layoutParams you call the margin setting methods, for example, setMargins (int left, int top, int right, int bottom)
well then
textView.setLayoutParams(layoutParams) FrameLayout.LayoutParams layoutParams = new FrameLayout.LayoutParams(MainActivity.this); context took with MainActivity what's the problem? - Eugene import android.app.Activity; import android.os.Bundle; import android.widget.TextView; import android.widget.FrameLayout; import android.widget.FrameLayout.LayoutParams; import android.view.View; import android.view.Gravity; import android.graphics.Color; public class MainActivity extends Activity { @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); TextView tv1 = new TextView(this); LayoutParams params = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.FILL_PARENT); params.setMargins(100,100,0,0); tv1.setLayoutParams(params); tv1.setTextSize(80); tv1.setTextColor(Color.GREEN); tv1.setText("text1"); TextView tv2 = new TextView(this); tv2.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT, Gravity.BOTTOM)); tv2.setTextSize(50); tv2.setGravity(Gravity.RIGHT); tv2.setTextColor(Color.WHITE); tv2.setText("text2"); FrameLayout fl = new FrameLayout(this); fl.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT)); fl.addView(tv1); fl.addView(tv2); setContentView(fl); } } Hooray! Found the answer to your question, a combination:
LayoutParams params = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.FILL_PARENT); params.setMargins(100,100,0,0); WORKS!
Source: https://ru.stackoverflow.com/questions/506128/
All Articles