0
我正在开发一个应用程序,它将在启动活动内的框架后向用户显示图像和其下的一些文本。 我正在以编程方式将drawable
资源分配给ImageView
。在屏幕上旋转保持图像大小
ImageView image = (ImageView) rootView.findViewById(R.id.avaImage);
image.setImageDrawable(getResources().getDrawable(R.drawable.ava_green));
到目前为止好。但是当我旋转设备的屏幕时,Android会更改图像的分辨率。我希望它保持原样。我怎样才能做到这一点? 这是我的片段布局:
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
tools:context=".NavigationActivity"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport="true">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<TextView
android:id="@+id/txtLabel"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:layout_marginTop="10dp"
android:text="@string/title"
android:textSize="26sp" />
<ImageView
android:id="@+id/avaImage"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="@id/txtLabel"
android:layout_centerHorizontal="true"
android:layout_marginTop="40dp" />
</RelativeLayout>
</ScrollView>
我不认为这是一个好主意,停止重置轮换的活动。我只需要在我的应用程序中使用的许多片段之一中保留图片大小 – 2014-09-01 21:03:38