wrong displaying Textview in ListVIew - android

I'm new in Android developing and I developping search apk.Search results displaying in custom listview. The layout for list view have this code:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="fill_parent"
android:layout_height="match_parent">
<RelativeLayout
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="wrap_content">
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text="Title"
android:id="#+id/Title"
android:layout_row="0"
android:layout_column="1"
android:layout_columnSpan="3"
android:layout_gravity="fill_horizontal"
android:layout_columnWeight="1"
android:layout_alignParentEnd="true"
android:layout_alignParentStart="true" />
</RelativeLayout>
<RelativeLayout
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="wrap_content">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="Price"
android:id="#+id/Price"
android:layout_row="1"
android:layout_column="1"
android:layout_gravity="left"
android:textColor="#ff5f59ff"
android:layout_alignParentLeft="true" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceSmall"
android:text="Stock"
android:id="#+id/InStock"
android:layout_gravity="right"
android:textColor="#ff00c000"
android:layout_alignParentRight="true" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceSmall"
android:text="Stock"
android:id="#+id/OutOfStock"
android:textColor="#ffff0f03"
android:layout_alignParentRight="true" />
</RelativeLayout>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceSmall"
android:text="ItemId"
android:id="#+id/ItemId"
android:visibility="invisible"
android:layout_columnSpan="4" />
</LinearLayout>
I'm excepting result sa at img1 , but instead of this I have result like at img2. Can somebody explain what's wrong?

Try this,
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:id="#+id/Title"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Title"
android:textAppearance="?android:attr/textAppearanceLarge" />
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1">
<TextView
android:id="#+id/Price"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_gravity="left"
android:text="Price"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="#ff5f59ff" />
</LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:orientation="vertical">
<TextView
android:id="#+id/InStock"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_gravity="right"
android:text="Stock"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="#ff00c000" />
<TextView
android:id="#+id/OutOfStock"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:text="Stock"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="#ffff0f03"
android:visibility="invisible" />
</LinearLayout>
</LinearLayout>
<TextView
android:id="#+id/ItemId"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="ItemId"
android:textAppearance="?android:attr/textAppearanceSmall"
android:visibility="invisible" />
</LinearLayout>

Related

onMeasure of custom expandable listview calling too many times

