[英]Android app unjustifiably rotates to landscape and then back to portrait
Android應用程序毫無理由地旋轉到橫向並轉為縱向。 從相機返回到應用程序時會發生這種情況。
public void configureItemImageButton() {
MaterialCardView itemImageButton = (MaterialCardView) view.findViewById(R.id.itemImageCardView);
itemImageButton.setOnClickListener(new View.OnClickListener(){
@Override
public void onClick(View v){
Intent cameraIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
startActivityForResult(cameraIntent, 111);
}
});
}
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
if (requestCode == 111) {
Bitmap image = (Bitmap) data.getExtras().get("data");
ImageView imageview = (ImageView) view.findViewById(R.id.itemImage);
imageview.setImageBitmap(image);
}
}
以下是我的android清單文件:
<application
android:allowBackup="true"
android:icon="@drawable/ic_trainsterlogo"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme"
android:screenOrientation="portrait">
<activity android:name=".TrainsterActivity"
android:theme="@style/AppTheme.NoActionBar"
android:windowSoftInputMode="adjustNothing"
android:screenOrientation="portrait">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
<uses-permission android:name="android.permission.READ_CONTACTS" />
<uses-permission android:name="android.permission.CAMERA"> </uses-permission>
編輯:如果我的editTextview中包含文本,則不會發生此問題,但是我無法再復制此文本,並且我嘗試刪除textview,問題仍然存在。
編輯:我否定了通過保存實例來清除圖像的負面影響。 然而,無法解釋的旋轉在美學上仍然令人不快。
將其添加到該特定活動下的清單文件中
android:screenOrientation="portrait"
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.