Scene transition image drawn in tiles during transition - android

I'm facing weird drawing issue with scene transitions (running with Nexus 5x 6.0.1 platform)
I found out that <item name="android:windowBackground">#null</item> has some relation to the issue.
Anyone know why this happens and what can be possible places to check in order to fix this?
Here is my test project setup to reproduce the problem:
minSdkVersion 16 and targetSdkVersion 23 using:
com.android.support:appcompat-v7:23.3.0
AndroidManifest.xml
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:supportsRtl="true"
android:theme="#style/AppTheme">
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
<activity android:name=".NextActivity"/>
</application>
styles.xml
<resources>
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
<item name="android:windowActionBar">false</item>
<item name="android:windowNoTitle">true</item>
<item name="android:windowBackground">#null</item>
<!-- Customize your theme here. -->
<item name="colorPrimary">#color/colorPrimary</item>
<item name="colorPrimaryDark">#color/colorPrimaryDark</item>
<item name="colorAccent">#color/colorAccent</item>
</style>
</resources>
MainActivity.java
public class MainActivity extends AppCompatActivity {
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
final View iv = findViewById(R.id.iv_test);
ViewCompat.setTransitionName(iv, "test");
findViewById(R.id.b_go).setOnClickListener(new OnClickListener() {
#Override
public void onClick(View v) {
Bundle bundle = ActivityOptionsCompat.makeSceneTransitionAnimation(MainActivity.this,
android.support.v4.util.Pair.create(iv, "test")).toBundle();
startActivity(new Intent(MainActivity.this, NextActivity.class), bundle);
}
});
}
}
NextActivity.java
public class NextActivity extends AppCompatActivity {
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_next);
final View iv = findViewById(R.id.iv_test);
ViewCompat.setTransitionName(iv, "test");
}
}
activity_main.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
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="#android:color/white"
android:paddingBottom="#dimen/activity_vertical_margin"
android:paddingLeft="#dimen/activity_horizontal_margin"
android:paddingRight="#dimen/activity_horizontal_margin"
android:paddingTop="#dimen/activity_vertical_margin"
tools:context="com.test.scenetransitions.MainActivity">
<ImageView
android:id="#+id/iv_test"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#android:drawable/ic_dialog_email"
android:tint="#color/colorAccent"/>
<Button
android:id="#+id/b_go"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:background="#color/colorAccent"
android:padding="20dp"
android:text="GO"/>
</RelativeLayout>
activity_next.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
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="#android:color/white"
android:paddingBottom="#dimen/activity_vertical_margin"
android:paddingLeft="#dimen/activity_horizontal_margin"
android:paddingRight="#dimen/activity_horizontal_margin"
android:paddingTop="#dimen/activity_vertical_margin"
tools:context="com.test.scenetransitions.MainActivity">
<ImageView
android:id="#+id/iv_test"
android:layout_width="200dp"
android:layout_height="200dp"
android:layout_centerInParent="true"
android:src="#android:drawable/ic_dialog_email"
android:tint="#color/colorAccent"/>
</RelativeLayout>
And here is screenshot took in proper time during the transition:

The issue is with <item name="android:windowBackground">#null</item> you should never ever use null for window background. Replace it with <item name="android:windowBackground">#android:color/transparent</item>
When you set it to null Android doesn't know what to draw and it could draw any garbage from GPU. So you should explicitly specify transparent background.

