I am new to android.
I ran into one problem: I am adding a frame layout to my application, the code
<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent" > <FrameLayout android:id="@+id/frameLayout1"> <LinearLayout android:layout_height="wrap_content" android:id="@+id/linearLayout1" android:layout_width="fill_parent"> </LinearLayout> </FrameLayout> </LinearLayout>
My problem is that I want to change the height of the frame layout in different screen orientations.
code example
wm = (WindowManager)getSystemService(Context.WINDOW_SERVICE); getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON); Log.v("height","height"+wm.getDefaultDisplay().getHeight()); if(wm.getDefaultDisplay().getHeight() <= 427) { Log.v("height","111"); ((FrameLayout)findViewById(R.id.frameLayout1)).setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT,LayoutParams.FILL_PARENT)); } else { ((FrameLayout)findViewById(R.id.frameLayout1)).setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT,LayoutParams.FILL_PARENT)); }
But he gives power close
If anyone has an idea, please help me.
Thanks in advance.
kiran source share