I have a simple MainActivity where an orientation change from portrait to landscape and back to portrait works properly. My SecondActivity screen has a TextView with EditText line for user input. Unfortunately, on orientation change from portrait to landscape, the layout does not change properly. It appears to not carry over to the landscape mode. The TextViews, background colors and toolbar of the layout file are not loading. Only the EditText hint shows and the background shown is white color. I tested on a Samsung Galaxy S3 and a Genymotion emulator with the same bad result. Lastly, when the device or the emulator is rotated back to portrait, the view layout loads correctly...everything displays properly like the original portrait display. What am I missing here?
SecondActivity java file:
...
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.cardviewinput);
EditText java file:
public class ListenerEditText extends EditText {
...
Layout xml file:
...
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_weight="1"
android:background="#FF0000" >
<TextView
android:id="@+id/createSkycard"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textColor="#FFFFFF"
android:layout_marginTop="20dp"
android:gravity="center_horizontal"
android:text="Create a skycard"
android:textAppearance="?android:attr/textAppearanceMedium"/>
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_weight="1"
android:background="#FF0000" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#FFFFFF"
android:text=" To Do item: "
android:textAppearance="?android:attr/textAppearanceMedium"/>
<com.example.jdw.secondscreen.ListenerEditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/CEditText"
android:inputType="text|textCapSentences|textNoSuggestions"
android:textAppearance="?android:attr/textAppearanceMedium"
android:hint="Type a new item here"
android:textColor="#000000"
android:singleLine="true"
android:imeOptions="actionNext" >
<requestFocus />
</com.example.jdw.secondscreen.ListenerEditText>
...