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'
}
Related
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
Good day.I have an set of buttons which should be aligned to the bottom always,but they all also should be below an text,and it goes like this,if text is large,it is going just to push the buttons inside the scrollview,otherwise the buttons should be aligned to the parent bottom.Issue is that i add both of the tags to the linear layout wrapper of the buttons,but as soon as i set visibility of text to gone,the view just pops up and not aligning to parent bottom,here is the actual code,
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/single_product_scroll_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport="true">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
android:id="#+id/single_product_image"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_marginTop="35dp"
android:src="#drawable/img_placeholder" />
<RelativeLayout
android:id="#+id/basket_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_above="#+id/single_product_divider"
android:layout_alignEnd="#+id/single_product_divider"
android:layout_alignLeft="#+id/single_product_divider"
android:layout_alignParentTop="true"
android:layout_alignRight="#+id/single_product_divider"
android:layout_alignStart="#+id/single_product_divider"
android:layout_centerHorizontal="true"
android:layout_marginTop="10dp"
android:visibility="gone">
<ImageView
android:id="#+id/basket_success_icon"
android:layout_width="46dp"
android:layout_height="46dp"
android:layout_centerVertical="true"
android:layout_marginLeft="26dp"
android:src="#drawable/success_icon" />
<TextView
android:id="#+id/basket_product_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignTop="#+id/basket_success_icon"
android:layout_marginLeft="16dp"
android:layout_marginTop="5dp"
android:layout_toRightOf="#+id/basket_success_icon"
android:text="#string/product_added_to_basket_text"
android:textColor="#ffffff"
android:textSize="16sp" />
</RelativeLayout>
<View
android:id="#+id/single_product_divider"
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_below="#+id/single_product_image"
android:layout_margin="25dp"
android:background="#D1D3D4">
</View>
<TextView
android:id="#+id/single_product_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/single_product_divider"
android:layout_alignStart="#+id/single_product_divider"
android:layout_below="#+id/single_product_divider"
android:text="#string/loading_text"
android:textColor="#231F20" />
<TextView
android:id="#+id/single_product_weight_and_servings"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/single_product_divider"
android:layout_alignStart="#+id/single_product_divider"
android:layout_below="#+id/single_product_name"
android:layout_marginTop="5dp"
android:text="#string/weight_and_servings_text"
android:textColor="#231F20" />
<TextView
android:id="#+id/single_product_price"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/single_product_weight_and_servings"
android:layout_alignStart="#+id/single_product_weight_and_servings"
android:layout_below="#+id/single_product_weight_and_servings"
android:layout_marginTop="15dp"
android:text="$12.09"
android:textColor="#009444"
android:textSize="17sp"
android:textStyle="bold" />
<RatingBar
android:id="#+id/single_product_rating"
style="#style/Base.Widget.AppCompat.RatingBar.Small"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/single_product_price"
android:layout_alignStart="#+id/single_product_price"
android:layout_below="#+id/single_product_price"
android:layout_marginTop="5dp"
android:numStars="5" />
<TextView
android:id="#+id/single_product_rating_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignTop="#+id/single_product_rating"
android:layout_marginLeft="5dp"
android:layout_toRightOf="#+id/single_product_rating"
android:text="10.0/10"
android:textColor="#231F20"
android:textSize="12sp" />
<TextView
android:id="#+id/single_product_review_count"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignTop="#+id/single_product_rating_text"
android:layout_marginLeft="5dp"
android:layout_toRightOf="#+id/single_product_rating_text"
android:text="8 reviews"
android:textColor="#EC2027"
android:textSize="12sp" />
<TextView
android:id="#+id/single_product_stock_status"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_alignTop="#+id/single_product_review_count"
android:layout_marginRight="10dp"
android:text="In stock"
android:textColor="#939598" />
<View
android:id="#+id/single_product_center_divider"
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_below="#+id/single_product_rating"
android:layout_centerHorizontal="true"></View>
<Spinner
android:id="#+id/single_product_weight_spinner"
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_alignParentLeft="true"
android:layout_below="#+id/single_product_rating"
android:layout_marginLeft="10dp"
android:layout_marginRight="2dp"
android:layout_marginTop="10dp"
android:layout_toLeftOf="#+id/single_product_center_divider"
android:background="#drawable/spinner_background"
android:spinnerMode="dropdown"></Spinner>
<Spinner
android:id="#+id/single_product_type_spinner"
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_alignParentRight="true"
android:layout_below="#+id/single_product_rating"
android:layout_marginLeft="2dp"
android:layout_marginRight="10dp"
android:layout_marginTop="10dp"
android:layout_toRightOf="#+id/single_product_center_divider"
android:background="#drawable/spinner_background"
android:spinnerMode="dropdown"></Spinner>
<TextView
android:id="#+id/single_product_description"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/single_product_type_spinner"
android:layout_margin="16dp"
android:text="This is simply the best tripod for the money you\'ll ever buy,it\'s rock solid and the head alone is worth more then the asking price"
android:textColor="#231F20" />
<RelativeLayout
android:id="#+id/single_product_buttons_wrapper"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_below="#+id/single_product_description"
android:orientation="vertical">
<Button
android:id="#+id/single_product_add_to_cart_button"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:background="#F26522"
android:text="#string/add_to_cart_text"
android:textAllCaps="false"
android:textColor="#ffffff" />
<Button
android:id="#+id/single_product_info_button"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/single_product_add_to_cart_button"
android:layout_marginLeft="6dp"
android:layout_marginRight="5dp"
android:layout_marginTop="8dp"
android:background="#E7E8E9"
android:drawableRight="#drawable/ic_arrow_down"
android:paddingRight="10dp"
android:text="#string/product_info_text"
android:textAllCaps="false"
android:textColor="#231F20" />
<Button
android:id="#+id/single_product_nutritional_info_button"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/single_product_info_button"
android:layout_marginLeft="6dp"
android:layout_marginRight="5dp"
android:layout_marginTop="8dp"
android:background="#E7E8E9"
android:drawableRight="#drawable/ic_arrow_down"
android:paddingRight="10dp"
android:text="#string/product_nutritional_text"
android:textAllCaps="false"
android:textColor="#231F20" />
<Button
android:id="#+id/single_product_reviews_button"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/single_product_nutritional_info_button"
android:layout_marginBottom="5dp"
android:layout_marginLeft="6dp"
android:layout_marginRight="5dp"
android:layout_marginTop="8dp"
android:background="#E7E8E9"
android:drawableRight="#drawable/ic_arrow_down"
android:paddingRight="10dp"
android:text="#string/product_reviews_text"
android:textAllCaps="false"
android:textColor="#231F20" />
</RelativeLayout>
</RelativeLayout>
</ScrollView>
Can anyone please give any suggestion?
Edit : The full code of the view,actual buttons are inside RelativeLayout at the bottom of xml files there are 4 of buttons.The wrapper is single_product_buttons_wrapper
Add android:gravity="bottom" to LinearLayout containing buttons. It will work have tested it.
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_below="#+id/single_product_description"
android:gravity="bottom"
android:orientation="vertical">
Try this:
<?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"
android:focusable="true"
android:focusableInTouchMode="true">
<TextView
android:id="#+id/single_product_description"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="16dp"
android:text="This is simply the best tripod for the money you\'ll ever buy,it\'s rock solid and the head alone is worth more then the asking price"
android:textColor="#231F20" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:orientation="vertical">
<Button
android:id="#+id/single_product_add_to_cart_button"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_above="#+id/single_product_info_button"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:background="#F26522"
android:text="123"
android:textAllCaps="false"
android:textColor="#ffffff" />
<Button
android:id="#+id/single_product_info_button"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_above="#+id/single_product_nutritional_info_button"
android:layout_marginLeft="6dp"
android:layout_marginRight="5dp"
android:layout_marginTop="8dp"
android:background="#E7E8E9"
android:paddingRight="10dp"
android:text="234"
android:textAllCaps="false"
android:textColor="#231F20" />
<Button
android:id="#+id/single_product_nutritional_info_button"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_above="#+id/single_product_reviews_button"
android:layout_marginLeft="6dp"
android:layout_marginRight="5dp"
android:layout_marginTop="8dp"
android:background="#E7E8E9"
android:paddingRight="10dp"
android:text="5555"
android:textAllCaps="false"
android:textColor="#231F20" />
<Button
android:id="#+id/single_product_reviews_button"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_marginBottom="5dp"
android:layout_marginLeft="6dp"
android:layout_marginRight="5dp"
android:layout_marginTop="8dp"
android:background="#E7E8E9"
android:paddingRight="10dp"
android:text="99999"
android:textAllCaps="false"
android:textColor="#231F20" />
</LinearLayout>
</RelativeLayout>
I am tryign to create a chat bubble like this -
But I want this bubble to wrap its content.
Now problem is that whenever I try to use 'alignparentRight = true" to those 'double-ticks', it expands to view to take up whole parents width.
How could I make it wrap the its content where ticks stay at right bottom and text 'hero' stays on top left.
<RelativeLayout
android:id="#+id/wrapper"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="5dp"
android:background="#drawable/bubble_send"
android:gravity="right"
android:orientation="vertical">
<ImageView
android:id="#+id/chat_image"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="#+id/chat_comment"
android:src="#drawable/rotate"
android:visibility="visible"/>
<TextView
android:id="#+id/chat_comment"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toLeftOf="#+id/time"
android:maxWidth="200dp"
android:text="Hero"
android:textColor="#android:color/primary_text_light"/>
<TextView
android:id="#+id/time"
android:layout_width="50dp"
android:layout_height="wrap_content"
android:layout_alignBottom="#+id/tick"
android:layout_toLeftOf="#id/tick"
android:text="11:25 am"
android:textColor="#color/black"
android:textSize="10sp"/>
<ImageView
android:id="#+id/tick"
android:layout_width="15dp"
android:layout_height="15dp"
android:layout_alignParentRight="true"
android:layout_below="#+id/chat_comment"
android:layout_marginTop="5dp"
android:src="#drawable/ic_tick_double"
android:visibility="visible"/>
</RelativeLayout>
I wanted to avoid multiple nesting, but this was the only resort. -
<LinearLayout
android:id="#+id/wrapper"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#drawable/bubble_send"
android:minWidth="100dp"
android:orientation="vertical">
<ImageView
android:id="#+id/chat_image"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="#+id/chat_comment"
android:layout_gravity="center_horizontal"
android:src="#drawable/rotate"
android:visibility="gone"/>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="left"
android:layout_margin="5dp"
android:orientation="vertical">
<TextView
android:id="#+id/chat_comment"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toLeftOf="#+id/time"
android:maxWidth="200dp"
android:text="Hero"
android:textColor="#android:color/primary_text_light"/>
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="right">
<TextView
android:id="#+id/time"
android:layout_width="50dp"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:layout_toLeftOf="#id/tick"
android:text="11:25 am"
android:textColor="#color/black"
android:textSize="10sp"/>
<ImageView
android:id="#+id/tick"
android:layout_width="15dp"
android:layout_height="15dp"
android:layout_alignParentRight="true"
android:layout_marginTop="5dp"
android:src="#drawable/ic_tick_double"
android:visibility="visible"/>
</LinearLayout>
</LinearLayout>
<RelativeLayout
android:id="#+id/wrapper"
android:layout_width="250dp"
android:layout_height="wrap_content"
android:layout_margin="5dp"
android:background="#drawable/bubble_send"
android:gravity="right"
android:orientation="vertical">
<ImageView
android:id="#+id/chat_image"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="#+id/chat_comment"
android:src="#drawable/rotate"
android:visibility="visible"/>
<TextView
android:id="#+id/chat_comment"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toLeftOf="#+id/time"
android:maxWidth="200dp"
android:text="Hero"
android:textColor="#android:color/primary_text_light"/>
<TextView
android:id="#+id/time"
android:layout_width="50dp"
android:layout_height="wrap_content"
android:layout_alignBottom="#+id/tick"
android:layout_toLeftOf="#id/tick"
android:text="11:25 am"
android:textColor="#color/black"
android:textSize="10sp"/>
<ImageView
android:id="#+id/tick"
android:layout_width="15dp"
android:layout_height="15dp"
android:layout_alignParentRight="true"
android:layout_below="#+id/chat_comment"
android:layout_marginTop="5dp"
android:src="#drawable/ic_tick_double"
android:visibility="visible"/>
-Instead of making your main layout to wrap content put it as fixed width
I have a listView with an header which contain imageview, bunch of textviews . But now i want to put two tabs at the bottom of that header to change the content of the listview with those two tabs, I am using Sherlockfragments in my app and the whole listview and its header are in one of my fragment .
This is my header of the listview , right now i am using two buttons instead of tabs but i want to replace them with tabs
<RelativeLayout
android:id="#+id/relativeLayout1"
android:layout_width="match_parent"
android:layout_height="250dp"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:background="#drawable/purple_bg"
android:orientation="vertical" >
<ImageView
android:id="#+id/userimage_profile"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_marginTop="16dp"
android:src="#drawable/loader" />
<TextView
android:id="#+id/fullname_profile"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/userimage_profile"
android:layout_centerHorizontal="true"
android:layout_marginTop="5dp"
android:text="ladygaga"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textSize="15sp" />
<TextView
android:id="#+id/twittername_profile"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/fullname_profile"
android:layout_centerHorizontal="true"
android:text="ladygaga"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textSize="10sp" />
<TextView
android:id="#+id/profile_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="#+id/twittername_profile"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_marginTop="8dp"
android:gravity="center"
android:maxLines="2"
android:text="By modifying the URL, dsfhieor fergieirgh erjogw54ijg you can retrieve other variant sizings such as ""
android:textAppearance="?android:attr/textAppearanceSmall"
android:textSize="13sp" />
<ImageButton
android:id="#+id/find_people"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/profile_text"
android:layout_centerHorizontal="true"
android:layout_marginTop="10dp"
android:background="#null"
android:onClick="onClick"
android:src="#drawable/find_people" />
<LinearLayout
android:id="#+id/linearLayout1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:orientation="horizontal" >
<TextView
android:id="#+id/chance_selected"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="0dp"
android:layout_weight="1"
android:background="#drawable/chances_selected"
android:gravity="center"
android:scaleType="centerCrop"
android:text="Chances(100)"
android:textSize="15sp" />
<TextView
android:id="#+id/fav_unselect"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="#drawable/fav_unselected"
android:gravity="center"
android:scaleType="centerCrop"
android:text="Favourites"
android:textSize="15sp" />
</LinearLayout>
<TextView
android:id="#+id/follow_profile"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignTop="#+id/find_people"
android:layout_marginRight="10dp"
android:layout_toRightOf="#+id/userimage_profile"
android:background="#drawable/follow_reqchance"
android:gravity="center"
android:text="Follow"
android:textColor="#ffffff" />
<TextView
android:id="#+id/req_chance_profile"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignTop="#+id/find_people"
android:layout_marginLeft="10dp"
android:layout_toLeftOf="#+id/userimage_profile"
android:background="#drawable/follow_reqchance"
android:gravity="center"
android:text="Request Chance"
android:textColor="#ffffff" />
</RelativeLayout>
I want to create a listview like older gmail app. See the screenshot:
I tried putting an empty view like this:
<TextView
android:id="#+id/color_highlight"
android:layout_width="5dp"
android:layout_height="match_parent"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:background="#ff0000"
android:minHeight="48dp" />
<TextView
android:id="#+id/name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_marginRight="20dp"
android:layout_marginTop="10dp"
android:layout_toLeftOf="#id/color_highlight"
android:text="Mudit Agarwal"
android:textStyle="bold"
android:textColor="#242424"
android:textIsSelectable="false"
android:textSize="22sp" />
<TextView
android:id="#+id/number"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignRight="#id/name"
android:layout_below="#id/name"
android:text="9933445566"
android:textColor="#777777"
android:textIsSelectable="false"
android:layout_marginBottom="10dp"
android:textSize="15sp" />
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_centerVertical="true"
android:padding="3dp"
android:src="#drawable/contact" />
but this is not taking full height of the view. Please suggest.
What I changed is
android:layout_alignBottom="#+id/number"
to your color_highlight TextView. and instead of margin, I put padding like below in number TextView.
android:paddingBottom="20dp"
just put following layout code.
<?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="wrap_content" >
<TextView
android:id="#+id/color_highlight"
android:layout_width="5dp"
android:layout_height="match_parent"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:layout_alignBottom="#+id/number"
android:background="#ff0000"
android:minHeight="48dp" />
<TextView
android:id="#+id/name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_marginRight="20dp"
android:layout_marginTop="10dp"
android:layout_toLeftOf="#id/color_highlight"
android:text="Mudit Agarwal"
android:textColor="#242424"
android:textIsSelectable="false"
android:textSize="22sp"
android:textStyle="bold" />
<TextView
android:id="#+id/number"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignRight="#id/name"
android:layout_below="#id/name"
android:paddingBottom="20dp"
android:text="9933445566"
android:textColor="#777777"
android:textIsSelectable="false"
android:textSize="15sp" />
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_centerVertical="true"
android:padding="3dp"
android:src="#drawable/contact" />
</RelativeLayout>
I'm not sure but you can try putting android:layout_height="0dip" instead of android:layout_height="match_parent".