Actually i have to create a xml layout as similar to the below screenshot and i know there is two cardView in linear Layout of having weight
but can anyone check my code and guide me i on the correct path or not...
xml code:
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_marginTop="#dimen/padding_top_bottom">
<LinearLayout android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="0.6"
>
<android.support.v7.widget.CardView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:cardBackgroundColor="#color/cardViewbackground">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="#dimen/icon_btw_margin"
android:layout_marginLeft="#dimen/padding"
android:src="#drawable/service_provide_box_icon"
android:layout_marginTop="#dimen/padding"
android:layout_marginEnd="#dimen/icon_btw_padding"
android:layout_marginRight="#dimen/icon_btw_padding" />
<TextView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_marginStart="30dp"
android:layout_marginLeft="#dimen/icon_btw_padding"
android:text="#string/testAddress"
android:textColor="#color/buttonbackground"
android:layout_marginEnd="#dimen/icon_btw_padding"
android:layout_marginRight="#dimen/icon_btw_padding"
/>
</android.support.v7.widget.CardView>
</LinearLayout>
<LinearLayout android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1.7"
android:layout_marginStart="#dimen/padding_top_bottom"
android:layout_marginLeft="#dimen/padding_top_bottom"
>
<android.support.v7.widget.CardView
android:layout_width="wrap_content"
android:layout_height="fill_parent"
app:cardBackgroundColor="#color/cardViewbackground">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:src="#drawable/car_services_icon_one"
android:layout_marginLeft="2dp"
android:layout_marginRight="2dp"
/>
</android.support.v7.widget.CardView><android.support.v7.widget.CardView
android:layout_width="wrap_content"
android:layout_height="fill_parent"
app:cardBackgroundColor="#color/cardViewbackground"
android:layout_marginStart="6dp"
android:layout_marginLeft="#dimen/icon_btw_margin"
android:layout_marginEnd="5dp"
android:layout_marginRight="5dp">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:src="#drawable/car_services_icon_three"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
/>
</android.support.v7.widget.CardView>
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_marginTop="0sp">
<LinearLayout android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="0.6"
>
<android.support.v7.widget.CardView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
app:cardBackgroundColor="#color/cardViewbackground">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="#dimen/icon_btw_margin"
android:layout_marginLeft="#dimen/padding"
android:src="#drawable/mechanics_available_icon"
android:layout_gravity="top"
android:layout_marginTop="#dimen/padding"
android:layout_marginEnd="#dimen/icon_btw_padding"
android:layout_marginRight="#dimen/icon_btw_padding" />
<TextView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_marginStart="30dp"
android:layout_marginLeft="#dimen/icon_btw_padding"
android:paddingTop="2dp"
android:text="#string/testMechanics"
android:textColor="#color/colorAccent"
android:layout_marginEnd="#dimen/icon_btw_padding"
android:layout_gravity="center_vertical"
android:layout_marginRight="#dimen/icon_btw_padding"
/>
</android.support.v7.widget.CardView>
</LinearLayout>
<LinearLayout android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1.7"
android:layout_marginStart="#dimen/padding_top_bottom"
android:layout_marginLeft="#dimen/padding_top_bottom"
>
<android.support.v7.widget.CardView
android:layout_width="wrap_content"
android:layout_height="fill_parent"
app:cardBackgroundColor="#color/cardViewbackground">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:src="#drawable/car_services_iconfour"
android:layout_marginLeft="2dp"
android:paddingTop="1sp"
android:layout_marginRight="2dp"
/>
</android.support.v7.widget.CardView><android.support.v7.widget.CardView
android:layout_width="wrap_content"
android:layout_height="fill_parent"
app:cardBackgroundColor="#color/cardViewbackground"
android:layout_marginStart="6dp"
android:layout_marginLeft="#dimen/icon_btw_margin"
android:layout_marginEnd="5dp"
android:layout_marginRight="5dp">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:src="#drawable/car_services_icon_two"
android:layout_marginLeft="2dp"
android:paddingTop="1sp"
android:layout_marginRight="2dp"
/>
</android.support.v7.widget.CardView>
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_marginTop="0sp">
<android.support.v7.widget.CardView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
app:cardBackgroundColor="#color/cardViewbackground">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="#dimen/icon_btw_margin"
android:layout_marginLeft="#dimen/padding"
android:src="#drawable/mechanics_available_icon"
android:layout_gravity="top"
android:layout_marginTop="#dimen/padding"
android:layout_marginEnd="#dimen/icon_btw_padding"
android:layout_marginRight="#dimen/icon_btw_padding" />
<TextView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_marginStart="30dp"
android:layout_marginLeft="#dimen/icon_btw_padding"
android:paddingTop="2dp"
android:text="#string/testMechanics"
android:textColor="#color/colorAccent"
android:layout_marginEnd="#dimen/icon_btw_padding"
android:layout_gravity="center_vertical"
android:layout_marginRight="#dimen/icon_btw_padding"
/>
</android.support.v7.widget.CardView>
</LinearLayout>
Use this XML . may be its helpful for your work..
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_marginTop="5sp"
android:weightSum="4">
<android.support.v7.widget.CardView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="3"
app:cardElevation="4dp"
app:cardUseCompatPadding="false"
app:cardBackgroundColor="#555555">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="10sp"
android:orientation="vertical">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#124688"
android:drawableStart="#drawable/yourimage"
android:text="500 west and avenue suite 5A"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#FFFFFF"
android:gravity="center_vertical"
android:drawableStart="#drawable/mechanic image"
android:text="12 Mechanics availabe"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#FFFFFF"
android:gravity="center_vertical"
android:drawableStart="#drawable/watchimage"
android:text="9:00AM to 11:00PM"/>
<RatingBar
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:scaleX="0.5"
android:scaleY="0.5"
/>
</LinearLayout>
</android.support.v7.widget.CardView>
<android.support.v7.widget.CardView
android:layout_width="0dp"
android:layout_height="match_parent"
app:cardElevation="4dp"
android:layout_weight="1"
app:cardUseCompatPadding="false"
app:cardBackgroundColor="#555555">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:weightSum="2">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal"
android:layout_weight="1"
android:weightSum="2">
<ImageView
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:src="#drawable/image1"/>
<ImageView
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:src="#drawable/image2"/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal"
android:layout_weight="1"
android:weightSum="2">
<ImageView
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:src="#drawable/image3"/>
<ImageView
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:src="#drawable/image4"/>
</LinearLayout>
</LinearLayout>
</android.support.v7.widget.CardView>
</LinearLayout>
my xml layout is working fine, everything coming in single screen no need to scroll in below 5.5 screens
but in 5.5 not able to see all thing in single screen i have to scroll to see remaining content that is two buttons showing bottom `
This is the screenshot.
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport="true">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="#+id/layout_container"
android:layout_marginBottom="20dp"
android:orientation="horizontal">
<ImageView
android:id="#+id/left_p"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:padding="20dp"
android:src="#drawable/left_arrow" />
<TextView
android:id="#+id/date_p"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_weight="5"
android:gravity="center_horizontal"
android:paddingLeft="60dp"
android:paddingRight="60dp"
android:text="Monday, 24 August, 2015"
android:textColor="#color/White" />
<ImageView
android:id="#+id/right_p"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:padding="20dp"
android:src="#drawable/right_arrow" />
</LinearLayout>
<LinearLayout
android:id="#+id/layout_container"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="1dp"
android:layout_marginLeft="2dp"
android:layout_marginRight="2dp"
android:layout_marginTop="2dp"
android:gravity="center_horizontal"
android:orientation="horizontal">
<LinearLayout
android:id="#+id/morning_layout"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_margin="1dp"
android:layout_weight="1"
android:background="#drawable/inactive_box"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="10dp"
android:orientation="horizontal"
android:paddingBottom="10dp">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="left"
android:orientation="vertical">
<ImageView
android:id="#+id/morning_icon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#drawable/morning_icon" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="right"
android:orientation="vertical">
<TextView
android:id="#+id/morning"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Morning"
android:textColor="#color/SlateGray" />
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:orientation="vertical">
<LinearLayout
android:id="#+id/tab_list1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_margin="20dp"
android:orientation="horizontal">
</LinearLayout>
</LinearLayout>
</LinearLayout>
<LinearLayout
android:id="#+id/noon_layout"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_margin="1dp"
android:layout_weight="1"
android:background="#drawable/inactive_box"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="8dp"
android:orientation="horizontal">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="left"
android:orientation="vertical">
<ImageView
android:id="#+id/noon_icon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#drawable/noon_icon" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="right"
android:orientation="vertical">
<TextView
android:id="#+id/noon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Noon"
android:textColor="#color/SlateGray" />
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:orientation="vertical">
<LinearLayout
android:id="#+id/tab_list2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_margin="20dp"
android:orientation="horizontal">
</LinearLayout>
</LinearLayout>
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="2dp"
android:layout_marginLeft="2dp"
android:layout_marginRight="2dp"
android:gravity="center_horizontal"
android:orientation="horizontal">
<LinearLayout
android:id="#+id/evening_layout"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_margin="1dp"
android:layout_weight="1"
android:background="#drawable/inactive_box"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="10dp"
android:orientation="horizontal"
android:paddingBottom="6dp">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="left"
android:orientation="vertical">
<ImageView
android:id="#+id/evening_icon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#drawable/evening_icon" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="right"
android:orientation="vertical">
<TextView
android:id="#+id/evening"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Evening"
android:textColor="#color/SlateGray" />
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:orientation="vertical">
<LinearLayout
android:id="#+id/tab_list3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_margin="20dp"
android:orientation="horizontal">
</LinearLayout>
</LinearLayout>
</LinearLayout>
<LinearLayout
android:id="#+id/night_layout"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_margin="1dp"
android:layout_weight="1"
android:background="#drawable/inactive_box"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="10dp"
android:orientation="horizontal">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="left"
android:orientation="vertical">
<ImageView
android:id="#+id/night_icon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#drawable/night_icon" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="right"
android:orientation="vertical">
<TextView
android:id="#+id/night"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Night"
android:textColor="#color/SlateGray" />
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:orientation="vertical">
<LinearLayout
android:id="#+id/tab_list4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_margin="20dp"
android:orientation="horizontal">
</LinearLayout>
</LinearLayout>
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:orientation="horizontal">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="20dp"
android:gravity="left"
android:orientation="vertical">
<ImageView
android:id="#+id/pillbox"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="7dp"
android:background="#drawable/pill_box_icon" />
<TextView
android:id="#+id/pill_box"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Pill Box"
android:textColor="#color/White"
android:textSize="13dp" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="20dp"
android:gravity="right"
android:orientation="vertical">
<ImageView
android:id="#+id/plus_icon"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:background="#drawable/plus_icon" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
</RelativeLayout>
I've arranged my image buttons and textView into a linear layout and I was wondering when I ran the application on the emulator and on my phone the image buttons was equally laid out but the were small and too far apart.
Here is a link of what the picture looks like.
http://i1207.photobucket.com/albums/bb478/Xxsoralover_1001xX/12980419_1141027192594851_48037648_n.png.jpeg?t=1460182699
This is the inside of my content xml file.
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingLeft="#dimen/activity_horizontal_margin"
android:paddingRight="#dimen/activity_horizontal_margin"
android:paddingTop="#dimen/activity_vertical_margin"
android:paddingBottom="#dimen/activity_vertical_margin"
app:layout_behavior="#string/appbar_scrolling_view_behavior"
android:orientation="vertical"
android:weightSum="8"
tools:showIn="#layout/activity_emotions"
tools:context="com.example.chadymaebarinan.emoji_express.Needs"
android:background="#drawable/backgroundnew">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:weightSum="5"
android:orientation="vertical">
<ImageView
android:layout_weight="4"
android:layout_width="100dp"
android:layout_height="70dp"
android:src="#drawable/kid"
android:layout_gravity="center"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="ME"
android:textSize="20sp"
android:layout_gravity="center" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="11"
android:weightSum="6"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="2"
android:weightSum="5"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="3"
android:weightSum="3"
android:orientation="horizontal"
android:padding="10dp">
<ImageButton
android:layout_weight="1"
android:id="#+id/buttonAngry"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:scaleType="fitCenter"
android:src="#drawable/angrybutton"
android:background="#null"/>
<ImageButton
android:layout_weight="1"
android:id="#+id/buttonHappy"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:scaleType="fitCenter"
android:src="#drawable/happybutton"
android:background="#null"/>
<ImageButton
android:layout_weight="1"
android:layout_width="wrap_content"
android:id="#+id/buttonSad"
android:layout_height="wrap_content"
android:scaleType="fitCenter"
android:src="#drawable/sadbutton"
android:background="#null"/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="0"
android:weightSum="3"
android:orientation="horizontal">
<TextView
android:padding="10dp"
android:layout_weight="1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Angry"
android:gravity="center" />
<TextView
android:padding="10dp"
android:layout_weight="1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Happy"
android:gravity="center"/>
<TextView
android:padding="10dp"
android:layout_weight="1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Sad"
android:gravity="center"/>
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="2"
android:weightSum="5"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="4"
android:weightSum="3"
android:orientation="horizontal"
android:padding="10dp">
<ImageButton
android:layout_weight="1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:scaleType="fitCenter"
android:id="#+id/buttonPainful"
android:src="#drawable/painfulbutton"
android:background="#null"/>
<ImageButton
android:layout_weight="1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/buttonScared"
android:scaleType="fitCenter"
android:src="#drawable/scaredbutton"
android:background="#null"/>
<ImageButton
android:layout_weight="1"
android:id="#+id/buttonInLove"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:scaleType="fitCenter"
android:src="#drawable/inlovebutton"
android:background="#null"/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="0"
android:weightSum="3"
android:orientation="horizontal">
<TextView
android:padding="10dp"
android:layout_weight="1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Painful"
android:gravity="center" />
<TextView
android:padding="10dp"
android:layout_weight="1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Scared"
android:gravity="center"/>
<TextView
android:padding="10dp"
android:layout_weight="1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="In Love"
android:gravity="center"/>
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="2"
android:weightSum="5"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="4"
android:weightSum="3"
android:orientation="horizontal"
android:padding="10dp">
<ImageButton
android:layout_weight="1"
android:id="#+id/buttonTired"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:scaleType="fitCenter"
android:src="#drawable/tiredbutton"
android:background="#null"/>
<ImageButton
android:layout_weight="1"
android:id="#+id/buttonEmbarrased"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:scaleType="fitCenter"
android:src="#drawable/embarrasedbutton"
android:background="#null"/>
<ImageButton
android:layout_weight="1"
android:id="#+id/buttonConfused"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:scaleType="fitCenter"
android:src="#drawable/confusedbutton"
android:background="#null"/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="0"
android:weightSum="3"
android:orientation="horizontal">
<TextView
android:padding="10dp"
android:layout_weight="1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Tired"
android:gravity="center" />
<TextView
android:padding="10dp"
android:layout_weight="1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Embarrased"
android:gravity="center"/>
<TextView
android:padding="10dp"
android:layout_weight="1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Confused"
android:gravity="center"/>
</LinearLayout>
</LinearLayout>
</LinearLayout>
</LinearLayout>
Thank you guys for helping. :)
hope this method help you:
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:orientation="vertical"
android:layout_height="match_parent"
android:paddingBottom="#dimen/activity_vertical_margin"
android:paddingLeft="#dimen/activity_horizontal_margin"
android:paddingRight="#dimen/activity_horizontal_margin"
android:paddingTop="#dimen/activity_vertical_margin">
<ImageView
android:layout_width="wrap_content"
android:layout_gravity="center_horizontal"
android:src="#drawable/common_plus_signin_btn_icon_light_pressed"
android:layout_height="wrap_content"/>
<TextView
android:layout_width="wrap_content"
android:text="me"
android:layout_gravity="center_horizontal"
android:layout_height="wrap_content"/>
<LinearLayout
android:layout_width="match_parent"
android:orientation="horizontal"
android:layout_height="wrap_content">
<LinearLayout
android:layout_width="0dp"
android:orientation="vertical"
android:layout_weight="1"
android:layout_height="wrap_content">
<ImageView
android:layout_width="wrap_content"
android:layout_gravity="center_horizontal"
android:src="#drawable/common_plus_signin_btn_icon_light_pressed"
android:layout_height="wrap_content"/>
<TextView
android:layout_width="wrap_content"
android:text="me"
android:layout_gravity="center_horizontal"
android:layout_height="wrap_content"/>
</LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:orientation="vertical"
android:layout_weight="1"
android:layout_height="wrap_content">
<ImageView
android:layout_width="wrap_content"
android:layout_gravity="center_horizontal"
android:src="#drawable/common_plus_signin_btn_icon_light_pressed"
android:layout_height="wrap_content"/>
<TextView
android:layout_width="wrap_content"
android:text="me"
android:layout_gravity="center_horizontal"
android:layout_height="wrap_content"/>
</LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:orientation="vertical"
android:layout_weight="1"
android:layout_height="wrap_content">
<ImageView
android:layout_width="wrap_content"
android:layout_gravity="center_horizontal"
android:src="#drawable/common_plus_signin_btn_icon_light_pressed"
android:layout_height="wrap_content"/>
<TextView
android:layout_width="wrap_content"
android:text="me"
android:layout_gravity="center_horizontal"
android:layout_height="wrap_content"/>
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:orientation="horizontal"
android:layout_height="wrap_content">
<LinearLayout
android:layout_width="0dp"
android:orientation="vertical"
android:layout_weight="1"
android:layout_height="wrap_content">
<ImageView
android:layout_width="wrap_content"
android:layout_gravity="center_horizontal"
android:src="#drawable/common_plus_signin_btn_icon_light_pressed"
android:layout_height="wrap_content"/>
<TextView
android:layout_width="wrap_content"
android:text="me"
android:layout_gravity="center_horizontal"
android:layout_height="wrap_content"/>
</LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:orientation="vertical"
android:layout_weight="1"
android:layout_height="wrap_content">
<ImageView
android:layout_width="wrap_content"
android:layout_gravity="center_horizontal"
android:src="#drawable/common_plus_signin_btn_icon_light_pressed"
android:layout_height="wrap_content"/>
<TextView
android:layout_width="wrap_content"
android:text="me"
android:layout_gravity="center_horizontal"
android:layout_height="wrap_content"/>
</LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:orientation="vertical"
android:layout_weight="1"
android:layout_height="wrap_content">
<ImageView
android:layout_width="wrap_content"
android:layout_gravity="center_horizontal"
android:src="#drawable/common_plus_signin_btn_icon_light_pressed"
android:layout_height="wrap_content"/>
<TextView
android:layout_width="wrap_content"
android:text="me"
android:layout_gravity="center_horizontal"
android:layout_height="wrap_content"/>
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:orientation="horizontal"
android:layout_height="wrap_content">
<LinearLayout
android:layout_width="0dp"
android:orientation="vertical"
android:layout_weight="1"
android:layout_height="wrap_content">
<ImageView
android:layout_width="wrap_content"
android:layout_gravity="center_horizontal"
android:src="#drawable/common_plus_signin_btn_icon_light_pressed"
android:layout_height="wrap_content"/>
<TextView
android:layout_width="wrap_content"
android:text="me"
android:layout_gravity="center_horizontal"
android:layout_height="wrap_content"/>
</LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:orientation="vertical"
android:layout_weight="1"
android:layout_height="wrap_content">
<ImageView
android:layout_width="wrap_content"
android:layout_gravity="center_horizontal"
android:src="#drawable/common_plus_signin_btn_icon_light_pressed"
android:layout_height="wrap_content"/>
<TextView
android:layout_width="wrap_content"
android:text="me"
android:layout_gravity="center_horizontal"
android:layout_height="wrap_content"/>
</LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:orientation="vertical"
android:layout_weight="1"
android:layout_height="wrap_content">
<ImageView
android:layout_width="wrap_content"
android:layout_gravity="center_horizontal"
android:src="#drawable/common_plus_signin_btn_icon_light_pressed"
android:layout_height="wrap_content"/>
<TextView
android:layout_width="wrap_content"
android:text="me"
android:layout_gravity="center_horizontal"
android:layout_height="wrap_content"/>
</LinearLayout>
</LinearLayout>
</LinearLayout>
I have the followin xml where I want imageview and then two textview and then imageview again, but it does not work properly.
Here is what I planned to have:
Here is what I am getting:
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="center_horizontal"
android:orientation="horizontal"
android:clickable="true"
android:onClick="userProfileDetailAction"
android:id="#+id/userProfileDetail"
android:paddingTop="5dp"
android:paddingBottom="5dp">
<com.example.eyeniaras.satdostum.CircleImageView
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_weight="0.3"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:background="#drawable/circle_shape"
app:civ_border_width="0.2dp"
app:civ_border_color="#color/dark"
android:id="#+id/userImage"
android:scaleType="centerCrop"/>
<LinearLayout
android:orientation="vertical"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="0.6">
<TextView
android:id="#+id/userName"
android:layout_width="wrap_content"
android:layout_height="0dp"
android:layout_gravity="center"
android:textColor="#android:color/black"
android:background="#ffffff"
android:textSize="18sp"
android:layout_weight="1"/>
<TextView
android:id="#+id/userRegistrationDate"
android:layout_width="wrap_content"
android:layout_height="0dp"
android:layout_gravity="center"
android:textColor="#android:color/black"
android:background="#ffffff"
android:textSize="18sp"
android:text = "45 days ago"
android:layout_weight="1"/>
</LinearLayout>
<ImageView
android:id="#+id/userClick"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_weight="0.1"
android:background="#drawable/list_arrow" />
</LinearLayout>
inside linearlayout must have 0 width
<LinearLayout
android:orientation="vertical"
android:layout_width="0dp"
android:layout_height="match_parent"
android:weightSum="100"
android:layout_weight="60">
Inside linearlayout second chance follow code.
<LinearLayout
android:orientation="vertical"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="60">
i was changed your code check it
change image View as you require and replace your code with this
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:orientation="horizontal"
android:clickable="true"
android:weightSum="100"
android:onClick="userProfileDetailAction"
android:id="#+id/userProfileDetail"
android:paddingTop="5dp"
android:paddingBottom="5dp">
<ImageView
android:layout_weight="20"
android:layout_width="0dp"
android:layout_height="match_parent"
android:id="#+id/userImage"
android:src="#android:drawable/btn_star_big_on"
android:scaleType="centerCrop"/>
<LinearLayout
android:orientation="vertical"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:weightSum="100"
android:gravity="center_vertical"
android:layout_weight="60">
<TextView
android:id="#+id/userName"
android:layout_width="wrap_content"
android:layout_height="0dp"
android:layout_gravity="center" android:text="hey hi"
android:textColor="#android:color/black"
android:background="#ffffff"
android:textSize="18sp"
android:textStyle="bold"
android:layout_weight="50"/>
<TextView
android:id="#+id/userRegistrationDate"
android:layout_width="wrap_content"
android:layout_height="0dp"
android:layout_gravity="center"
android:textColor="#android:color/black"
android:background="#ffffff"
android:textSize="18sp"
android:text = "45 days ago"
android:textStyle="bold"
android:layout_weight="50"/>
</LinearLayout>
<ImageView
android:id="#+id/userClick"
android:layout_width="0dp"
android:layout_height="match_parent"
android:src="#android:drawable/btn_star"
android:layout_weight="20" /></LinearLayout>
it is because of width make it 0dp..copy the bellow code it works perfect
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="center_horizontal"
android:orientation="horizontal"
android:clickable="true"
android:weightSum="100"
android:onClick="userProfileDetailAction"
android:id="#+id/userProfileDetail"
android:paddingTop="5dp"
android:paddingBottom="5dp">
<com.example.eyeniaras.satdostum.CircleImageView
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_weight="20"
android:layout_width="0dp"
android:layout_height="10dp"
android:background="#drawable/circle_shape"
app:civ_border_width="0.2dp"
app:civ_border_color="#color/dark"
android:id="#+id/userImage"
android:scaleType="centerCrop"/>
<LinearLayout
android:orientation="vertical"
android:layout_width="0dp"
android:orientation="vertical"
android:layout_height="match_parent"
android:weightSum="100"
android:layout_weight="60">
<TextView
android:id="#+id/userName"
android:layout_width="wrap_content"
android:layout_height="0dp"
android:layout_gravity="center"
android:textColor="#android:color/black"
android:background="#ffffff"
android:textSize="18sp"
android:textStyle="bold"
android:layout_weight="50"/>
<TextView
android:id="#+id/userRegistrationDate"
android:layout_width="wrap_content"
android:layout_height="0dp"
android:layout_gravity="center"
android:textColor="#android:color/black"
android:background="#ffffff"
android:textSize="18sp"
android:text = "45 days ago"
android:textStyle="bold"
android:layout_weight="50"/>
</LinearLayout>
<ImageView
android:id="#+id/userClick"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:textColor="#android:color/black"
android:textSize="18sp"
android:textStyle="bold"
android:layout_weight="20"
android:background="#drawable/list_arrow" />
</LinearLayout>
You can use The following Code:-
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:weightSum="10" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:orientation="horizontal"
android:weightSum="4" >
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:orientation="vertical" >
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:src="#drawable/ic_launcher" />
</LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="2"
android:orientation="vertical"
android:weightSum="1" >
<TextView
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight=".5"
android:gravity="center"
android:text="hello" />
<TextView
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight=".5"
android:gravity="center"
android:text="hello" />
</LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:orientation="vertical" >
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:src="#drawable/ic_launcher" />
</LinearLayout>
</LinearLayout>
This is the perfect scenario to make use of PercentageRelativeLayout. The best thing about this layout is that you can use percentage based dimensions which is super easy.
Here is a quick example of it,
<android.support.percent.PercentRelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
app:layout_widthPercent="50%"
app:layout_heightPercent="50%"
app:layout_marginTopPercent="25%"
app:layout_marginLeftPercent="25%"/>
</android.support.percent.PercentFrameLayout>
This is very simple and intuitive to use and is optimized for various use cases too.
I've taken your code and stripped it down. The following, at least in studio design, has the layout you've described. Perhaps progressively change/adapt this; checking as you go along that it maintains the desired layout.
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:android="http://schemas.android.com/apk/res-auto"
android:layout_gravity="center_horizontal"
android:orientation="horizontal"
android:clickable="true"
android:weightSum="100"
android:onClick="userProfileDetailAction"
android:id="#+id/userProfileDetail"
android:paddingTop="5dp"
android:paddingBottom="5dp"
xmlns:android="http://schemas.android.com/apk/res/android">
<ImageView
android:layout_width="100dp"
android:layout_height="100dp" />
<LinearLayout
android:orientation="vertical"
android:layout_width="500dp"
android:layout_height="100dp"
android:weightSum="100"
android:layout_weight="60">
<TextView
android:id="#+id/userName"
android:layout_width="500dp"
android:layout_height="50dp"
android:layout_gravity="center"
android:textColor="#android:color/black"
android:background="#ffffff"
android:textSize="18sp"
android:textStyle="bold"
android:layout_weight="50"/>
<TextView
android:id="#+id/userRegistrationDate"
android:layout_width="500dp"
android:layout_height="50dp"
android:layout_gravity="center"
android:textColor="#android:color/black"
android:background="#ffffff"
android:textSize="18sp"
android:text = "45 days ago"
android:textStyle="bold"
android:layout_weight="50"/>
</LinearLayout>
<ImageView
android:id="#+id/userClick"
android:layout_width="100dp"
android:layout_height="100dp" />
</LinearLayout>
Note I've done away with things like width="match_parent", which may have been an issue, as an example.
According to Image.
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/userProfileDetail"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:clickable="true"
android:onClick="userProfileDetailAction"
android:orientation="horizontal"
android:padding="5dp"
android:paddingBottom="5dp"
android:paddingTop="5dp"
android:weightSum="5">
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1">
<com.example.eyeniaras.satdostum.CircleImageView xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="#+id/userImage"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#drawable/circle_shape"
android:scaleType="centerCrop"
app:civ_border_color="#color/dark"
app:civ_border_width="0.2dp" />
</LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="3"
android:orientation="vertical"
android:weightSum="2">
<TextView
android:id="#+id/userName"
android:layout_width="match_parent"
android:gravity="center"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_weight="1"
android:background="#ffffff"
android:text="45 days ago"
android:textColor="#android:color/black"
android:textSize="18sp"
android:textStyle="bold" />
<TextView
android:id="#+id/userRegistrationDate"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_weight="1"
android:background="#ffffff"
android:gravity="center"
android:text="45 days ago"
android:textColor="#android:color/black"
android:textSize="18sp"
android:textStyle="bold" />
</LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1">
<ImageView
android:id="#+id/userClick"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_weight="20"
android:background="#drawable/list_arrow"
android:textColor="#android:color/black"
android:textSize="18sp"
android:textStyle="bold" />
</LinearLayout>
</LinearLayout>
Don't use weightsum at all and then assign weight according to requirement to all main views.It will definitely work.why to make things complex.I have done it for you.Check it below.
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:orientation="horizontal"
android:clickable="true"
android:onClick="userProfileDetailAction"
android:id="#+id/userProfileDetail"
android:paddingTop="5dp"
android:paddingBottom="5dp">
<com.example.eyeniaras.satdostum.CircleImageView
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_weight="0.2"
android:layout_width="0dp"
android:layout_height="match_parent"
android:background="#drawable/circle_shape"
app:civ_border_width="0.2dp"
app:civ_border_color="#color/dark"
android:id="#+id/userImage"
android:scaleType="centerCrop"/>
<LinearLayout
android:orientation="vertical"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="0.6">
<TextView
android:id="#+id/userName"
android:layout_width="wrap_content"
android:layout_height="0dp"
android:layout_gravity="center"
android:textColor="#android:color/black"
android:background="#ffffff"
android:textSize="18sp"
android:textStyle="bold"
android:layout_weight="1"/>
<TextView
android:id="#+id/userRegistrationDate"
android:layout_width="wrap_content"
android:layout_height="0dp"
android:layout_gravity="center"
android:textColor="#android:color/black"
android:background="#ffffff"
android:textSize="18sp"
android:text = "45 days ago"
android:textStyle="bold"
android:layout_weight="1"/>
</LinearLayout>
<ImageView
android:id="#+id/userClick"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_gravity="center"
android:textColor="#android:color/black"
android:textSize="18sp"
android:textStyle="bold"
android:layout_weight="0.2"
android:background="#drawable/list_arrow" />
</LinearLayout>
you need to use android:layout_weight for both images and textview so here is solution,
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/userProfileDetail"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_margin="5dp"
android:clickable="true"
android:onClick="userProfileDetailAction"
android:orientation="horizontal"
android:paddingBottom="5dp"
android:paddingTop="5dp"
android:weightSum="5">
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1.4">
<com.example.eyeniaras.satdostum.CircleImageView xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="#+id/userImage"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#drawable/circle_shape"
android:scaleType="centerCrop"
app:civ_border_color="#color/dark"
app:civ_border_width="0.2dp" />
</LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="3"
android:orientation="vertical"
android:weightSum="2">
<TextView
android:id="#+id/userName"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_weight="1"
android:background="#ffffff"
android:gravity="center"
android:text="Hi"
android:textColor="#android:color/black"
android:textSize="18sp"
android:textStyle="bold" />
<TextView
android:id="#+id/userRegistrationDate"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_weight="1"
android:background="#ffffff"
android:gravity="center"
android:text="45 days ago"
android:textColor="#android:color/black"
android:textSize="18sp"
android:textStyle="bold" />
</LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="0.6">
<ImageView
android:id="#+id/userClick"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_weight="20"
android:background="#drawable/list_arrow"
android:textColor="#android:color/black"
android:textSize="18sp"
android:textStyle="bold" />
</LinearLayout>
</LinearLayout>
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:weightSum="100"
android:layout_weight="60">
android:layout_width="match_parent",this layout's width is match_parent,so it filled up everything else,change to wrap_content,just like
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/userProfileDetail"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:clickable="true"
android:onClick="userProfileDetailAction"
android:orientation="horizontal"
android:paddingBottom="5dp"
android:paddingTop="5dp"
android:weightSum="100" >
<ImageView
android:id="#+id/userImage"
android:layout_width="0dp"
android:layout_height="40dp"
android:layout_weight="20"
android:background="#drawable/ic_launcher"
android:scaleType="centerCrop"
/>
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:weightSum="100"
android:layout_weight="60"
android:orientation="vertical"
>
<TextView
android:id="#+id/userName"
android:layout_width="wrap_content"
android:layout_height="0dp"
android:layout_gravity="center"
android:layout_weight="50"
android:background="#ffffff"
android:text="46 days ago"
android:textColor="#android:color/black"
android:textSize="18sp"
android:textStyle="bold" />
<TextView
android:id="#+id/userRegistrationDate"
android:layout_width="wrap_content"
android:layout_height="0dp"
android:layout_gravity="center"
android:layout_weight="50"
android:background="#ffffff"
android:text="45 days ago"
android:textColor="#android:color/black"
android:textSize="18sp"
android:textStyle="bold" />
</LinearLayout>
<ImageView
android:id="#+id/userImage"
android:layout_width="0dp"
android:layout_height="40dp"
android:layout_weight="20"
android:background="#drawable/ic_launcher"
android:scaleType="centerCrop"
/>
</LinearLayout>
use can following thing for weight ..i think this answer is helpful for you..
this xml
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="30"
android:background="#drawable/background"
android:gravity="center" >
<ImageView
android:layout_width="80dp"
android:layout_height="80dp"
android:src="#drawable/images" />
</LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="40" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:weightSum="10" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="5"
android:background="#drawable/background"
android:gravity="center" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Firstname" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="5"
android:background="#drawable/background"
android:gravity="center" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Lastname" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="30"
android:background="#drawable/background"
android:gravity="center" >
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/download" />
</LinearLayout>
</LinearLayout>
and this code for background past in drawable/background
<?xml version="1.0" encoding="UTF-8"?>
<!-- res/drawable/rounded_edittext.xml -->
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:padding="12dp"
android:shape="rectangle" >
<solid android:color="#FFFFFF" />
<stroke
android:width="0.3dp"
android:color="#797979" />`enter code here`
</shape>
I am making an android app, i want to make a layout like below image.
How can i manage image and layout weight with color.
Try this..
<?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:orientation="vertical" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:gravity="center"
android:orientation="horizontal" >
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_margin="5dp"
android:layout_weight="1"
android:gravity="center"
android:orientation="vertical" >
<ImageView
android:id="#+id/flag"
android:layout_width="wrap_content"
android:layout_height="0dp"
android:layout_gravity="center"
android:layout_weight="1"
android:src="#drawable/ic_launcher" />
<TextView
android:id="#+id/txt"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:background="#1D63A1"
android:gravity="center"
android:padding="7dp"
android:text="#string/hello_world"
android:textColor="#FFFFFF"
android:textSize="20dp" />
</LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_margin="5dp"
android:layout_weight="1"
android:gravity="center"
android:orientation="vertical" >
<ImageView
android:id="#+id/flag"
android:layout_width="wrap_content"
android:layout_height="0dp"
android:layout_gravity="center"
android:layout_weight="1"
android:src="#drawable/ic_launcher" />
<TextView
android:id="#+id/txt"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:background="#1D63A1"
android:gravity="center"
android:padding="7dp"
android:text="#string/hello_world"
android:textColor="#FFFFFF"
android:textSize="20dp" />
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:gravity="center"
android:orientation="horizontal" >
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_margin="5dp"
android:layout_weight="1"
android:gravity="center"
android:orientation="vertical" >
<ImageView
android:id="#+id/flag"
android:layout_width="wrap_content"
android:layout_height="0dp"
android:layout_gravity="center"
android:layout_weight="1"
android:src="#drawable/ic_launcher" />
<TextView
android:id="#+id/txt"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:background="#1D63A1"
android:gravity="center"
android:padding="7dp"
android:text="#string/hello_world"
android:textColor="#FFFFFF"
android:textSize="20dp" />
</LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_margin="5dp"
android:layout_weight="1"
android:gravity="center"
android:orientation="vertical" >
<ImageView
android:id="#+id/flag"
android:layout_width="wrap_content"
android:layout_height="0dp"
android:layout_gravity="center"
android:layout_weight="1"
android:src="#drawable/ic_launcher" />
<TextView
android:id="#+id/txt"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:background="#1D63A1"
android:gravity="center"
android:padding="7dp"
android:text="#string/hello_world"
android:textColor="#FFFFFF"
android:textSize="20dp" />
</LinearLayout>
</LinearLayout>
</LinearLayout>