I have seen similar kind of questions in SO but it didn't solve my issue. So I'm posting it as a new question.
I have a custom expandable listview inside a scrollview and setting isExpanded true always. This expandable listview's(ExpandableHeightListView
in the below layout xml) adapter has a custom edittext, When I click on edittext it calls the onMeasure of Custom ExpandableListview infinitely. This is happening only in devices have Lollipop and above.
Can anybody point out me what I'm doing wrong. Yea I know its not a good approach to use listview inside a scrollview but its an old implementation which cannot be changed due to some functional requirements.
This is my layout:
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/goods_receipt_scrollview"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#drawable/abstract_blue_land">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:focusable="false"
android:focusableInTouchMode="true"
android:orientation="vertical"
android:padding="#dimen/page_padding">
<TextView
android:layout_width="match_parent"
android:layout_height="?android:attr/actionBarSize"
android:background="#android:color/transparent" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#color/cell_header_background"
android:padding="#dimen/cell_padding"
android:text="#string/purchase_order_details"
android:textAppearance="#style/section_header" />
<GridLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#color/cell_content_background"
android:columnCount="2"
android:padding="#dimen/cell_padding"
android:rowCount="2"
android:stretchColumns="*">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_column="0"
android:layout_gravity="left"
android:layout_row="0"
android:orientation="horizontal">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/purchase_order" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text=": " />
<TextView
android:id="#+id/pur_ord"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textStyle="bold" />
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_column="1"
android:layout_gravity="right"
android:layout_row="0"
android:orientation="horizontal">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/type" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text=": " />
<TextView
android:id="#+id/doc_type"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textStyle="bold" />
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_column="0"
android:layout_gravity="left"
android:layout_row="1"
android:orientation="horizontal"
android:paddingTop="3dip">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/created_on" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text=": " />
<TextView
android:id="#+id/created_on"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textStyle="bold" />
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_column="1"
android:layout_gravity="right"
android:layout_row="1"
android:orientation="horizontal"
android:paddingTop="3dip">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/created_by" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text=": " />
<TextView
android:id="#+id/created_by"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textStyle="bold" />
</LinearLayout>
</GridLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="5dip"
android:layout_marginTop="10dip"
android:background="#color/transparent_highlight"
android:orientation="horizontal"
android:padding="#dimen/input_section_padding">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/items"
android:textAppearance="#style/section_header" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text=" " />
<TextView
android:id="#+id/items_count"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="#style/section_header" />
</LinearLayout>
<LinearLayout
android:id="#+id/list_header"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#color/cell_header_background"
android:orientation="horizontal"
android:visibility="gone">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ems="5"
android:gravity="center_vertical"
android:minEms="5"
android:padding="5dip"
android:text="#string/item"
android:textColor="#color/button_background_light"
android:textStyle="bold" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ems="2"
android:gravity="center_vertical"
android:minEms="2"
android:padding="5dip"
android:text="#string/dflag"
android:textColor="#color/button_background_light"
android:textStyle="bold" />
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="4"
android:gravity="center_vertical"
android:padding="5dip"
android:text="#string/material"
android:textColor="#color/button_background_light"
android:textStyle="bold" />
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="3"
android:gravity="center_vertical"
android:padding="5dip"
android:text="#string/plant"
android:textColor="#color/button_background_light"
android:textStyle="bold" />
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="4"
android:gravity="center_vertical"
android:padding="5dip"
android:text="#string/ordered_qty"
android:textColor="#color/button_background_light"
android:textStyle="bold" />
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="4"
android:gravity="center_vertical"
android:padding="5dip"
android:text="#string/posted_qty"
android:textColor="#color/button_background_light"
android:textStyle="bold" />
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="4"
android:gravity="center_vertical"
android:padding="5dip"
android:text="#string/posting_qty"
android:textColor="#color/button_background_light"
android:textStyle="bold" />
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="2"
android:gravity="center_vertical"
android:padding="5dip"
android:text="#string/uom"
android:textColor="#color/button_background_light"
android:textStyle="bold" />
</LinearLayout>
<com.sample.template.utils.ExpandableHeightListView
android:id="#+id/list_goods_receipt_items"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:visibility="gone" />
<com.sample.template.utils.ExpandableHeightGridView
android:id="#+id/goods_receipt_po_items_grid"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:horizontalSpacing="10dip"
android:numColumns="2"
android:verticalSpacing="10dip" />
</LinearLayout>
</ScrollView>
If the question is too broad please let me know I'll update my question.
Regards

table layout problemss in custom listview android

