Change Eclipse Layout Orientation - android

I want to know how to change the orientation of my layout.
In manifest I have:
android:screenOrientation="landscape"
In layout.xml I have
android:orientation="horizontal"
but when I click the "layout" button it still appears as a vertical layout.
Thank You.

There is a dropdown within the layout editor that allows you to select landscape or portrait orientation.

Related

Enable scrolling or create new layout for landscape view

I'm developing an android app where in I have the login button at the bottom of the layout. On rotation of the device to landscape view, the button disappears making the UI pretty much useless.
So my question is: Should I rearrange views in the existing layout and enable scrolling or create a new layout for landscape view?
If you agree with the first option, how can I make sure that the login button stays intact at the bottom in the portrait as well as in landscape view?
Specifying a landscape layout should be your best option. With this, you can setup exactly what you want for each orientations.
Add ScrollView as a parent to the xml file of your login page
Example
<ScrollView android:id="#+id/ScrollView01"
xmlns:android="http://schemas.android.com/apk/res/android"
android:fillViewport="true"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<--your layout
</ScrollView>

Android layout orientation change in landscape mode

I have a FrameLayout inside my fragment, and three other layouts inside my FrameLayout. I want one of the three layouts to change its view positions on a landscape, so I created two XML files for this layout and put them inside layout-port and layout-land accordingly, but the layout is still using the portrait layout in landscape mode. So what else do I need to do?
<FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
.
.>
<include
layout="#layout/xxx"
... />
<include
layout="#layout/xxx2"
... />
...
</FrameLayout>
I want to change the layout of xxx on a landscape, and I created 2 XML for xxx.
The default folder for layout is layout no need to add port suffix to it, when you create a landscape version you should make sure that its in the folder layout-land and the device will automatically select this layout version at runtime. for more information on supporting different screen sizes look at this documentation

Android buttons at top and ScrollView at bottom of the screen

I have two buttons "Submit" and "Reset" on top of the ui and below this is my form. The problem is when i open my keyboard, the form scrolls up and goes below the top buttons layout. What should be the problem? I want to show buutons on top only.
try this
Replace to RelativeLayout to Linearlayout With orientation Vertical.
you can try to prevent the keyboard from scrolling up your form, so the keyboard will be above your layout by doing this :
add this to your manifest
<activity
android:name="yourActivity"
android:screenOrientation="portrait"
android:windowSoftInputMode="stateVisible|adjustPan"/>
then put this inside your ScrollView
<ScrollView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:isScrollContainer="false">
</ScrollView>
if any trouble leave a comment !
Good luck

Change ScrollView into HorizontalScrollView

I have two layouts defined mainactivity.xml which is found in the layout folder, and another mainactivity.xml which is found in the layout-port folder. As you can probably tell one layout is for Landscape orientation and the other is for Portrait.
The issue I'm having is that in the Landscape layout I have a ScrollView, and in the Portrait layout it is a HorizontalScrollView with the same id. How do I change (in code) the ScrollView into a HorizontalScrollView when the orientation of the device changes?
You could create a bools.xml file in res/values-land (and also one in res/values-port in which is_landscape should be set to false)
<?xml version="1.0" encoding="utf-8"?>
<resources>
<bool name="is_landscape">true</bool>
</resources>
Then in your code you can check
if (getResources().getBool(R.bool.is_landscape)) {
//setup horizontal scrollview
} else {
//setup vertical scrollview
}
Although perhaps a better way is to use this library (so you don't have to code for two different ui components).
https://github.com/lucasr/twoway-view
I'm using this in a current project and it works beautifully.
In your scrollview define this property
android:orientation="horizontal" for landscape
android:orientation="vertical" for portrait

Layout Orientation conflicting with manifest

In the manifest file of this application, I have specified the screen orientation to be landscape for each activity. However, in each layout file it lists android:orientation="vertical" as default. The application sometimes crashes, sometimes it doesn't, could these values be conflicting?
No way, it is different things at all.
Landscape for activity mean how to show activity for user
android:orientation="vertical" for LinearLayout mean how LinearLayout will draw its children views
android:orientation in layout defines how the child view will be stacked on the screen (for example see LinearLayout). The orientation in the manifest is all about the screen orientation (or the orientation of specific Activity).

Categories

Resources