Hi All I m making an app开发者_JAVA技巧lication in android 2.2 it layout has some text fields in linear layout and also some image Buttons at the bottom of the page. its view on Portrait View is Perfect but now when i turn to Landscape view by pressing CTRL+F11 its bottom Image Buttons do no display.. just because the screen size in landscape is different that of portrait.
what i want is to please guide me through code that if my mobile go to landscape mode it checks its mode and change the location of the buttons so that the image buttons should be visible.
please please please friends help me in this..
waiting for ur positive response and guide.. Thanks in advance
in your project's res folder create a subfolder named 'layout-land'. copy your protrait layout xml file to that folder and edit it for your landscape needs. now the layout is going to be adjusted automatically every time you change the device's orientation. simple as that
In addition to what @Steff has recommended, let me add another thing. After you have created a layout-land folder and created XML, you might consider encapsulating your layout elements within a ScrollView. I had a similar problem and this solution worked perfect for me. Here is a code snippet:
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="horizontal"
android:layout_weight="1" >
<ScrollView
android:id="@+id/ScrollView01"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1" >
<LinearLayout
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:padding="3dp" >
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textStyle="bold"
android:text="NAME"
android:padding="3dp"
android:textColor="#666666"
android:textSize="16sp" >
</TextView>
<TextView
android:text="Name"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:id="@+id/summaryContactName"
android:padding="3dp"
android:textColor="#111111"
android:textSize="17sp" >
</TextView>
</LinearLayout>
</LinearLayout>
</ScrollView>
</LinearLayout>
All the elements that you put under the ScrollView will make sure that the screen content is never cut off.
Hope it helps.
精彩评论