I created a custom list view with table layout.
Now I want to show the text on the right. (You can see an example in the image, I cannot put this in the post)
But I cannot move textviews to the right.
http://i.stack.imgur.com/x57ly.png
my code:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_gravity="top"
android:background="#drawable/bar_bg"
android:paddingTop="0dip" >
<TableLayout
android:id="#+id/tableLayout1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
tools:ignore="RtlHardcoded" >
<TableRow
android:layout_marginTop="3dp"
tools:ignore="UselessParent"
>
<LinearLayout
android:layout_width="120dp"
android:layout_height="82dp"
android:paddingBottom="5dp"
android:paddingLeft="5dp"
android:paddingTop="5dp"
tools:ignore="RtlSymmetry" >
<ImageView
android:id="#+id/image"
android:layout_width="70dp"
android:layout_height="70dp"
android:layout_gravity="left|top"
android:scaleType="centerCrop"
tools:ignore="ContentDescription" />
</LinearLayout>
<TableLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_gravity="top"
android:paddingTop="0dp" >
<TableRow
android:layout_width="fill_parent"
android:layout_gravity="center_vertical"
android:textDirection="rtl"
tools:ignore="UnusedAttribute" >
<TextView
android:id="#+id/text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="right|center_vertical"
android:layout_marginLeft="5dp"
android:layout_marginTop="9dp"
android:layout_marginBottom="10dp"
android:paddingRight="6dp"
android:gravity="right"
android:layout_span="1"
android:layout_weight="1"
android:textColor="#000000"
android:textSize="16sp" />
</TableRow>
<TableRow android:layout_width="fill_parent" >
<TextView
android:id="#+id/text1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="right|center_vertical"
android:layout_marginBottom="10dp"
android:layout_marginLeft="5dp"
android:layout_marginTop="5dp"
android:layout_weight="1"
android:gravity="right"
android:paddingRight="6dp"
android:textColor="#000000"
android:textSize="16sp"
tools:ignore="RtlHardcoded" />
</TableRow>
</TableLayout>
</TableRow>
</TableLayout>
<TextView
android:id="#+id/tvdarsad"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:layout_marginRight="16dp"
android:textSize="22sp"
android:textAlignment="center"
android:textStyle="bold"
android:layout_marginTop="18dp"
android:background="#drawable/badge_ifaux"
android:text="%20"
android:textColor="#FFFFFF" />
<ImageView
android:id="#+id/imagecolor"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_marginTop="15dp"
android:layout_marginRight="4dp"
android:layout_alignParentTop="true"
android:src="#drawable/color1"/>
</RelativeLayout>
I think you implemented a complicated solution. You can achieve the same result using LinearLayout and distributing the weight between its views.
Here I post you have an example with your code with the same result of the photo.
Hope it helps.
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:weightSum="3">
<ImageView
android:id="#+id/image"
android:layout_width="0dip"
android:layout_height="match_parent"
android:layout_weight=".5"
tools:ignore="ContentDescription" />
<LinearLayout
android:layout_width="0dip"
android:layout_height="match_parent"
android:layout_weight="2"
android:layout_marginLeft="20dp"
android:orientation="vertical">
<TextView
android:id="#+id/text"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="text1"
android:textColor="#000000"
android:textSize="16sp" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="text2"
android:textColor="#000000"
android:textSize="16sp" />
</LinearLayout>
<TextView
android:id="#+id/text2"
android:layout_width="0dip"
android:layout_height="match_parent"
android:layout_weight=".3"
android:textColor="#000000"
android:textSize="16sp" />
<ImageView
android:id="#+id/imagecolor"
android:layout_width="0dip"
android:layout_height="match_parent"
android:layout_weight=".2"
android:src="#drawable/abc_btn_borderless_material"/>
</LinearLayout>

Resize image background keyboard(android)

