I need some help with an idea I had for an application I'm developing.
I have a main activity, which has a background image that is wider than the screen, and I wanted to make that image look and act like the android main screen
But I not being able to make the background ImageView to act like it.
Here's my code:
MainActivity:
// slide effect in background
background = (ImageView) findViewById(R.id.imgBackMain);
backgroundAnim = new TranslateAnimation(TranslateAnimation.ABSOLUTE, 0f, TranslateAnimation.ABSOLUTE,
100f, TranslateAnimation.ABSOLUTE, 0f, TranslateAnimation.ABSOLUTE, 0f);
backgroundAnim.setDuration(10000);
backgroundAnim.setRepeatCount(-1);
backgroundAnim.setRepeatMode(Animation.REVERSE);
backgroundAnim.setInterpolator(new LinearInterpolator());
background.setAnimation(backgroundAnim);
And here's my activity.xml:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/rlMain"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#088A08"
tools:context="com.racsa.UI.MainActivity">
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/imgBackMain"
android:layout_alignParentTop="true"
android:layout_alignParentLeft="true"
android:src="@mipmap/pantalla_principal"
android:layout_alignParentStart="true"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/btnMain"
android:onClick="goMaps"
android:layout_centerVertical="true"
android:layout_centerHorizontal="true" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/lblLoginPopUp"
android:id="@+id/btnOpenLoginOptions"
android:onClick="openLoginOptions"
android:layout_marginBottom="15dp"
android:textColor="#ffffff"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text="@string/lblTurismo"
android:id="@+id/lblTurismo"
android:textColor="#ffffff"
android:layout_marginBottom="15dp"
android:layout_above="@+id/btnOpenLoginOptions"
android:layout_centerHorizontal="true" />
</RelativeLayout>
This is how my activity looks like at the moment (I've been trying with the setScaleType method, don't blame me lol)
It doesn't matter if is done automatically or if I have to scroll myself, I just want to make it look and act like the android main screen background. I have also tried to put the image as a background for the Relative layout, with no success
Thanks in advance!
EDIT
After trying to add Sprockets to my project, I have an annoying Class not found error, in v4.view.ViewPager and I'm really starting to get nuts with this.
This is my dependencies module in the projects' Gradle file:
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:support-v4:22.1.+'
compile 'com.google.code.gson:gson:2.2.4'
// Google Play Services
compile 'com.google.android.gms:play-services:6.5.87'
// Facebook
compile 'com.facebook.android:facebook-android-sdk:4.0.1'
compile 'net.sf.sprockets:sprockets-android:2.4.0'
}
How can I fix this?