I copy pasted your code, but i didn't get any drawing issues. I mean when the second page opens up, the image is a bit blurry(pixelated) that's cause of the small size of the actual image(if that's the case just use a bigger image in the second activity). May be its your device. I tested this in Moto E2. For me the transition is smooth, no drawing issues what so ever.

Related

App won't run in landscape

Today I started trying to optimize my application for landscape mode. But I just cannot get my application to run in landscape mode, there are no settings that I have enabled to force portrait.
I am showing my placeholder screen as an example.
I also double checked that auto rotate in my AVD is enabled. I have this problem on every AVD.
Declared like this in my manifest.
<activity
android:name=".PlaceholderActivity"
android:theme="#style/AppTheme.NoActionBar" />
My layout looks like this.
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#color/background_material_light"
android:orientation="vertical"
android:animateLayoutChanges="true" >
<View
android:id="#+id/icon"
android:layout_width="350dp"
android:layout_height="350dp"
android:layout_centerInParent="true"
android:background="#drawable/feedyr_full" />
<ProgressBar
android:id="#+id/progress"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/icon"
android:layout_centerHorizontal="true"
android:visibility="visible" />
<include
layout="#layout/helper_error"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/icon"
android:layout_centerHorizontal="true" />
</RelativeLayout>
And my Theme looks like this.
<style name="AppTheme.NoActionBar" parent="Theme.AppCompat.Light.NoActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">#color/colorPrimary</item>
<item name="colorPrimaryDark">#color/colorPrimaryDark</item>
<item name="colorAccent">#color/colorAccent</item>
<item name="android:colorButtonNormal">#color/colorAccent</item>
<item name="android:windowIsTranslucent">true</item>
<item name="android:windowBackground">#android:color/transparent</item>
<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>
<item name="android:windowDrawsSystemBarBackgrounds">true</item>
<item name="android:windowTranslucentStatus">true</item>
</style>
There is also nothing is my class that's forcing portrait
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_placeholder);
config = FirebaseRemoteConfig.getInstance();
model = Model.getInstance();
....
What am I missing?
Try setting the activity orientation to sensor :
<activity
android:name=".PlaceholderActivity"
android:theme="#style/AppTheme.NoActionBar"
android:orientation="sensor"/>
in your AndroidManifest
<activity
android:name=".MainActivity"
android:configChanges="orientation|keyboardHidden|screenSize"
android:label="#string/app_name"
android:theme="#style/AppTheme.NoActionBar" />
and in MainActivity.java
public void onConfigurationChanged(Configuration newConfig) {
super.onConfigurationChanged(newConfig);
if (newConfig.orientation== Configuration.ORIENTATION_PORTRAIT)
{
}
else if (newConfig.orientation == Configuration.ORIENTATION_LANDSCAPE)
{
}
}
hope it`s help
Don't ask me why, but suddenly the landscape mode works. I pressed the screen rotation buttons on the right menu. When it went back in landscape it suddenly worked. Did this before so don't know why it suddenly started to work.
I did not change anything in my code, theme, manifest or layout...
Try to enable the emulator screen rotation mode to work.

How to hide Title Android

i am trying to make a mini-game program and i cant get the title bar to go away i have already tried the following getActionBar().hide(); , requestWindowFeature(Window.FEATURE_NO_TITLE); here is what i have so far.
package com.example.marcus.game;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.Window;
public class MainActivity extends AppCompatActivity {
protected void onCreate(Bundle savedInstanceState) {
requestWindowFeature(Window.FEATURE_NO_TITLE);
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
}
XML
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout 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:paddingBottom="#dimen/activity_vertical_margin"
android:paddingLeft="#dimen/activity_horizontal_margin"
android:paddingRight="#dimen/activity_horizontal_margin"
android:paddingTop="#dimen/activity_vertical_margin"
android:theme="#android:style/Theme.Black.NoTitleBar.Fullscreen"
tools:context="com.example.marcus.game.MainActivity"
android:background="#752fdf">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text="Large Text"
android:id="#+id/textView"
android:layout_alignParentTop="true"
android:theme="#android:style/Theme.Black.NoTitleBar.Fullscreen"
android:layout_centerHorizontal="true" />
</RelativeLayout>
Add this style to your styles.xml:
<style name="AppTheme.Fullscreen" parent="Theme.AppCompat.Light.NoActionBar">
<item name="android:windowNoTitle">true</item>
<item name="windowActionBar">false</item>
<item name="android:windowFullscreen">true</item>
<item name="android:windowContentOverlay">#null</item>
</style>
You can also add :
<item name="android:windowTranslucentStatus">true</item>
to your v21 style.
Change your androidmanifest.xml to use the style:
<activity
android:name="MainActivity"
android:theme="#style/AppTheme.Fullscreen"/>
see About the Full Screen And No Titlebar from manifest
add
android:theme="#android:style/Theme.NoTitleBar"
to your activity or application in the manifest
and change
"extends AppCompatActivity"
to
"extends Activity"

how to delete the toolbar in android design

The red frame should not have in my code, but after I updated my Android Studio, it is showed in all of my APPS. please click and see the picture.
How to delete the red frame from my code? And it could not find in its design/text. The blue frame's begin code is:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<EditText
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:id="#+id/activity_login_user_email_edt"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_marginTop="100dp"
android:layout_marginLeft="20dp"
android:layout_marginRight="20dp"
android:paddingLeft="35dp"
android:autoText="true"
android:hint="e-mail" />
The Answer Skynet posted is correct,but this is the programatical way
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// Full Screen and remove toolbar
requestWindowFeature(Window.FEATURE_NO_TITLE);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
setContentView(R.layout.main);
}
That is the theme your activity is extending from. You change it in the styles.xml. Then you need to update this setting in the Manifest.
You need to add this to styles.xml:
<style name="Theme.AppCompat.Light.NoActionBar.FullScreen" parent="#style/Theme.AppCompat.Light">
<item name="windowNoTitle">true</item>
<item name="windowActionBar">false</item>
<item name="android:windowFullscreen">true</item>
<item name="android:windowContentOverlay">#null</item>
</style>
Then in your AndroidManifest.xml for this Activity:
<activity
android:name=".YourActivity"
android:label="#string/title_activity_main"
android:screenOrientation="landscape"
android:theme="#style/Theme.AppCompat.Light.NoActionBar.FullScreen">
</activity>
The above will work if you are extending from AppCompatActivity which should look like:
public class YourActivity extends AppCompatActivity{}

Activity UI elements not showing

Adding UI elements to my activity changes nothing when app runs - I get an empty activity.
I've attached my activity layout, manifest and styles file.
Activity Layout:
<RelativeLayout 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:paddingLeft="#dimen/activity_horizontal_margin"
android:paddingRight="#dimen/activity_horizontal_margin"
android:paddingTop="#dimen/activity_vertical_margin"
android:paddingBottom="#dimen/activity_vertical_margin" tools:context=".MainActivity"
android:id="#+id/activity_main"
android:clickable="false">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text="text"
android:id="#+id/textView"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_marginTop="75dp"
android:visibility="visible"
android:editable="false" />
Manifest looks like:
<?xml version="1.0" encoding="utf-8"?>
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<application
android:allowBackup="true"
android:icon="#mipmap/my_icon"
android:label="#string/app_name">
<activity
android:name=".MainActivity"
android:theme="#style/myTheme"
android:label=""
>
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
Styles looks like:
<resources>
<style name="myTheme" parent="Theme.AppCompat.Light.NoActionBar">
<item name="android:windowNoTitle">false</item>
<item name="windowActionBar">false</item>
<item name="android:windowFullscreen">true</item>
</style>
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
</style>
make sure to use the right oncreate() method as we have two methods:
public void onCreate(Bundle savedInstanceState, PersistableBundle persistentState)
and
protected void onCreate(#Nullable Bundle savedInstanceState)
What does your MainActivity look like? Have you used
setContentView(R.layout.main_activity)
in onCreate() ?
I have found the problem. Apparently a webView was declared
setContentView(webView);
In my main activity.
I came across the same issue when I started developing on android recently.
The problem was I had an infinite loop running in the onCreate(Bundle savedInstanceState) method of the activity.
Though all the elements were present in the layout, since the activity was entering an infinite loop after its created, no UI elements were rendered
Hope this helps

Android Activity with transparent background and Action Bar?

im trying to build a Popup for my Android App. It should be a Activity which doesn't use the whole screen, just 200dp on the right side of the screen and the rest should be transparent black.
A Picture of what it looks like / what i want to have: http://i.stack.imgur.com/6APy6.png
Java:
public class ActivitySettings extends BaseActivity implements View.OnTouchListener {
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_settings);
setFinishOnTouchOutside(true);
}
#Override
public boolean onTouch(View view, MotionEvent motionEvent) {
System.out.println("Klicked " + motionEvent.getAction());
// If we've received a touch notification that the user has touched
// outside the app, finish the activity.
if (MotionEvent.ACTION_OUTSIDE == motionEvent.getAction()) {
finish();
return true;
}
return false;
}
}
AndroidManifest:
<activity
android:name="com.cleverlize.substore.test.ActivitySettings"
android:label="#string/title_activity_settings"
android:theme="#style/Theme.Transparent">
</activity>
Style XML:
<style name="Theme.Transparent" parent="Theme.AppCompat.Light">
<item name="android:windowIsTranslucent">true</item>
<item name="android:windowNoTitle">true</item>
<item name="android:windowBackground">#color/itemPremium</item>
<item name="android:windowContentOverlay">#null</item>
<item name="android:windowIsFloating">true</item>
<item name="android:backgroundDimEnabled">true</item>
</style>
So i just need the adjustment and the ActionBar... please Help :)
You can have acitivity without titlebar and actionbar in manifest with the theme as
<activity
android:name="com.demo.YourActivity"
android:theme="#android:style/Theme.Translucent.NoTitleBar" />
and for layout
for transperancy your base layout background will be android:background="#android:color/transparent"
your container layout will be
design as per your requirement with android:layout_alignParentRight="true"
Go to Android manifest file-> search for the required activity-> include this:
<--android:theme="#android:style/Theme.Translucent"-->
in the activity tag like this:
<activity
android:name=".Services"
android:label="#string/title_activity_services"
android:theme="#android:style/Theme.Translucent" >
</activity>
Suppose your Activity layout is inside the LinearLayout, set the inner layout margin from left 200sp:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#000000"
android:orientation="vertical" >
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginLeft="200sp"
android:background="#FFFFFF"
android:orientation="vertical" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:text="Text Display"
android:textColor="#000000" />
</LinearLayout>
</LinearLayout>

Categories

Resources