I have a design in which i need to get image view in centre alignment. how can i manage to get a image view with centered image and make its size compatible with all screens.if i give hard code size ,that doesn't set on some devices.Do i have to make design for all screens individual or i can manage it somehow through one XML. here is my XML file :
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="200dp"
android:layout_margin="5dp"
android:padding="5dp"> <LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/backgrondcolor"
android:orientation="horizontal"
android:weightSum="4"> <LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="2"
android:orientation="vertical"> <ImageView
android:id="@id/image"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:cropToPadding="true"
android:scaleType="fitXY"
android:src="@drawable/image_corner" /> </LinearLayout> <LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_margin="7dp"
android:layout_weight="1.8"
android:orientation="vertical"
android:weightSum="5.5">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1.5"> <TextView
android:id="@+id/assemblyName"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:maxLines="2"
android:textAppearance="@style/Base.TextAppearance.AppCompat.Medium"
android:textColor="@color/colortoolbartitle"
/> </LinearLayout> <LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="3"> <TextView
android:id="@+id/asemblyinformation"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textAppearance="@style/Base.TextAppearance.AppCompat.Small"
android:textColor="@color/colortoolbartitle" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:orientation="horizontal"
android:weightSum="7">
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1">
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:src="@drawable/image" />
</LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1.5">
<TextView
android:id="@+id/totalassemblies"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:src="@mipmap/ic_launcher"
android:textAppearance="@style/Base.TextAppearance.AppCompat.Small"
android:textColor="@color/colortoolbartitle" />
</LinearLayout>
<LinearLayout android:layout_width="0dp"
android:layout_height="wrap_content" android:layout_weight="2">
<ImageView android:id="@+id/imageweb"
android:layout_width="wrap_content"
android:layout_height="wrap_content" android:src="@drawable/web" />
</LinearLayout> <LinearLayout android:layout_width="0dp"
android:layout_height="match_parent" android:layout_weight="2">
<ImageView android:id="@+id/imagenextpage"
android:layout_width="match_parent"
android:layout_height="match_parent" android:clickable="true"
android:src="@drawable/link" /> </LinearLayout> </LinearLayout>
</LinearLayout> </LinearLayout> </LinearLayout>