Set LinearLayout Orientation using links instead of layout-land (xml only)

I have a layout that is used for both landscape and portrait. I use it in folders /layoutand /layout-land. The only difference is this android:orientation.

I would like to have only 1 xml in /layout, because it is easier to maintain. Instead, I would like to use /valuesand /values-land. Is it possible?

Now I have (unnecessary code removed):

<LinearLayout 
    android:orientation="horizontal"/>

against

<LinearLayout 
    android:orientation="vertical"/>

I’m at least something like:

<LinearLayout 
    android:orientation="@xxxx/linear_orientation"/>

As a final solution, I also thought about creating a custom style just for this LinearLayout(I don't like this solution, but it will have to use it if I cannot distinguish another option).

. , java, xml .

+4
1

1 xml in/layout, . /values ​​/values-land. ?

, . .

styles.xml /values:

<style name="LinearLayoutOrientation" >
    <item name="android:orientation">vertical</item>
</style>

styles.xml /values -land:

<style name="LinearLayoutOrientation" >
    <item name="android:orientation">horizontal</item>
</style>

xml- LinearLayout:

 <LinearLayout 
    style="@style/LinearLayoutOrientation"/>
+9

All Articles