У меня есть ImageView внутри ScrollView. Ширина и высота ImageView и match_parent и wrap_content. Но ImageView имеет небольшое дополнение слева и справа от него. Изображение загружается с сервера и отображается в ImageView.ImageView - Нежелательное дополнение слева и справа
Вот мой XML:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res/com.xx.xxx"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<include
android:id="@+id/toolbar"
layout="@layout/toolbar_without_spinner" />
<ScrollView
android:id="@+id/scrollview"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:scrollbars="none" >
<LinearLayout
android:id="@+id/ll_select_activity"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/green"
android:orientation="vertical" >
<LinearLayout
android:id="@+id/ll_feature"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<LinearLayout
android:id="@+id/text_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:orientation="vertical"
android:paddingBottom="10dp"
android:paddingTop="10dp"
android:visibility="gone" >
<TextView
android:id="@+id/item_features_title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:text="@string/empty"
android:textAppearance="?android:attr/textAppearanceLarge" />
<TextView
android:id="@+id/item_features_description"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:text="@string/empty"
android:textAppearance="?android:attr/textAppearanceMedium" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<!-- ImageView with the problem -->
<ImageView
android:id="@+id/item_features_imageview_icon"
android:layout_width="0dip"
android:layout_height="wrap_content"
android:layout_weight="1"
android:adjustViewBounds="true"
android:padding="0dp"
android:contentDescription="@string/item_features_icon"
android:cropToPadding="false"
android:scaleType="fitCenter" />
</LinearLayout>
</LinearLayout>
....
....
</LinearLayout>
</ScrollView>
</LinearLayout>
Вы можете найти скриншоты ниже:
Как я сделать ImageView соответствовать общей ширине Scrollview и также поддерживать соотношение сторон?
Не должен ли «fitCenter» автоматически соответствовать краям, согласно документации?
ImageView.ScaleType. FIT_CENTER
Вычислить масштаб, который будет поддерживать исходное соотношение сторон SRC, но также гарантирует, что SRC подходит полностью внутри ДСТ. По крайней мере одна ось (X или Y) будет точно соответствовать. Результат центрирован внутри dst.
попробуйте изменить 'andro id: scaleType = "fitCenter" 'to android: scaleType =" fitXY "' –
ok .. Но, будет ли fitXY поддерживать «соотношение сторон» загруженного изображения? Я хочу поддерживать соотношение сторон, потому что я не хочу, чтобы изображение растягивалось или сжималось –