I'm using androidx for development and I'm trying to use the NavigationView and since the findViewById doesn't usually work when you need it to, I'm trying to do everything in Java Code. So, I'm trying to get this NavigationView to appear, but this seems to be missing something:
public class MainActivity extends AppCompatActivity {
Activity_Animation001_Layout animation001_layout;
Animation_Activity002 animLay2;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
DrawerLayout mDrawer = new DrawerLayout(this);
mDrawer.setLayoutParams(new DrawerLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
LinearLayout mLinearLayout = new LinearLayout(this);
mLinearLayout.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
mLinearLayout.setOrientation(LinearLayout.HORIZONTAL);
TextView mTextView = new TextView(this);
mTextView.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
mTextView.setText("something");
mTextView.setTextSize(30);
mLinearLayout.addView(mTextView);
NavigationView mNavView = new NavigationView(this);
NavigationView.LayoutParams mNavLayParam = new NavigationView.LayoutParams(250, ViewGroup.LayoutParams.MATCH_PARENT);
mNavLayParam.gravity= Gravity.RIGHT;
mNavView.setLayoutParams(mNavLayParam);
mDrawer.addView(mLinearLayout);
mDrawer.addView(mNavView);
// animLay2 = new Animation_Activity002(this);
setContentView(mDrawer);
}
The Drawer, LinearLayout and TextView seem to be appearing, but I make the NavigationView to appear when I swipe left from the right edge of the screen. How should we add and instantiate Views(or the NavigationView in this case)?
