Friday 29 May 2015

ANDROID STUDIO : Rendering problems in v 1.1.0 / 1.2

On recent Android Studio update v1.1 or v1.2 if you are facing rendering problem in xml on adding android.support.v7.widget.Toolbar or another android.support.v7.widget.*,
try fixing the error by either switching preview API level from 22 to 21 or add Base. to default AppTheme in res/values/styles.xml

A) Switching API level from 22 to 21 in preview pane.
 
 












B)  Changing AppTheme parent in res/values/styles.xml. (i.e Adding Base. to default AppTheme.)
Replace
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
    <!-- Customize your theme here. -->
</style>
with
<style name="AppTheme" parent="Base.Theme.AppCompat.Light.DarkActionBar">
    <!-- Customize your theme here. -->
</style>

Reference:  http://stackoverflow.com/questions/29062658/rendering-problems-in-android-studio-v-1-1-0/29964412#29964412

ANDROID : How to make an Activity FullScreen

Setting activity to fullscreen mode in android can be done either programmatically or via AndroidManifest.xml file.

A) Programmatically

public class FullScreenActivity extends Activity {
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
       
        requestWindowFeature(Window.FEATURE_NO_TITLE);
        getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
            WindowManager.LayoutParams.FLAG_FULLSCREEN);
        setContentView(R.layout.main);
    }
}
 
B) Via AndroidManifest.xml

<activity android:name=".FullScreenActivity"
    android:label="@string/app_name"
    android:theme="@android:style/Theme.NoTitleBar.Fullscreen"/>