XML : Scale Icon and Center it in Linear Layout - Android

I have a layout with 4 boxes that automaticly scale depending on screensize. What I want now is an Icon in the center of the box that also automaticly scales depending on the screensize.

Here is my Layout:

  <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"  android:layout_width="match_parent"  android:layout_height="match_parent"  android:orientation="vertical"  android:background="#ffffff"  android:padding="10dp" >    <LinearLayout      android:layout_width="match_parent"      android:layout_height="0dp"      android:layout_weight=".5"      android:orientation="horizontal">        <LinearLayout          android:layout_width="0dp"          android:layout_height="match_parent"          android:layout_weight=".5"          android:orientation="vertical"          android:layout_marginRight="5dp"          android:layout_marginBottom="5dp"          android:background="@drawable/runde_ecken_grau"          android:weightSum="1">        </LinearLayout>        <LinearLayout          android:layout_width="0dp"          android:layout_height="match_parent"          android:layout_weight=".5"          android:orientation="vertical"          android:layout_marginLeft="5dp"          android:layout_marginBottom="5dp"          android:background="@drawable/runde_ecken_grau">            <TextView              android:layout_width="wrap_content"              android:layout_height="wrap_content"              android:textAppearance="?android:attr/textAppearanceLarge"              android:text="Name"              android:id="@+id/textView" />            <TextView              android:layout_width="wrap_content"              android:layout_height="wrap_content"              android:textAppearance="?android:attr/textAppearanceLarge"              android:text="Alter"              android:id="@+id/textView2" />            <TextView              android:layout_width="wrap_content"              android:layout_height="wrap_content"              android:textAppearance="?android:attr/textAppearanceLarge"              android:text="Krankheiten"              android:id="@+id/textView3" />            <TextView              android:layout_width="wrap_content"              android:layout_height="wrap_content"              android:textAppearance="?android:attr/textAppearanceLarge"              android:text="Medikamente"              android:id="@+id/textView4" />            <TextView              android:layout_width="wrap_content"              android:layout_height="wrap_content"              android:textAppearance="?android:attr/textAppearanceLarge"              android:text="Wohnsitz"              android:id="@+id/textView5" />            <Button              android:layout_width="fill_parent"              android:layout_height="fill_parent"              android:id="@+id/button3"              android:layout_gravity="center_horizontal"              android:background="@drawable/runde_ecken_grau" />      </LinearLayout>    </LinearLayout>    <LinearLayout      android:layout_width="match_parent"      android:layout_height="0dp"      android:layout_weight=".5"      android:orientation="horizontal">        <LinearLayout          android:layout_width="0dp"          android:layout_height="match_parent"          android:layout_weight=".5"          android:orientation="vertical"          android:layout_marginRight="5dp"          android:layout_marginTop="5dp">            <Button              android:layout_width="fill_parent"              android:layout_height="fill_parent"              android:id="@+id/button"              android:background="@drawable/runde_ecken_blau" />      </LinearLayout>        <LinearLayout          android:layout_width="0dp"          android:layout_height="match_parent"          android:layout_weight=".5"          android:orientation="vertical"          android:layout_marginLeft="5dp"          android:layout_marginTop="5dp">            <Button              android:layout_width="fill_parent"              android:layout_height="fill_parent"              android:id="@+id/button2"              android:background="@drawable/runde_ecken_rot" />        </LinearLayout>    </LinearLayout>    

This is what it looks like now

No comments:

Post a Comment