什麼是處理圖像寬高比的正確和乾淨的方法?如何處理不同分辨率和旋轉的圖像寬高比
在我的應用程序,如果我旋轉屏幕,我失去了縱橫比和我的圖像出現難看得要命 - 看到這些圖像進行比較的我的應用程序和Play商店 - http://imgur.com/a/GriwP#0
這是我正在做:
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:orientation="horizontal"
android:layout_gravity="center" >
<Button
android:id="@+id/btnStark"
android:layout_marginLeft="4dp"
android:layout_marginRight="2dp"
android:layout_width="fill_parent"
android:layout_height="100dp"
android:layout_weight="1"
android:background="@drawable/stark"
android:gravity="center|bottom"
android:layout_gravity="top" />
<Button
android:id="@+id/btnLannister"
android:layout_marginLeft="2dp"
android:layout_marginRight="4dp"
android:layout_width="fill_parent"
android:layout_height="100dp"
android:layout_weight="1"
android:background="@drawable/stark"
android:gravity="center|bottom"
android:layout_gravity="top" />
</LinearLayout>
我該如何處理高度?我應該設置一個固定值嗎?或者有什麼辦法可以自動保持寬高比?
我使用的是像400x300像素,
謝謝。 ImageView真正解決了寬高比問題。 另一個問題:爲android:layout_height設置固定值是否是最佳做法? – Ricardo
謝謝@Ricardo。請考慮標記此答案爲已接受,如果它解決了您的問題!原因如下:http://meta.stackexchange.com/a/5235 –