HLessJon Tutorials
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#ff0202"
android:gravity="top|center"
android:orientation="vertical" >
<!--**23** basically added ImageView with the image robbit1 I
think working with graphics helps create better visual understanding.
also changed the background with color picker (see video) -->
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:background="@drawable/robbit1" />
</LinearLayout>
package com.mycompany.multipanefragment;
import android.app.FragmentManager;
import android.app.FragmentTransaction;
import android.content.res.Configuration;
import android.os.Bundle;
import android.support.v4.app.FragmentActivity;
import android.view.View;
public class MyActivity extends FragmentActivity {
/*A fragment must always be embedded in an activity
and the fragment's lifecycle is directly affected by
the host activity's lifecycle.*/
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_my);
// Hides the side panel when in portrait mode HIGHLIGHT THIS
// SECTION AND COMMENT IT OUT TO SEE WHAT HAPPENS
int screenOrientation = getResources().getConfiguration().orientation;
if (screenOrientation == Configuration.ORIENTATION_PORTRAIT) {
hideSidePane();
}
//Code for **23**, beginning
/* else {
View bttnPanel = findViewById(R.id.main_panel);
if (bttnPanel.getVisibility() == View.VISIBLE) {
bttnPanel.setVisibility(View.GONE);
}
}*/
//Code for **23** added, end.
}
// Hides the side panel
private void hideSidePane() {
View sidePane = findViewById(R.id.side_panel);
if (sidePane.getVisibility() == View.VISIBLE) {
sidePane.setVisibility(View.GONE);
}
}
}