【发布时间】:2018-02-05 20:38:50
【问题描述】:
我希望它用我的旋转图像填充 ImageView。 这是我的 ImageView 代码:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<ImageView
android:id="@+id/imgResult"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:rotation="90"
android:scaleType="fitXY"
android:src="@drawable/img_ex" />
<LinearLayout
android:id="@+id/linearLayout"
style="?android:attr/buttonBarStyle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintStart_toStartOf="parent">
<Button
android:id="@+id/btCancelar"
style="?android:attr/buttonBarButtonStyle"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Cancelar"
app:layout_constraintBottom_toBottomOf="parent"
/>
<View
android:layout_width="1dp"
android:layout_height="match_parent"
android:background="#fff" />
<Button
android:id="@+id/btSalvar"
style="?android:attr/buttonBarButtonStyle"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Salvar"
app:layout_constraintBottom_toBottomOf="parent"
/>
</LinearLayout>
</LinearLayout>
我不介意拉伸图片,我只想填充 ImageView 组件
PS:我已经尝试过这个解决方案Scaling ImageView to device width
【问题讨论】:
-
@AkashPal 不起作用。我仍然得到图像周围的白色边框
-
@AkashPal 也不工作
-
如果去掉权重,让 ImageView 匹配父级宽高会怎样?
-
fitXY 不需要adjustViewBounds
-
能否请您发布您的图片,以便我们检查