我需要一些帮助,我有一个想法,我有一个应用程序,我正在开发。
我有一个主要活动,其中有一个背景图像比屏幕宽,我想使该图像的外观和行为像Android的主屏幕
但我不能够使背景的ImageView表现得像这样。 这里是我的代码:使安卓活动看起来和行动像android主屏幕背景
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);
这是我的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>
这是我的行为看起来像此刻(我一直在尝试与setScaleType方法,不要怪我哈哈)
如果是自动完成或如果我h大街上滚动自己,我只是想让它看起来和行为像Android主屏幕背景。我也试图把图像作为相对布局的背景,没有成功
在此先感谢!
编辑
试图链轮添加到我的项目,我有一个恼人的类没有发现错误,在v4.view.ViewPager,我真的开始得到这个螺母。 这是我的依赖模块中的项目的摇篮文件:
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'
}
我该如何解决这个问题?
iadd'android:scaleType =“fitXY”'到'ImageView' – hrskrs
如果我这样做,它很合适,但图像被拉伸,看起来不太好:/ – pamobo0609
比引用[this link](http:// stackoverflow.com/questions/13925530/imageview-fit-without-stretching-the-image) – hrskrs