i'm making app it's contents inside card-like views having couple of problems:
i can't label line (the blue line) move away card text. i've tried both padding , margin (on both line imageview , textview text) , nothing seems work here.
the bottom part of card title getting cropped because of line spacing. how can fix , keep line spacing?
check screenshot better understanding: http://imgur.com/qsocfrb
here's code card background , interface itself:
card_bg:
<?xml version="1.0" encoding="utf-8"?> <layer-list xmlns:android="http://schemas.android.com/apk/res/android"> <item> <shape android:shape="rectangle" android:dither="true"> <corners android:radius="1dp"/> <solid android:color="#bdbdbd" /> </shape> </item> <item android:bottom="2dp"> <shape android:shape="rectangle" android:dither="true"> <corners android:radius="2dp" /> <solid android:color="@android:color/white" /> <padding android:bottom="6dp" android:left="6dp" android:right="6dp" android:top="4dp" /> </shape> </item> </layer-list>
main acitivity:
<?xml version="1.0" encoding="utf-8"?> <framelayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="wrap_content"> <relativelayout android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginbottom="4dp" android:layout_marginleft="6dp" android:layout_marginright="6dp" android:layout_margintop="4dp" android:background="@drawable/card_bg" > <imageview android:id="@+id/iconview0001" android:layout_width="wrap_content" android:layout_height="wrap_content" android:paddingtop="6dp" android:src="@drawable/icon_example" /> <imageview android:id="@+id/labelsource0001" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignbottom="@+id/cardtext0001" android:layout_margintop="4dp" android:background="@drawable/card_label" /> <textview android:id="@+id/cardtitle0001" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_aligntop="@+id/cardtext0001" android:layout_torightof="@+id/iconview0001" android:fontfamily="sans-serif-condensed" android:maxlines="2" android:paddingleft="4dp" android:linespacingextra="-6dp" android:text="@string/card_title_002" android:textcolor="#717171" android:textsize="16sp" /> <textview android:id="@+id/cardtext0001" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_below="@+id/iconview0001" android:fontfamily="sans-serif" android:layout_margintop="4dp" android:maxlines="1" android:text="@string/card_desc_002" android:textcolor="#acacac" android:textsize="12sp" /> </relativelayout> </framelayout>
thanks in advance.
this creator of gist on github!
have tried increasing padding on relativelayout, perhaps fix problem? or on textview element?
try doing , see results are.
edit: also, why there negative line spacing within text view?
double edit: happening layout_alignbottom in linktitle textview shorter height of 2 lines of text, therefore cropping title limit height of textview of favicon imageview. removing property fixes issue.
similar issue goes label shape, alignbottom what's messing up.
change layout_alignbottom layout_below , padding/margin should affect position please.
here updated version of code should remedy issues:
<?xml version="1.0" encoding="utf-8"?> <framelayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/linkcardview" android:layout_width="match_parent" android:layout_height="wrap_content" android:background="#ccc" > <relativelayout android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginbottom="4dp" android:layout_marginleft="6dp" android:layout_marginright="6dp" android:layout_margintop="4dp" android:background="@drawable/card_bg"> <textview android:id="@+id/linktitle" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_torightof="@+id/faviconview0001" android:padding="4dp" android:maxlines="2" android:text="@string/link_title_001" android:textcolor="#717171" android:textsize="17sp" /> <textview android:id="@+id/linkdesc0001" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_below="@+id/linktitle" android:paddingtop="6dp" android:paddingbottom="9dp" android:fontfamily="sans-serif" android:maxlines="1" android:text="@string/link_desc_001" android:textcolor="#acacac" android:textsize="13sp" /> <imageview android:id="@+id/faviconview0001" android:layout_width="wrap_content" android:layout_height="wrap_content" android:paddingtop="6dp" android:layout_alignparentleft="true" android:src="@drawable/favicon_example" /> <view android:layout_height="0dp" android:layout_width="fill_parent" /> <imageview android:id="@+id/labelsource0001" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_below="@+id/linkdesc0001" android:background="@drawable/card_label" /> </relativelayout> </framelayout>
i hope of helps!
Comments
Post a Comment