I am facing a problem while populating a list view. Following is my layout for a list item.
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingTop="10dp"
android:paddingBottom="10dp"
android:paddingLeft="10dp"
android:paddingRight="10dp">
<CheckBox
android:id="#+id/item_pay_periods_check_box"
android:layout_width="20dp"
android:layout_height="20dp"
android:layout_alignParentLeft="true"
android:button="#drawable/btn_check"
android:layout_below="#+id/item_pay_periods_date"
android:layout_marginTop="5dp"
android:layout_marginRight="5dp"
android:visibility="visible"/>
<TextView
android:id="#+id/item_pay_periods_date"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Mon Sep 12"
android:textSize="13sp"
android:layout_toRightOf="#+id/item_pay_periods_check_box"
android:layout_alignParentTop="true"/>
<TextView
android:id="#+id/item_pay_periods_time_in"
android:layout_width="70dp"
android:layout_height="wrap_content"
android:text="12:00 am"
android:layout_toRightOf="#+id/item_pay_periods_check_box"
android:layout_below="#+id/item_pay_periods_date"
android:layout_marginTop="5dp"
android:textSize="13sp"/>
<TextView
android:id="#+id/item_pay_periods_time_out"
android:layout_width="70dp"
android:layout_height="wrap_content"
android:textSize="13sp"
android:layout_below="#+id/item_pay_periods_time_in"
android:text="12:00 am"
android:layout_toRightOf="#+id/item_pay_periods_check_box"
android:layout_marginTop="5dp"/>
<TextView
android:id="#+id/item_pay_periods_service_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Attendant care service service service"
android:textSize="13sp"
android:textStyle="bold"
android:layout_alignBaseline="#+id/item_pay_periods_time_in"
android:layout_toRightOf="#+id/item_pay_periods_time_in"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:maxLines="1"
android:ellipsize="end"
android:layout_toLeftOf="#+id/item_pay_periods_duration"
android:layout_toStartOf="#+id/item_pay_periods_duration" />
<TextView
android:id="#+id/item_pay_periods_activities"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:maxLines="1"
android:ellipsize="end"
android:text="Housework, shopping, shopping, shopping"
android:layout_below="#+id/item_pay_periods_service_name"
android:layout_toRightOf="#+id/item_pay_periods_time_out"
android:layout_marginLeft="5dp"
android:layout_alignBaseline="#+id/item_pay_periods_time_out"
android:layout_marginRight="5dp"
android:layout_toLeftOf="#+id/item_pay_periods_duration"
android:layout_toStartOf="#+id/item_pay_periods_duration"
android:visibility="visible"/>
<LinearLayout
android:id="#+id/itemPayPeriodsNotesLayout"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_below="#+id/item_pay_periods_activities"
android:layout_toRightOf="#+id/item_pay_periods_time_out"
android:layout_marginLeft="5dp"
android:layout_toLeftOf="#+id/item_pay_periods_duration"
android:layout_toStartOf="#+id/item_pay_periods_duration"
android:layout_marginTop="5dp">
<ImageView
android:id="#+id/item_pay_periods_img_tag"
android:layout_width="15dp"
android:layout_height="15dp"
android:src="#drawable/ic_tag"
android:layout_gravity="center_vertical"/>
<TextView
android:id="#+id/item_pay_periods_notes"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:maxLines="1"
android:ellipsize="end"
android:text="made trip to CVC"
android:textSize="13sp"
android:layout_marginLeft="5dp"
android:layout_gravity="center_vertical"/>
</LinearLayout>
<TextView
android:id="#+id/item_pay_periods_duration"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="5h 00m"
android:textSize="13sp"
android:layout_alignBaseline="#+id/item_pay_periods_time_in"
android:layout_alignBottom="#+id/item_pay_periods_time_in"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true"
android:visibility="visible"/>
<ImageView
android:id="#+id/item_pay_periods_img_submit_check_icon"
android:layout_width="15dp"
android:layout_height="15dp"
android:src="#drawable/ic_check"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:tint="#color/blue"
android:visibility="visible"/>
<TextView
android:id="#+id/item_pay_periods_entry_status"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toLeftOf="#+id/item_pay_periods_img_submit_check_icon"
android:text="Rejected"
android:textSize="12sp"
android:textColor="#color/red"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true" />
</RelativeLayout>
This is how it looks on Marshmallow and Nougat devices
Not overlapping views
And this is how it looks on Lollipop and pre lollipop devices
Overlapping views
Can anyone tell me why this is happening? Or anybody have faced such issue? Thanks in advance.
Related
So, I was trying to create a customized wedding card in Android Studio. The code is given below. I noticed difference in textColor while building it in the emulator and real device. Though the color of this attribute has been defined as black but in the real device it appears as white. Screenshots of the real device and emulator appearance have been mentioned in the link below:
Appearance in the Real Device
Appearance in the Emulator
Android Studio Version: 4.1.1
Any suggestions about how this issue can be solved in terms of real device?
Thanks in advance.
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="#+id/wedding_Card"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">
<ImageView
android:id="#+id/wedding_card"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scaleType="centerCrop"
app:srcCompat="#drawable/wedding_card"
android:contentDescription="TODO" />
<ImageView
android:id="#+id/petals"
android:layout_width="325dp"
android:layout_height="716dp"
android:layout_centerInParent="true"
android:contentDescription="TODO"
app:srcCompat="#drawable/pink" />
<ImageView
android:id="#+id/flower_top"
android:layout_width="186dp"
android:layout_height="88dp"
android:layout_above="#id/save_date"
android:layout_centerHorizontal="true"
android:layout_marginBottom="-30dp"
app:srcCompat="#drawable/floral_pattern"
android:contentDescription="TODO" />
<TextView
android:id="#+id/save_date"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="#id/date"
android:layout_centerHorizontal="true"
android:fontFamily="cursive"
android:text="#string/save_the_day"
android:textColor="#color/black"
android:textSize="25sp"
android:textStyle="bold"
android:visibility="visible"
tools:visibility="visible" />
<TextView
android:id="#+id/date"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="#id/flower_bou"
android:layout_centerHorizontal="true"
android:fontFamily="cursive"
android:text="#string/_25_12_2020"
android:textColor="#color/black"
android:textSize="20sp"
android:textStyle="bold"
tools:visibility="visible" />
<TextView
android:layout_width="52dp"
android:layout_height="38dp"
android:layout_above="#id/bride_groom"
android:layout_centerHorizontal="true"
android:layout_marginRight="6dp"
android:layout_marginBottom="7dp"
android:layout_toLeftOf="#id/flower_bou"
android:fontFamily="cursive"
android:text="#string/emma"
android:textColor="#color/black"
android:textSize="20sp"
android:textStyle="bold"
android:layout_marginEnd="6dp"
android:layout_toStartOf="#id/flower_bou" />
<ImageView
android:id="#+id/flower_bou"
android:layout_width="81dp"
android:layout_height="38dp"
android:layout_above="#id/bride_groom"
android:layout_centerHorizontal="true"
android:layout_marginBottom="5dp"
app:srcCompat="#drawable/flower_bouquet"
android:contentDescription="TODO" />
<TextView
android:layout_width="104dp"
android:layout_height="40dp"
android:layout_above="#id/bride_groom"
android:layout_centerHorizontal="true"
android:layout_marginStart="6dp"
android:layout_marginLeft="-21dp"
android:layout_marginTop="6dp"
android:layout_marginEnd="6dp"
android:layout_marginBottom="3dp"
android:layout_toRightOf="#id/bride_groom"
android:fontFamily="cursive"
android:text="#string/dexter"
android:textColor="#color/black"
android:textSize="20sp"
android:textStyle="bold"
android:layout_toEndOf="#id/bride_groom" />
<ImageView
android:id="#+id/bride_groom"
android:layout_width="133dp"
android:layout_height="111dp"
android:layout_centerInParent="true"
app:srcCompat="#drawable/bride_groom"
android:contentDescription="TODO" />
<TextView
android:id="#+id/We_getting_married"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#id/bride_groom"
android:layout_centerHorizontal="true"
android:fontFamily="cursive"
android:text="#string/we_are_getting_married"
android:textColor="#color/black"
android:textSize="30sp"
android:textStyle="bold" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/time"
android:layout_centerHorizontal="true"
android:layout_below="#id/We_getting_married"
android:text="#string/at_five_o_clock_in_the_evening"
android:textColor="#color/black"
android:fontFamily="sans-serif"
android:textStyle="bold"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/cityLove"
android:layout_centerHorizontal="true"
android:layout_below="#id/time"
android:text="#string/city_of_love"
android:textColor="#color/black"
android:fontFamily="sans-serif"
android:textStyle="bold"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/avenue"
android:layout_centerHorizontal="true"
android:layout_below="#id/cityLove"
android:text="#string/flower_avenue"
android:textColor="#color/black"
android:fontFamily="sans-serif"
android:textStyle="bold"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/church"
android:layout_centerHorizontal="true"
android:layout_below="#id/avenue"
android:text="#string/st_rose_church"
android:textColor="#color/black"
android:fontFamily="sans-serif"
android:textStyle="bold"/>
<TextView
android:id="#+id/dinner_dancing_to_follow"
android:layout_width="wrap_content"
android:layout_height="41dp"
android:layout_below="#id/church"
android:layout_centerHorizontal="true"
android:layout_marginTop="-10dp"
android:fontFamily="cursive"
android:text="#string/dinner_and_dancing_to_follow"
android:textColor="#color/black"
android:textSize="25sp"
android:textStyle="bold" />
</RelativeLayout>
Expected Result
Achieved Result
i am able to acheive everything but not able to place image (+ sign) between two layouts as described.
Following is the code i have used. i am not getting idea how should i place ( + sign image ) overlapping between two relative layouts.
I have tried placing imageview between 2 layouts but it takes space between layouts , i want overlapping between 2 layouts.
If anyone has come across such situation before or can help figure out this problem i would be very much grateful to them. thanks in advance.
<LinearLayout
android:id="#+id/line3"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/indicator"
android:orientation="horizontal"
android:weightSum="4">
<RelativeLayout
android:id="#+id/line3_1"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="#CCCCCC"
android:padding="#dimen/line3_layout_padding">
<TextView
android:id="#+id/textRent"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:text="Rent"
android:textColor="#999999"
android:textSize="#dimen/line3_text1_size" />
<TextView
android:id="#+id/textRentValue"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#id/textRent"
android:layout_centerHorizontal="true"
android:text="€30.00"
android:textColor="#999999"
android:textSize="#dimen/line3_text2_size" />
<TextView
android:id="#+id/textRentPerDay"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/textRentValue"
android:layout_centerHorizontal="true"
android:text="Per day"
android:textColor="#999999"
android:textSize="#dimen/line3_text1_size" />
</RelativeLayout>
<RelativeLayout
android:id="#+id/line3_2"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="#FF3333"
android:gravity="center"
android:padding="#dimen/line3_layout_padding">
<TextView
android:id="#+id/textIns"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:text="Insurance"
android:textColor="#FFFFFF"
android:textSize="#dimen/line3_text1_size" />
<TextView
android:id="#+id/textInsValue"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#id/textIns"
android:layout_centerHorizontal="true"
android:text="€4.00"
android:textColor="#FFFFFF"
android:textSize="#dimen/line3_text2_size" />
<TextView
android:id="#+id/textInsPerDay"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/textInsValue"
android:layout_centerHorizontal="true"
android:text="Per day"
android:textColor="#FFFFFF"
android:textSize="#dimen/line3_text1_size" />
</RelativeLayout>
<RelativeLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1.2"
android:background="#33CC66"
android:gravity="center"
android:padding="#dimen/line3_layout_padding">
<TextView
android:id="#+id/textEbysComm"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:text="Ebys commission"
android:textColor="#FFFFFF"
android:textSize="#dimen/line3_text1_size" />
<TextView
android:id="#+id/textEbysCommValue"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#id/textEbysComm"
android:layout_centerHorizontal="true"
android:text="€2.00"
android:textColor="#FFFFFF"
android:textSize="#dimen/line3_text2_size" />
<TextView
android:id="#+id/textEbysCommPerDay"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/textEbysCommValue"
android:layout_centerHorizontal="true"
android:text="Per day"
android:textColor="#FFFFFF"
android:textSize="#dimen/line3_text1_size" />
</RelativeLayout>
<RelativeLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="0.8"
android:background="#6666CC"
android:gravity="center"
android:padding="#dimen/line3_layout_padding">
<TextView
android:id="#+id/textTotalCost"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:text="Total Cost"
android:textColor="#FFFFFF"
android:textSize="#dimen/line3_text1_size" />
<TextView
android:id="#+id/textTotalCostValue"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#id/textTotalCost"
android:layout_centerHorizontal="true"
android:text="€36.00"
android:textColor="#FFFFFF"
android:textSize="#dimen/line3_text2_size" />
<TextView
android:id="#+id/textTotalCostPerDay"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/textTotalCostValue"
android:layout_centerHorizontal="true"
android:text="Per day"
android:textColor="#FFFFFF"
android:textSize="#dimen/line3_text1_size" />
</RelativeLayout>
</LinearLayout>
create three individual layouts as below and place them between RelativeLayouts as
XML for sub type
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_height="match_parent"
android:layout_width="60dp">
<View
android:layout_width="30dp"
android:background="#F00"
android:layout_alignParentLeft="true"
android:layout_height="match_parent"/>
<View
android:layout_width="30dp"
android:background="#0F0"
android:layout_alignParentRight="true"
android:layout_height="match_parent"/>
<ImageView
android:layout_width="30dp"
android:layout_height="30dp"
android:scaleType="fitCenter"
android:layout_centerInParent="true"
android:src="#android:drawable/ic_dialog_info"/>
</RelativeLayout>
I am creating a weather app.
How do I get this card effect ? How do I get a textView in a card like that ?
This is my status:
Can someone show how to make this or something at least similar
frist of all below dependencies add in your build.gradle
compile 'com.android.support:cardview-v7:24.2.1'
and in xml you can write this code. its just sample design according to your need...
this will solve your question... How do I get this card effect ? How do I get a textView in a card like that ?
<?xml version="1.0" encoding="utf-8"?>
<android.support.v7.widget.CardView android:id="#+id/card1"
android:layout_width="match_parent"
android:layout_height="200dp"
app:cardElevation="5dp"
app:cardUseCompatPadding="true"
app:cardCornerRadius="5dp"
app:cardBackgroundColor="#android:color/white"
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="10dp">
<TextView
android:id="#+id/text1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Detail"
android:textSize="20dp"
android:textColor="#color/colorPrimary"
android:layout_alignParentTop="true"
android:layout_marginRight="10dp"/>
<TextView
android:id="#+id/line"
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="#color/colorPrimary"
android:layout_below="#id/text1"/>
<TextView
android:id="#+id/text2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="TUE"
android:textColor="#color/colorGrey"
android:layout_marginTop="10dp"
android:textSize="16dp"
android:layout_below="#+id/text1"/>
<TextView
android:id="#+id/text3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="NOON"
android:layout_marginTop="10dp"
android:textSize="16dp"
android:layout_toRightOf="#+id/text2"
android:layout_marginLeft="10dp"
android:layout_below="#+id/text1"
android:textColor="#color/colorTextBlackLight"/>
<TextView
android:id="#+id/text4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="EVE"
android:layout_marginTop="10dp"
android:textSize="16dp"
android:layout_toRightOf="#+id/text3"
android:layout_marginLeft="30dp"
android:layout_below="#+id/text1"
android:textColor="#color/colorTextBlackLight"/>
<TextView
android:id="#+id/text5"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="NIGHT"
android:layout_marginTop="10dp"
android:textSize="16dp"
android:layout_toRightOf="#+id/text4"
android:layout_marginLeft="30dp"
android:layout_below="#+id/text1"
android:textColor="#color/colorTextBlackLight"/>
<TextView
android:id="#+id/text6"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="WED"
android:layout_marginTop="10dp"
android:textSize="16dp"
android:layout_toRightOf="#+id/text5"
android:layout_marginLeft="30dp"
android:layout_below="#+id/text1"
android:textColor="#color/colorGrey"/>
<TextView
android:id="#+id/text7"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="WED"
android:layout_marginTop="10dp"
android:textSize="16dp"
android:layout_toRightOf="#+id/text6"
android:layout_marginLeft="5dp"
android:layout_below="#+id/text1"
android:textColor="#color/colorTextBlackLight"/>
<TextView
android:id="#+id/text8"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="21"
android:layout_marginTop="10dp"
android:textSize="16dp"
android:layout_marginLeft="5dp"
android:layout_below="#+id/text2"
android:textColor="#color/colorTextBlackLight"/>
<ImageView
android:id="#+id/img1"
android:layout_width="30dp"
android:layout_height="25dp"
android:src="#drawable/ic_like_icon"
android:scaleType="fitXY"
android:layout_marginTop="10dp"
android:layout_below="#+id/text3"
android:layout_toRightOf="#+id/text8"/>
<TextView
android:id="#+id/textmore"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="MORE"
android:textSize="18dp"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:textColor="#color/colorTextBlackLight"/>
</RelativeLayout>
</android.support.v7.widget.CardView>
you can use this xml in row.xml for using in recyclerview to create multiple use
for listing read tutorial:
http://www.androidhive.info/2016/05/android-working-with-card-view-and-recycler-view
hope it will helpfull for you. dont forgot to accept it if helpfull
I have an item of RecyclerView that looks :
If user click on the help icon, I want to show a description of the item in the middle expanding the height of the item like this:
I tryed differents ways but I cant make it work, I tryed to set the height of the parent ( but I dont think this is a good approach, since it should get the size automattically in fuction of how many text have the description) but it doesnt work, make layout wrap content doesnt work either since it is a RelativeLayout with alignparent bottom, any help will be great
Layout
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/ll"
android:layout_width="wrap_content"
android:layout_height="80dp"
android:layout_centerHorizontal="true"
android:layout_margin="10dp"
android:layout_marginLeft="20dp"
android:layout_marginRight="20dp"
android:animateLayoutChanges="true"
android:background="#drawable/stroke_shop_adapter"
android:orientation="vertical">
<TextView
android:id="#+id/nombre"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_gravity="center"
android:layout_margin="5dp"
android:layout_marginTop="10dp"
android:layout_toRightOf="#+id/img"
android:layout_toLeftOf="#+id/ayuda"
android:gravity="center|top"
android:text="#string/level"
android:textColor="#fff"
android:textSize="15sp" />
<ImageView
android:id="#+id/img"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:layout_marginBottom="10dp"
android:layout_marginLeft="10dp"
android:layout_gravity="center"
android:src="#drawable/cubo" />
<TextView
android:id="#+id/descripcion"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toRightOf="#+id/img"
android:layout_toLeftOf="#+id/ayuda"
android:layout_below="#+id/separador1"
android:layout_above="#+id/coste"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:gravity="center"
android:text=""
android:textColor="#fff"
android:textSize="14sp" />
<ImageView
android:id="#+id/ayuda"
android:layout_width="50dp"
android:layout_height="50dp"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:layout_marginRight="10dp"
android:src="#drawable/ayuda_icon"/>
<TextView
android:id="#+id/coste"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_toLeftOf="#+id/ayuda"
android:gravity="center"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_marginBottom="10dp"
android:text="100$"
android:textColor="#fff"
android:textSize="13sp" />
<View
android:id="#+id/separador1"
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_below="#id/nombre"
android:layout_toRightOf="#+id/img"
android:layout_toLeftOf="#+id/ayuda"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_marginBottom="2dp"
android:background="#00c6ff"/>
<TextView
android:id="#+id/nivel"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="10dp"
android:layout_marginLeft="10dp"
android:layout_marginTop="5dp"
android:layout_toRightOf="#+id/img"
android:layout_alignParentBottom="true"
android:text="Level: 5/7"
android:textColor="#fff"
android:textSize="13sp" />
<TextView
android:id="#+id/maxNivel"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_below="#id/separador1"
android:layout_marginBottom="5dp"
android:layout_marginRight="20dp"
android:layout_marginTop="5dp"
android:text=""
android:textColor="#fff"
android:textSize="17sp" />
Try layout as:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#color/colorBlack"
android:orientation="vertical">
<ImageView
android:id="#+id/img"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="10dp"
android:layout_marginLeft="10dp"
android:layout_marginTop="10dp"
android:src="#mipmap/ic_launcher"/>
<ImageView
android:id="#+id/ayuda"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_marginBottom="10dp"
android:layout_marginRight="10dp"
android:layout_marginTop="10dp"
android:src="#mipmap/ic_launcher"/>
<TextView
android:id="#+id/nombre"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_gravity="center"
android:layout_margin="5dp"
android:layout_marginTop="10dp"
android:layout_toLeftOf="#+id/ayuda"
android:layout_toRightOf="#+id/img"
android:gravity="center|top"
android:text="Level"
android:textColor="#fff"
android:textSize="15sp"/>
<View
android:id="#+id/separador1"
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_below="#id/nombre"
android:layout_marginBottom="2dp"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_toLeftOf="#+id/ayuda"
android:layout_toRightOf="#+id/img"
android:background="#00c6ff"/>
<TextView
android:id="#+id/descripcion"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/separador1"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:layout_toLeftOf="#+id/ayuda"
android:layout_toRightOf="#+id/img"
android:text="content desc content desc content desc content desc content desc content desc content desc "
android:textColor="#fff"
android:gravity="center_horizontal"
android:textSize="14sp"/>
<TextView
android:id="#+id/nivel"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#id/descripcion"
android:layout_marginBottom="10dp"
android:layout_marginLeft="10dp"
android:layout_marginTop="5dp"
android:layout_toRightOf="#+id/img"
android:text="Level: 5/7"
android:textColor="#fff"
android:textSize="13sp"/>
<TextView
android:id="#+id/coste"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#id/descripcion"
android:layout_marginBottom="10dp"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_toLeftOf="#+id/ayuda"
android:gravity="center"
android:text="100$"
android:textColor="#fff"
android:textSize="13sp"/>
</RelativeLayout>
In that case you can use Expandable-RecyclerView
Download the latest AAR via Maven:
<dependency>
<groupId>com.levelupstudio</groupId>
<artifactId>expandable-recyclerview</artifactId>
<version>1.0.1</version>
</dependency>
or Gradle:
compile 'com.levelupstudio:expandable-recyclerview:1.0.1'
Other option is to use
You can try with ExpandableHeightListView
Add ExpandableHeightListView instead of ListView in your xml files:
<ScrollView 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">
<com.github.paolorotolo.expandableheightlistview.ExpandableHeightListView
android:id="#+id/expandable_listview"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:padding="8dp">
</com.github.paolorotolo.expandableheightlistview.ExpandableHeightListView>
</ScrollView>
Add this to your build.gradle:
repositories {
mavenCentral()
}
dependencies {
compile 'com.github.paolorotolo:expandableheightlistview:1.0.0'
}
I make the single_row.xml for the custom adapter which works perfectly on several devices but in the case of HighEnd device , the TextVIew is slightly up from the center. Why ??Please Help..
Image Link to understand the question Clearly
single_row.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
>
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/imageViewSingleRow"
android:layout_alignParentTop="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:src="#drawable/one"
android:paddingTop="12dp"
android:paddingBottom="12dp"
android:paddingLeft="5dp"
android:paddingRight="5dp"
android:adjustViewBounds="true"
/>
<TextView
android:paddingTop="10dp"
android:paddingBottom="6dp"
android:paddingLeft="5dp"
android:paddingRight="10dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Title text here"
android:id="#+id/textViewTitle"
android:layout_alignParentTop="true"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true"
android:layout_alignBottom="#+id/imageViewSingleRow"
android:layout_toRightOf="#+id/imageViewSingleRow"
android:layout_toEndOf="#+id/imageViewSingleRow"
android:textSize="18dp"
android:gravity="center_vertical"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:textSize="20sp"
android:textStyle="normal"
android:id="#+id/textViewNumbering"
android:layout_alignLeft="#+id/imageViewSingleRow"
android:layout_alignTop="#+id/imageViewSingleRow"
android:layout_alignRight="#+id/imageViewSingleRow"
android:layout_alignBottom="#+id/imageViewSingleRow"
android:gravity="center"
/>
<TextView
android:visibility="gone"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="description"
android:id="#+id/textViewDescription"
android:layout_below="#+id/textViewTitle"
android:layout_centerHorizontal="true" />
<TextView
android:visibility="gone"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="imageLink"
android:id="#+id/textViewImageLink"
android:layout_below="#+id/textViewDescription"
android:layout_alignRight="#+id/textViewDescription"
android:layout_alignEnd="#+id/textViewDescription"
/>
</RelativeLayout>
Finally done for the high end devices too..
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:text="1"
android:padding="26dp"
android:textStyle="bold"
android:id="#+id/textViewNumbering"
android:layout_alignTop="#+id/imageViewSingleRow"
android:layout_alignBottom="#+id/imageViewSingleRow"
android:gravity="center"
/>