<intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter>
setContentView(R.layout.activity_main);
<!-- Main layout file --> <LinearLayout xmlns:android= "http://schemas.android.com/apk/res/android" xmlns:tools= "http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:padding="50dp" android:orientation="vertical" tools:content=".MainActivity"> </LinearLayout>Ans: The validation header at the top is missing:
<?xml version="1.0" encoding="utf-8"?>The validation header must be the first tag in the XML file. All other tags, even comments, must come after it.
<color name="color1">#e0e0ff</color>
android:background="ffffd0"or
android:background="@color/color1"
LinearLayout layout = (LinearLayout) findViewById(R.id.main_layout);or
Button btnSubmit = (Button) findViewById(R.id.submit);Then call the View setBackground method:
layout.setBackgroundColor(Color.GREEN);or
layout.setBackgroundColor(Color.parseColor("#ffffe0"));or
layout.setBackgroundColor(getResources( ). getColor(R.color.color1));