Sorry for my english. I have background image, if keyboard show is resize background image. If keyboard not show evrithing work fine.
sorry obout image i have not 15 reputation
Its normal condition: image
Its if keyboard is show: image, background image is resize
Its if i in manifest i write adjustPan image
Bellow my xml:
<?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="wrap_content"
android:layout_height="match_parent"
android:orientation="vertical" >
<RelativeLayout
android:layout_width="match_parent"
android:background="#9a5f35"
android:layout_height="50dp" >
<LinearLayout
android:id="#+id/edit_profile"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_weight="1"
android:orientation="vertical" >
</LinearLayout>
<TextView
android:id="#+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:layout_marginTop="10dp"
android:layout_weight="1"
android:text="Получить бонус"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textColor="#fff"
android:textSize="20sp" />
<RelativeLayout
android:id="#+id/backDd"
android:layout_width="100dp"
android:layout_height="50dp" >
<ImageView
android:layout_width="20dp"
android:layout_height="20dp"
android:layout_centerVertical="true"
android:layout_marginLeft="10dp"
android:src="#drawable/back_arraund" />
</RelativeLayout>
</RelativeLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="bottom" >
<ScrollView
android:id="#+id/scroll"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:fillViewport="true"
android:fadingEdge="none" >
<ImageView
android:id="#+id/imageView21"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scaleType="centerCrop"
android:src="#drawable/bg_shkaf" />
</ScrollView>
<ScrollView
android:id="#+id/scrollView1"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginTop="40dp"
android:orientation="vertical" >
<TextView
android:id="#+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:text="1) Введите сумму вашего счета"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textColor="#fff"
android:textSize="20dp" />
<TextView
android:id="#+id/textView3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:text="2) Сгенерируйте код"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textColor="#fff"
android:textSize="20dp" />
<TextView
android:id="#+id/textView4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:text="3) Покажите код официанту"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textColor="#fff"
android:textSize="20dp" />
<TextView
android:id="#+id/textView5"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:text="4) Получите бонус на счет"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textColor="#fff"
android:textSize="20dp" />
</LinearLayout>
<TextView
android:id="#+id/textView6"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginTop="30dp"
android:gravity="center"
android:lineSpacingMultiplier="1.2"
android:text="Бонусы дают привликательную возможность\nполучть скидки и обменивать их на подарки\nот нашего кафе.Получайте как можно больше\nбонусов, для более ценных подарков"
android:textColor="#d2d3ce"
android:textSize="13dp"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="80dp"
android:orientation="horizontal" >
<TextView
android:id="#+id/textView7"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginLeft="10dp"
android:layout_marginRight="5dp"
android:text="Введите сумму:"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textColor="#fff"
android:textSize="20dp" />
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_weight="1" >
</RelativeLayout>
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="40dp"
android:layout_marginRight="10dp"
android:background="#drawable/button_radius_get_bonus"
android:gravity="center_vertical" >
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
<EditText
android:id="#+id/summgrn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginLeft="5dp"
android:hint="1200"
android:inputType="number"
android:maxLines="1"
android:maxLength="5"
android:background="#null"
android:textColor="#fff"
android:textColorHint="#91623f" >
<requestFocus />
</EditText>
<TextView
android:id="#+id/textView8"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginLeft="5dp"
android:layout_marginRight="20dp"
android:layout_weight="1"
android:text="грн."
android:textAppearance="?android:attr/textAppearanceLarge"
android:textColor="#fff"
android:textSize="20dp" />
</LinearLayout>
</RelativeLayout>
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<TextView
android:id="#+id/textView9"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginBottom="5dp"
android:layout_marginTop="1dp"
android:text="и покажите официанту код"
android:textColor="#fff"
/>
<ImageView
android:id="#+id/registrationsdasdad"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginBottom="1dp"
android:layout_marginTop="1dp"
android:src="#drawable/review_button"
android:visibility="invisible" />
<TextView
android:id="#+id/textView102"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginBottom="50dp"
android:layout_marginTop="1dp"
android:text="Мы очень старались - оцените нас!"
android:textColor="#fff"
android:visibility="invisible" />
</LinearLayout>
</LinearLayout>
</ScrollView>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical" >
</LinearLayout>
<ImageView
android:id="#+id/imageView212"
android:layout_width="300dp"
android:layout_height="300dp"
android:layout_centerHorizontal="true"
android:scaleType="centerCrop"
android:layout_marginTop="10dp"
android:visibility="invisible"
android:src="#drawable/image_8" />
<RelativeLayout
android:id="#+id/generateBonus"
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_gravity="bottom"
android:background="#9a5f35"
android:gravity="center_horizontal"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true">
<TextView
android:id="#+id/textView10"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:text="Получить"
android:textColor="#fff"
android:textSize="20dp" />
</RelativeLayout>
</RelativeLayout>
</LinearLayout>

android:layout_below= Does Not Set TextViews Below ImageButtons

I'm not sure why but in my linearlayout android:layout_below= Does Not Set TextViews Below ImageButtons.
I know I've overlooked something but I'm not sure exactly what that might be.
Any suggestions are appreciated.
<?xml version="1.0" encoding="UTF-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/layout1"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<LinearLayout
android:id="#+id/linearLayout1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_centerVertical="true"
android:weightSum="1" >
<View
android:id="#+id/view1"
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_weight="0.3" />
<ImageButton
android:id="#+id/photos"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="0.1"
android:src="#drawable/photos" />
<TextView
android:id="#+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/photos"
android:layout_marginTop="17dp"
android:text="Large Text"
android:textAppearance="?android:attr/textAppearanceLarge" />
<ImageButton
android:id="#+id/audio"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="0.1"
android:src="#drawable/audio" />
<TextView
android:id="#+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/audio"
android:layout_marginTop="17dp"
android:text="Large Text"
android:textAppearance="?android:attr/textAppearanceLarge" />
<ImageButton
android:id="#+id/written"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="0.1"
android:src="#drawable/written" />
<TextView
android:id="#+id/textView3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/written"
android:layout_marginTop="17dp"
android:text="Large Text"
android:textAppearance="?android:attr/textAppearanceLarge" />
<ImageButton
android:id="#+id/video"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="0.1"
android:src="#drawable/video" />
<TextView
android:id="#+id/textView4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/video"
android:layout_marginTop="17dp"
android:text="Large Text"
android:textAppearance="?android:attr/textAppearanceLarge" />
<View
android:id="#+id/view1"
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_weight="0.3" />
</LinearLayout>
<ImageView
android:id="#+id/imageView1"
android:layout_width="800dp"
android:layout_height="100dp"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_marginTop="48dp"
android:src="#drawable/icon_e" />
</RelativeLayout>
Try this..
android:layout_below is only for RelativeLayout not for LinearLayout
<?xml version="1.0" encoding="UTF-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/layout1"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<LinearLayout
android:id="#+id/linearLayout1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_centerVertical="true" >
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_weight="1"
android:gravity="center"
android:orientation="vertical" >
<ImageButton
android:id="#+id/photos"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:gravity="center"
android:src="#drawable/photos" />
<TextView
android:id="#+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginTop="17dp"
android:gravity="center"
android:text="Large Text"
android:textAppearance="?android:attr/textAppearanceLarge" />
</LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_weight="1"
android:gravity="center"
android:orientation="vertical" >
<ImageButton
android:id="#+id/audio"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:gravity="center"
android:src="#drawable/audio" />
<TextView
android:id="#+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginTop="17dp"
android:gravity="center"
android:text="Large Text"
android:textAppearance="?android:attr/textAppearanceLarge" />
</LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_weight="1"
android:gravity="center"
android:orientation="vertical" >
<ImageButton
android:id="#+id/written"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:gravity="center"
android:src="#drawable/written" />
<TextView
android:id="#+id/textView3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginTop="17dp"
android:gravity="center"
android:text="Large Text"
android:textAppearance="?android:attr/textAppearanceLarge" />
</LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_weight="1"
android:gravity="center"
android:orientation="vertical" >
<ImageButton
android:id="#+id/video"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:gravity="center"
android:src="#drawable/video" />
<TextView
android:id="#+id/textView4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginTop="17dp"
android:gravity="center"
android:text="Large Text"
android:textAppearance="?android:attr/textAppearanceLarge" />
</LinearLayout>
</LinearLayout>
<ImageView
android:id="#+id/imageView1"
android:layout_width="800dp"
android:layout_height="100dp"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_marginTop="48dp"
android:src="#drawable/icon_e" />
</RelativeLayout>
android:layout_below only works inside the RelativeLayout
You have to use RalativeLayout instead of LinearLayout.
LinearLayout can not allow layout_below property.
Put each related ImageButton and TextView into another LinearLayout with android:orientation="vertical" as follows...
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical" >
<ImageButton
android:id="#+id/photos"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/photos" />
<TextView
android:id="#+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/photos"
android:layout_marginTop="17dp"
android:text="Large Text"
android:textAppearance="?android:attr/textAppearanceLarge" />
</LinearLayout>
So, your updated layout can be as follows...
<?xml version="1.0" encoding="UTF-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/layout1"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<LinearLayout
android:id="#+id/linearLayout1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:gravity="center"
android:orientation="horizontal"
android:weightSum="1" >
<LinearLayout
android:layout_width="0dip"
android:layout_height="wrap_content"
android:layout_weight="0.2"
android:orientation="vertical" >
<ImageButton
android:id="#+id/photos"
android:layout_width="wrap_content"
android:layout_height="0dip"
android:layout_weight="1"
android:src="#drawable/photos" />
<TextView
android:id="#+id/textView1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="17dp"
android:text="Large Text"
android:textAppearance="?android:attr/textAppearanceLarge" />
</LinearLayout>
<LinearLayout
android:layout_width="0dip"
android:layout_height="wrap_content"
android:layout_weight="0.2"
android:orientation="vertical" >
<ImageButton
android:id="#+id/audio"
android:layout_width="wrap_content"
android:layout_height="0dip"
android:layout_weight="1"
android:src="#drawable/audio" />
<TextView
android:id="#+id/textView2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="17dp"
android:text="Large Text"
android:textAppearance="?android:attr/textAppearanceLarge" />
</LinearLayout>
<LinearLayout
android:layout_width="0dip"
android:layout_height="wrap_content"
android:layout_weight="0.2"
android:orientation="vertical" >
<ImageButton
android:id="#+id/written"
android:layout_width="wrap_content"
android:layout_height="0dip"
android:layout_weight="1"
android:src="#drawable/written" />
<TextView
android:id="#+id/textView3"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="17dp"
android:text="Large Text"
android:textAppearance="?android:attr/textAppearanceLarge" />
</LinearLayout>
<LinearLayout
android:layout_width="0dip"
android:layout_height="wrap_content"
android:layout_weight="0.2"
android:orientation="vertical" >
<ImageButton
android:id="#+id/video"
android:layout_width="wrap_content"
android:layout_height="0dip"
android:layout_weight="1"
android:src="#drawable/video" />
<TextView
android:id="#+id/textView4"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="17dp"
android:text="Large Text"
android:textAppearance="?android:attr/textAppearanceLarge" />
</LinearLayout>
</LinearLayout>
<ImageView
android:id="#+id/imageView1"
android:layout_width="800dp"
android:layout_height="100dp"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_marginTop="48dp"
android:src="#drawable/icon_e" />
</RelativeLayout>

