android - how can i style this activity to be show in square style -


i have activity_main.xml nested linear layout creating blocks , have little problem xml code :

<?xml version="1.0" encoding="utf-8"?> <linearlayout     xmlns:android="http://schemas.android.com/apk/res/android"     xmlns:tools="http://schemas.android.com/tools"     android:layout_width="match_parent"     android:layout_height="match_parent"     android:orientation="vertical">      <android.support.v7.widget.toolbar         xmlns:android="http://schemas.android.com/apk/res/android"         android:id="@+id/xmltoolbarmain"         android:layout_width="match_parent"         android:layout_height="?attr/actionbarsize"         android:background="#f44336"/>      <scrollview xmlns:android="http://schemas.android.com/apk/res/android"         android:layout_width="match_parent"         android:layout_height="match_parent">          <linearlayout             android:layout_width="match_parent"             android:layout_height="match_parent"             android:orientation="vertical"             tools:context="gridheader.majid.com.bahaltarinha.mainactivity">              <!-- row  1 -->              <linearlayout                 android:layout_width="match_parent"                 android:layout_height="wrap_content"                 android:layout_margin="3dp">                  <!-- cooking -->                 <imageview                     android:layout_width="0dp"                     android:layout_height="130dp"                     android:layout_marginright="2dp"                     android:layout_weight="1"                     android:scaletype="fitxy"                     android:src="@drawable/cooking_r" />                  <!-- celebrity -->                 <imageview                     android:layout_width="0dp"                     android:layout_height="130dp"                     android:layout_marginleft="2dp"                     android:layout_marginright="2dp"                     android:layout_weight="2"                     android:scaletype="fitxy"                     android:src="@drawable/celebrity_r" />              </linearlayout>              <!-- row  2 -->             <linearlayout                 android:layout_width="match_parent"                 android:layout_height="wrap_content"                 android:layout_margin="2dp">                  <!-- makeup -->                 <imageview                     android:layout_width="0dp"                     android:layout_height="260dp"                     android:layout_marginleft="3dp"                     android:layout_marginright="2dp"                     android:layout_weight="2"                     android:background="#63ae4f"                     android:scaletype="fitxy"                     android:src="@drawable/makeup_r" />                  <linearlayout                     android:layout_width="0dp"                     android:layout_height="260dp"                     android:layout_marginleft="2dp"                     android:layout_weight="1"                     android:orientation="vertical">                       <!-- kids -->                      <imageview                         android:layout_width="match_parent"                         android:layout_height="130dp"                         android:layout_marginbottom="2dp"                         android:layout_marginright="2dp"                         android:layout_weight="1"                         android:scaletype="fitxy"                         android:src="@drawable/kids_r" />                       <!-- fashion -->                     <imageview                         android:layout_width="match_parent"                         android:layout_height="130dp"                         android:layout_marginright="2dp"                         android:layout_margintop="2dp"                         android:layout_weight="1"                         android:scaletype="fitxy"                         android:src="@drawable/fashion_r" />                  </linearlayout>              </linearlayout>              <!-- row  3 -->              <linearlayout                 android:layout_width="match_parent"                 android:layout_height="wrap_content"                 android:layout_margin="2dp"                 android:orientation="horizontal">                  <!-- lifestyle  -->                 <imageview                     android:layout_width="0dp"                     android:layout_height="130dp"                     android:layout_marginleft="2dp"                     android:layout_marginright="2dp"                     android:layout_weight="1"                     android:scaletype="fitxy"                     android:src="@drawable/lifestyle_r" />                  <!-- taghzieh  -->                 <imageview                     android:layout_width="0dp"                     android:layout_height="130dp"                     android:layout_marginleft="1dp"                     android:layout_marginright="2dp"                     android:layout_weight="1"                     android:scaletype="fitxy"                     android:src="@drawable/nutr_r" />              </linearlayout>             <!-- fal -->              <!--<imageview-->             <!--android:layout_margin="2dp"-->             <!--android:layout_width="match_parent"-->             <!--android:layout_height="130dp"-->             <!--android:background="#e74c3c"/>-->               <!-- row  4 -->           </linearlayout>     </scrollview> </linearlayout> 

this screen shot layout . image left activity_main , image right layout want make . want show images in square style (with same length , width )not stretch rectangle :

enter image description here

ok , hope purpose , think image useful :

change scale type of image views fit_xy center_crop

this should fix distorted images.


Comments

Popular posts from this blog

ruby - Trying to change last to "x"s to 23 -

jquery - Clone last and append item to closest class -

c - Unrecognised emulation mode: elf_i386 on MinGW32 -