Last active
November 3, 2015 13:16
-
-
Save rajohns08/04346e93e0c5cffc6e47 to your computer and use it in GitHub Desktop.
Android - Skeleton layout for using a background image for a layout while maintaining the image's aspect ratio
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="utf-8"?> | |
<FrameLayout | |
xmlns:android="http://schemas.android.com/apk/res/android" | |
android:layout_width="match_parent" | |
android:layout_height="match_parent"> | |
<ImageView | |
android:id="@+id/background_image_view" | |
android:layout_width="match_parent" | |
android:layout_height="match_parent" | |
android:scaleType="centerCrop" | |
android:src="@drawable/your_drawable"/> | |
<LinearLayout | |
android:id="@+id/your_actual_layout" | |
android:layout_width="match_parent" | |
android:layout_height="wrap_content" | |
android:orientation="vertical"> | |
</LinearLayout> | |
</FrameLayout> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// later if you want to change bg image in code | |
backgroundImageView.setImageResource(R.drawable.your_drawable); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment