Android水平视图,无需更改应用程序视图
我的布局中有一个视图。我想将位图和按钮更改为水平视图,而不更改应用程序视图。应用程序始终处于垂直位置,因此当我更改旋转时,它什么也不做 这怎么可能像下面的图片一样?我不擅长布局,花了好几天的时间才完成下面的工作Android水平视图,无需更改应用程序视图,android,android-layout,Android,Android Layout,我的布局中有一个视图。我想将位图和按钮更改为水平视图,而不更改应用程序视图。应用程序始终处于垂直位置,因此当我更改旋转时,它什么也不做 这怎么可能像下面的图片一样?我不擅长布局,花了好几天的时间才完成下面的工作 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layou
<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>
在xml布局中,可以使用“旋转” 试试这个:
<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>
我不理解您的问题,您到底想做什么?使您的应用程序能够旋转屏幕?或者在设备处于垂直位置时旋转布局?在运行时不应旋转。它应该在开始时设置一次,就像我的帖子中的图片所示。左一个是当前状态,右一个是我想要的结果。我认为我们不能在xml或布局中完成,您必须在运行时进行轮换。
myImageView.setRotation(90);
<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>