android Exit from full screen mode

As per below code, i can hide the TitleBar by your needs, Button full; static int vari = 0; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); full = (Button)findViewById(R.id.fullview); full.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { // TODO Auto-generated method stub if(vari == 0) { getWindow().clearFlags(WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN); getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN); vari = 1; }else { … Read more

How do I programmatically remove an existing rule that was defined in XML?

You can’t remove a rule because all rules are always stored in a fixed-size java array. But you can set a rule to 0. For example layoutParams.addRule(RelativeLayout.RIGHT_OF, 0); layoutParams.addRule(RelativeLayout.BELOW, R.id.new_ref_LinearLayout); EDIT (thanks to Roger Rapid): As of API level 17, the class RelativeLayout.LayoutParams has the following method: public void removeRule(int verb) So you can remove … Read more

TYPE_SYSTEM_OVERLAY in ICS

To create an overlay view, when setting up the LayoutParams DON’T set the type to TYPE_SYSTEM_OVERLAY. Instead set it to TYPE_PHONE. Use the following flags: FLAG_NOT_TOUCH_MODAL FLAG_WATCH_OUTSIDE_TOUCH FLAG_NOT_TOUCH_MODAL << I found this one to be quite important. Without it, focus is given to the overlay and soft-key (home, menu, etc.) presses are not passed to … Read more

Auto-fit TextView for Android

Thanks to MartinH’s simple fix here, this code also takes care of android:drawableLeft, android:drawableRight, android:drawableTop and android:drawableBottom tags. My answer here should make you happy Auto Scale TextView Text to Fit within Bounds I have modified your test case: @Override protected void onCreate(final Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); final ViewGroup container = (ViewGroup) findViewById(R.id.container); findViewById(R.id.button1).setOnClickListener(new … Read more