0

I have got a View in my Layout. I want to change the Bitmap and the Button to horizontal View, without changing the Application View. The Application is always in Vertical position, so it's doing nothing when I change the rotation.

How is this possible like in the picture bellow? I am not good at layouts, took me days to only do that thing bellow.

enter image description here

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="#FFFFFF"
    android:orientation="vertical"
    tools:context=".MainActivity" >

    <LinearLayout
        android:layout_gravity="right"
        android:id="@+id/paint_colors"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:orientation="horizontal" >

    </LinearLayout>

    <com.example.drawing.DrawingView
        android:id="@+id/drawing"
        android:layout_width="fill_parent"
        android:layout_height="0dp"
        android:layout_marginBottom="3dp"
        android:layout_marginTop="3dp"
        android:layout_weight="1"
        android:background="#FFFFFFFF" />

    <LinearLayout
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="center"
        android:orientation="vertical" >

        <LinearLayout
            android:layout_width="wrap_content"
            android:layout_height="50dp"
            android:layout_gravity="center"
            android:orientation="horizontal" >

            <Button
                android:id="@+id/clear"
                android:layout_width="306dp"
                android:layout_marginBottom="3dp"
                android:layout_height="wrap_content"
                android:background="#009fca"
                android:contentDescription="@string/clear"
                android:text="Do clear" />

        </LinearLayout>
    </LinearLayout>

</LinearLayout>
csnewb
  • 1,190
  • 2
  • 19
  • 37
  • possible duplicate of [Rotating a view in android](http://stackoverflow.com/questions/1930963/rotating-a-view-in-android) – naveejr Jun 26 '14 at 11:34
  • I'm not understanding your problem, what do you want to do exactly?, make your application able to rotate your screen? or rotate your layout having the device in a vertical position? – zozelfelfo Jun 26 '14 at 11:35
  • it should not rotate at runtime. it should be set up one time at the beginning, like the picture in my post shows. left one is current state, right one the result i want. – csnewb Jun 26 '14 at 11:40
  • i think we can't do in xml or layout,you have to rotate at run time. – Haresh Chhelana Jun 26 '14 at 11:44

2 Answers2

1

in the xml layout you can use "rotation"

 <ImageView
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:rotation="90"/>

or in your activity you can say

myImageView.setRotation(90);
erik
  • 4,946
  • 13
  • 70
  • 120
0

Try this:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal"

android:background="#FFFFFF"
 >

<LinearLayout
    android:id="@+id/front"
    android:layout_width="match_parent"
    android:layout_height="match_parent"

    android:orientation="horizontal"

    android:weightSum="100">


    <RelativeLayout
        android:id="@+id/thumb_wrapper"
        android:layout_width="0dip"
        android:layout_height="wrap_content"
        android:layout_gravity="center"

        android:layout_weight="100">


        <ImageView
            android:id="@+id/drawing"
            android:layout_width="wrap_content"
            android:layout_height="match_parent"
            android:src="@drawable/restaurant_1"
            android:layout_alignParentLeft="true"
            android:rotation="90"
            android:background="#FFFFFFFF" />



        <RelativeLayout
            android:id="@+id/left_drawer"
            android:layout_width="wrap_content"
            android:layout_height="match_parent"
            android:layout_alignParentRight="true"
            android:background="#009fca"

            >

            <Button
                android:id="@+id/clear"
                android:layout_width="90dip"
                android:layout_height="match_parent"
                android:layout_centerHorizontal="true"
                android:gravity="center"
                android:background="#009fca"

                android:text="Do clear"
                android:rotation="90"


                />


        </RelativeLayout>

    </RelativeLayout>

</LinearLayout>

sherin
  • 1,091
  • 2
  • 17
  • 27