약간의 변화 등이다 가장 적합한 두 번째 요소를 추가해야합니다.
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#2A7800"<---- optional background color to fit the image. to make it blend in
android:orientation="vertical">
<ImageView
android:id="@+id/imageView"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="center_horizontal"<--- centers
android:adjustViewBounds="true"
android:scaleType="fitXY"<--- makes sure the image fits into the layout my matching the screen size.
android:src="@drawable/splash" />
</LinearLayout>
ImageView를 추가하는 것은 android : background를 사용하고 이미지를 설정하는 것보다 더 나은 성능을 발휘하는 가장 좋은 방법입니다. 나는 이것을 ScrollView에서 발견했으며 마스터 부모는 android : 배경을 이미지로 설정했다. 그것은 ScrollView를 극단적으로 느리게 만들었습니다.
또한이 방법으로 특정 레이아웃을 사용할 필요가 없습니다. RelativeLayout, FrameLayout, LinearLayout을 사용할 수 있습니다. 예외는 ListView를,의 GridView는
출처
2016-08-29 18:43:55
Zoe
가능한 [Android : Center and image] (http://stackoverflow.com/questions/6101874/android-center-an-image) – Zoe