我有一個imageview &相對佈局,其中包含兩個按鈕的佈局應該與底部對齊,並且圓形圖像應伸展以佔用剩餘空間。我嘗試了其他答案,但無法做到這一點。我有下面的代碼和圖像。如何將特定佈局對齊到底部並修復imageview的大小以覆蓋剩餘空間?
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/cardview_light_background"
android:clickable="true">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<include layout="@layout/toolbar_child_with_progress"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/toolbar_child"/>
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@+id/toolbar_child">
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
>
<ImageView
android:id="@+id/iv_SavedInvoice"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:src="@drawable/service_app_logo"
android:scaleType="fitStart"
android:adjustViewBounds="true"
android:layout_centerHorizontal="true"
/>
<LinearLayout
android:id="@+id/ll_inner"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_below="@+id/iv_SavedInvoice"
android:layout_alignParentBottom="true"
>
<Button
style="@style/PrimaryButton"
android:layout_marginTop="20dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/form_proof_replace_invoice"
android:id="@+id/button_ReplaceInvoice" />
<Button
style="@style/NoBorderButton"
android:layout_marginTop="20dp"
android:layout_marginBottom="20dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/form_proof_next"
android:id="@+id/button_SavedProofNext" />
</LinearLayout>
</RelativeLayout>
</ScrollView>
</RelativeLayout>
謝謝,scrollview是罪魁禍首。其實我有一些其他的代碼,我沒有發佈。我在scrollview之上移動了佈局,並且它正在工作。 –
你能否幫我一個小忙。我已經使用「fitXY」來適應圖像的高度以覆蓋按鈕上的高度間隙。如何保持橫向圖像的縱橫比並將圖像的寬度發送出屏幕? –
與centerCrop重新鑲嵌xY。它將保持長寬比。但它會使一些地區crop。。如果它很好,試試這個。或者可以嘗試一些ImageView的庫。 –