I have an Activity with several TextEdits
and in portrait mode everything is displayed perfectly.But when i switch the device to the landscape mode several views didn't displayed (they are cut).Can i in some way automatically add scrolling to the view when the device is switched to the landscape mode?
Asked
Active
Viewed 1.2k times
12

Oleksandr Karaberov
- 12,573
- 10
- 43
- 70
2 Answers
21
you can try do this, this maybe helpful to you:
add ScrollView to your layout and set this flag android:fillViewport="true"
for example:
<ScrollView
android:id="@+id/scrollView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport="true" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
// your layout
</LinearLayout>
</ScrollView>
Scroll will be enable when in your screen not enough space for items. Then you can scroll screen. So that if screen orientation is changed to landscape you can scroll items, and in portrait everything is displayed perfectly without ability to scroll.

Volodymyr Yatsykiv
- 3,181
- 1
- 24
- 28
-
android:fillViewport="true" that is very important ,work for me tanx @Volodymyr – Adiii May 26 '16 at 11:35
0
Check when your device is in portrait mode and add :
ScrollView scroll = new ScrollView(yourContext);
scroll.setBackgroundColor(android.R.color.transparent);
scroll.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT));
scroll.addView(yourView);

Alexis C.
- 91,686
- 21
- 171
- 177
-
You should get a look at the doc : http://developer.android.com/reference/android/content/res/Configuration.html#orientation – Alexis C. Apr 09 '13 at 08:45
-
2use getResources().getConfiguration().orientation to get the current orientation – Sankar V Apr 09 '13 at 08:45