Reputation:
Creating layout and can not solve margins up and above the ImageView
(and don't understand why they appear).
Logo itself is without these margins.
I use layout_width="250dp" the same as for the buttons.
And layout_height="wrap content".
Layout code is here:
<?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="@drawable/menu_background"
android:gravity="center"
android:layout_gravity="center"
android:orientation="vertical"
>
<ImageView
android:layout_width="250dp"
android:layout_height="wrap_content"
android:src="@drawable/game_logo"
/>
<Button
android:id="@+id/start_button"
style="@style/menuButtonStyle"
android:layout_margin="5dp"
android:text="@string/start_button" />
<Button
android:id="@+id/result_button"
style="@style/menuButtonStyle"
android:layout_margin="5dp"
android:text="@string/high_score" />
<Button
android:id="@+id/settings_button"
style="@style/menuButtonStyle"
android:layout_margin="5dp"
android:text="@string/settings" />
<Button
android:id="@+id/about_button"
style="@style/menuButtonStyle"
android:layout_margin="5dp"
android:text="@string/about_button" />
</LinearLayout>
Can I manage this without setting ImageView's layout_height in dp?
Upvotes: 0
Views: 1931
Reputation: 2293
Set following property in your ImageView
:
android:adjustViewBounds="true"
Upvotes: 2