android layout design looking good only in graphical layout not in devices

i tried designing an xml layout for my android app. It looks good in eclipse graphical layout of android api level 10. But when i run the same in my android device of 2.3.3(api level 10),
that layout looks completely different.
After the text title in the top everything gets changed
I have attached the screen shot of my graphical layout in eclipse and image from my android device
Following is my xml file
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<RelativeLayout
android:id="#+id/frame2_include"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:background="#drawable/bg">
<LinearLayout
android:id="#+id/title_layout"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_gravity="top">
<include
android:id="#+id/title_include"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
layout="#layout/title" />
</LinearLayout>
<RelativeLayout
android:id="#+id/r_title_layout"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#drawable/title_bg">
<TextView
android:id="#+id/normal_title_txt"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:text="#string/app"
android:textAppearance="?android:attr/textAppearanceMedium" />
</RelativeLayout>
<RelativeLayout
android:id="#+id/r_frame_layout"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/r_title_layout">
<ViewSwitcher
android:id="#+id/r_frame_viewSwitcher1"
android:layout_width="fill_parent"
android:layout_height="wrap_content">
<LinearLayout
android:id="#+id/r_frame_image_layout"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_margin="7dp"
android:background="#color/white"
android:layout_gravity="center_vertical">
<RelativeLayout
android:id="#+id/r_round_points"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#drawable/points_bg" >
<LinearLayout
android:id="#+id/r_center_frame_img_layout"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true">
<TextView
android:id="#+id/r_frame_img_txt1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="30dp"
android:text="50"
android:textColor="#000000"
android:textAppearance="?android:attr/textAppearanceMedium" />
<TextView
android:id="#+id/r_frame_img_txt2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/Points"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="#000000" />
</LinearLayout>
</RelativeLayout>
</LinearLayout>
<LinearLayout
android:id="#+id/r_frame_map_layout"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<include
android:id="#+id/parii_me_map_view2"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
layout="#layout/parii_map" />
</LinearLayout>
</ViewSwitcher>
<RelativeLayout
android:id="#+id/r_merge_layout"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="105dp"
android:background="#android:color/transparent">
<ImageView
android:contentDescription="#string/app_name"
android:id="#+id/merge_bg_img"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#drawable/title_bg"
android:layout_centerInParent="true"/>
<RelativeLayout
android:id="#+id/merge_view_pro_layout"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_toLeftOf="#+id/merge_center_img"
android:layout_centerVertical="true">
<TextView
android:id="#+id/merge_view_pro_txt"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/mrg_profile"
android:layout_centerInParent="true"
android:textAppearance="?android:attr/textAppearanceMedium" />
</RelativeLayout>
<ImageView
android:contentDescription="#string/app_name"
android:id="#+id/merge_center_img"
android:layout_width="73dp"
android:layout_height="73dp"
android:layout_centerInParent="true"
android:background="#drawable/ic_launcher" />
<RelativeLayout
android:id="#+id/merge_view_cash_layout"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_toRightOf="#+id/merge_center_img"
android:layout_centerVertical="true">
<TextView
android:id="#+id/merge_view_cash_txt"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:text="#string/mrg_cash"
android:textAppearance="?android:attr/textAppearanceMedium" />
</RelativeLayout>
</RelativeLayout>
<RelativeLayout
android:id="#+id/r_edit_box_layout"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="185dp">
<TextView
android:id="#+id/r_remaining_label"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_marginLeft="7dp"
android:layout_marginRight="3dp"
android:gravity="center|center_horizontal"
android:text="200"
android:textColor="#color/black"
android:background="#drawable/ponts_field"
android:textAppearance="?android:attr/textAppearanceSmall" />
<TextView
android:id="#+id/r_remaining_txt"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toRightOf="#+id/r_remaining_label"
android:text="#string/Reamins"
android:layout_centerVertical="true"
android:textColor="#color/black"
android:textAppearance="?android:attr/textAppearanceSmall" />
<TextView
android:id="#+id/r_points_txt"
android:layout_toLeftOf="#+id/r_points_label"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/Parii_Pts"
android:layout_centerVertical="true"
android:gravity="center"
android:textColor="#color/black"
android:textAppearance="?android:attr/textAppearanceSmall" />
<TextView
android:id="#+id/r_points_label"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_marginRight="7dp"
android:layout_marginLeft="3dp"
android:text="100"
android:gravity="center|center_horizontal"
android:textColor="#color/black"
android:background="#drawable/ponts_field"
android:textAppearance="?android:attr/textAppearanceSmall" />
</RelativeLayout>
</RelativeLayout>
<TextView
android:id="#+id/r_items_viewed_txt"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:layout_marginTop="10dp"
android:layout_marginLeft="20dp"
android:layout_marginRight="20dp"
android:layout_below="#+id/r_frame_layout"
android:maxLines="2"
android:textColor="#color/black"
android:textAppearance="?android:attr/textAppearanceSmall" />
<RelativeLayout
android:id="#+id/r_bottom_map_layout"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/r_items_viewed_txt"
android:layout_marginTop="20dp">
<TextView
android:id="#+id/r_valid_date"
android:layout_toLeftOf="#+id/r_points_label"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_marginLeft="10dp"
android:textColor="#color/black"
android:textAppearance="?android:attr/textAppearanceSmall" />
<ImageButton
android:contentDescription="#string/app_name"
android:id="#+id/parii_me_details_switch_mapBtn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_marginRight="15dp"
android:layout_centerVertical="true"
android:background="#drawable/map_sel_btn" />
</RelativeLayout>
</FrameLayout>
Pls say me where i am going wrong
try this:
only replace that by default image by your circle image having 50 pts inside.
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#aba4a4">
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:id="#+id/l1">
<Button
android:id="#+id/btn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Back btn"
android:textColor="#121212"
android:textSize="18dp" />
<TextView
android:id="#+id/txt"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Rewards"
android:textColor="#android:color/black"
android:textSize="18dp"
android:textStyle="bold"
android:layout_gravity="center_vertical"
android:layout_marginLeft="15dp"/>
</LinearLayout>
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:id="#+id/l2"
android:layout_below="#+id/l1"
android:background="#7d7373">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Title"
android:textSize="18dp"
android:layout_centerHorizontal="true"
android:textColor="#android:color/white"/>
</RelativeLayout>
<ImageView
android:layout_width="150dp"
android:layout_height="150dp"
android:layout_below="#+id/l2"
android:background="#drawable/ic_launcher"/>
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:id="#+id/l3"
android:background="#7d7373"
android:layout_centerInParent="true">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Profile"
android:textSize="18dp"
android:layout_alignParentLeft="true"
android:layout_centerVertical="true"
android:textColor="#android:color/white"
android:layout_marginLeft="20dp"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="View"
android:textSize="18dp"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:textColor="#android:color/white"
android:layout_marginRight="20dp"/>
</RelativeLayout>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#drawable/ic_launcher"
android:layout_centerInParent="true"/>
</RelativeLayout>
Add the remaining view in it.i think this must solve your issue.

Categories

Resources