我需要一些幫助,我有一個想法,我有一個應用程序,我正在開發。
我有一個主要活動,其中有一個背景圖像比屏幕寬,我想使該圖像的外觀和行爲像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