android - Need fit in LinearLayout icons on every device -
i hope atleast try me :)
i beginner , sorry english.
my problem: need fit linearlayout on every device , not know how (it fits on phone, think not fit on others)
<android.support.v7.widget.cardview android:layout_width="match_parent" android:layout_height="70dp" android:layout_marginbottom="@dimen/spacing_medium" android:layout_marginleft="@dimen/spacing_middle" android:layout_marginright="@dimen/spacing_middle" android:layout_margintop="@dimen/spacing_large" app:cardcornerradius="@dimen/card_corner_radius" app:cardelevation="@dimen/elevation_card"> <linearlayout android:orientation="horizontal" android:layout_width="fill_parent" android:layout_height="wrap_content" android:padding="@dimen/spacing_medium" android:weightsum="1"> <linearlayout android:orientation="vertical" android:layout_width="66dp" android:layout_height="fill_parent" android:id="@+id/linearlayout2" android:paddingleft="5dp" android:paddingright="5dp" android:gravity="center_horizontal" android:onclick="clicklayout" android:clickable="true" android:background="?attr/selectableitembackground"> <imageview android:layout_width="@dimen/spacing_mlarge" android:layout_height="@dimen/spacing_mlarge" android:layout_margin="@dimen/spacing_middle" android:src="@drawable/ic_icon" android:tint="@color/grey_hard" /> <textview android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="check in" android:id="@+id/checkin" android:textcolor="@color/material_grey_800" android:gravity="center" android:singleline="true" android:layout_weight="0" android:ellipsize="end" android:textsize="12sp"/> </linearlayout> <linearlayout android:orientation="vertical" android:layout_width="66dp" android:layout_height="fill_parent" android:id="@+id/linearlayout4" android:paddingleft="5dp" android:paddingright="5dp" android:gravity="center_horizontal" android:onclick="clicklayout" android:clickable="true" android:background="?attr/selectableitembackground" > <imageview android:layout_width="@dimen/spacing_mlarge" android:layout_height="@dimen/spacing_mlarge" android:layout_margin="@dimen/spacing_middle" android:src="@drawable/ic_icon" android:tint="@color/grey_hard" /> <textview android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="add photo" android:id="@+id/addchillspotphoto" android:textcolor="@color/material_grey_800" android:gravity="center" android:singleline="true" android:layout_weight="0" android:ellipsize="end" android:textsize="12sp"/> </linearlayout> <linearlayout android:orientation="vertical" android:layout_width="66dp" android:layout_height="fill_parent" android:id="@+id/linearlayout5" android:paddingleft="5dp" android:paddingright="5dp" android:gravity="center_horizontal" android:onclick="clicklayout" android:clickable="true" android:background="?attr/selectableitembackground" > <imageview android:layout_width="@dimen/spacing_mlarge" android:layout_height="@dimen/spacing_mlarge" android:layout_margin="@dimen/spacing_middle" android:src="@drawable/ic_icon" android:tint="@color/grey_hard" /> <textview android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="report" android:id="@+id/reportchillspot" android:textcolor="@color/material_grey_800" android:gravity="center" android:singleline="true" android:layout_weight="0" android:ellipsize="end" android:textsize="12sp"/> </linearlayout> <linearlayout android:orientation="vertical" android:layout_width="66dp" android:layout_height="fill_parent" android:id="@+id/linearlayout6" android:paddingleft="5dp" android:paddingright="5dp" android:gravity="center_horizontal" android:onclick="clicklayout" android:clickable="true" android:background="?attr/selectableitembackground" > <imageview android:layout_width="@dimen/spacing_mlarge" android:layout_height="@dimen/spacing_mlarge" android:layout_margin="@dimen/spacing_middle" android:src="@drawable/ic_icon" android:tint="@color/grey_hard" /> <textview android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="rate" android:id="@+id/rate_chillspot" android:textcolor="@color/material_grey_800" android:gravity="center" android:singleline="true" android:layout_weight="0" android:ellipsize="end" android:textsize="12sp"/> </linearlayout> <linearlayout android:orientation="vertical" android:layout_width="66dp" android:layout_height="fill_parent" android:id="@+id/linearlayout7" android:paddingleft="5dp" android:paddingright="5dp" android:gravity="center_horizontal" android:onclick="clicklayout" android:clickable="true" android:background="?attr/selectableitembackground" > <imageview android:layout_width="@dimen/spacing_mlarge" android:layout_height="@dimen/spacing_mlarge" android:layout_margin="@dimen/spacing_middle" android:src="@drawable/ic_icon" android:tint="@color/grey_hard" /> <textview android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="workomg" android:id="@+id/future_distance" android:textcolor="@color/material_grey_800" android:gravity="center" android:singleline="true" android:layout_weight="0" android:ellipsize="end" android:textsize="12sp"/> </linearlayout> </linearlayout> </android.support.v7.widget.cardview>
thank guys help, tried best not know here....
//edit:
here results: (not working :/ )
only add android:layout_weight=".2"
, changed android:layout_width=".0dp"
each linearlayout
because 0.2 * (5 linearlayout) 1 it's android:weightsum="1"
try code..
<?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="match_parent" android:orientation="vertical"> <android.support.v7.widget.cardview android:layout_width="match_parent" android:layout_height="70dp" android:layout_marginbottom="@dimen/spacing_medium" android:layout_marginleft="@dimen/spacing_middle" android:layout_marginright="@dimen/spacing_middle" android:layout_margintop="@dimen/spacing_large" app:cardcornerradius="@dimen/card_corner_radius" app:cardelevation="@dimen/elevation_card"> <linearlayout android:layout_width="fill_parent" android:layout_height="match_parent" android:gravity="center" android:orientation="horizontal" android:padding="@dimen/spacing_medium" android:weightsum="1"> <linearlayout android:id="@+id/linearlayout2" android:layout_width=".0dp" android:layout_height="fill_parent" android:layout_weight=".2" android:background="?attr/selectableitembackground" android:clickable="true" android:gravity="center_horizontal" android:onclick="clicklayout" android:orientation="vertical" android:paddingleft="5dp" android:paddingright="5dp"> <imageview android:layout_width="@dimen/spacing_mlarge" android:layout_height="@dimen/spacing_mlarge" android:layout_margin="@dimen/spacing_middle" android:src="@drawable/com_facebook_profile_picture_blank_portrait" /> <textview android:id="@+id/checkin" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_weight="0" android:ellipsize="end" android:gravity="center" android:singleline="true" android:text="check in" android:textcolor="@color/material_grey_800" android:textsize="12sp" /> </linearlayout> <linearlayout android:id="@+id/linearlayout4" android:layout_width=".0dp" android:layout_height="fill_parent" android:layout_weight=".2" android:background="?attr/selectableitembackground" android:clickable="true" android:gravity="center_horizontal" android:onclick="clicklayout" android:orientation="vertical" android:paddingleft="5dp" android:paddingright="5dp"> <imageview android:layout_width="@dimen/spacing_mlarge" android:layout_height="@dimen/spacing_mlarge" android:layout_margin="@dimen/spacing_middle" android:src="@drawable/com_facebook_profile_picture_blank_portrait" android:tint="@color/grey_hard" /> <textview android:id="@+id/addchillspotphoto" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_weight="0" android:ellipsize="end" android:gravity="center" android:singleline="true" android:text="add photo" android:textcolor="@color/material_grey_800" android:textsize="12sp" /> </linearlayout> <linearlayout android:id="@+id/linearlayout5" android:layout_width=".0dp" android:layout_height="fill_parent" android:layout_weight=".2" android:background="?attr/selectableitembackground" android:clickable="true" android:gravity="center_horizontal" android:onclick="clicklayout" android:orientation="vertical" android:paddingleft="5dp" android:paddingright="5dp"> <imageview android:layout_width="@dimen/spacing_mlarge" android:layout_height="@dimen/spacing_mlarge" android:layout_margin="@dimen/spacing_middle" android:src="@drawable/ic_icon" android:tint="@color/grey_hard" /> <textview android:id="@+id/reportchillspot" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_weight="0" android:ellipsize="end" android:gravity="center" android:singleline="true" android:text="report" android:textcolor="@color/material_grey_800" android:textsize="12sp" /> </linearlayout> <linearlayout android:id="@+id/linearlayout6" android:layout_width=".0dp" android:layout_height="fill_parent" android:layout_weight=".2" android:background="?attr/selectableitembackground" android:clickable="true" android:gravity="center_horizontal" android:onclick="clicklayout" android:orientation="vertical" android:paddingleft="5dp" android:paddingright="5dp"> <imageview android:layout_width="@dimen/spacing_mlarge" android:layout_height="@dimen/spacing_mlarge" android:layout_margin="@dimen/spacing_middle" android:src="@drawable/ic_icon" android:tint="@color/grey_hard" /> <textview android:id="@+id/rate_chillspot" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_weight="0" android:ellipsize="end" android:gravity="center" android:singleline="true" android:text="rate" android:textcolor="@color/material_grey_800" android:textsize="12sp" /> </linearlayout> <linearlayout android:id="@+id/linearlayout7" android:layout_width=".0dp" android:layout_height="fill_parent" android:layout_weight=".2" android:background="?attr/selectableitembackground" android:clickable="true" android:gravity="center_horizontal" android:onclick="clicklayout" android:orientation="vertical" android:paddingleft="5dp" android:paddingright="5dp"> <imageview android:layout_width="@dimen/spacing_mlarge" android:layout_height="@dimen/spacing_mlarge" android:layout_margin="@dimen/spacing_middle" android:src="@drawable/ic_icon" android:tint="@color/grey_hard" /> <textview android:id="@+id/future_distance" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_weight="0" android:ellipsize="end" android:gravity="center" android:singleline="true" android:text="workomg" android:textcolor="@color/material_grey_800" android:textsize="12sp" /> </linearlayout> </linearlayout> </android.support.v7.widget.cardview> </linearlayout>
Comments
Post a Comment